@proposit/proposit-core 2.1.0 → 2.2.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.
Files changed (55) hide show
  1. package/dist/extensions/chat-completions/errors.d.ts +66 -0
  2. package/dist/extensions/chat-completions/errors.d.ts.map +1 -0
  3. package/dist/extensions/chat-completions/errors.js +139 -0
  4. package/dist/extensions/chat-completions/errors.js.map +1 -0
  5. package/dist/extensions/chat-completions/http.d.ts +10 -0
  6. package/dist/extensions/chat-completions/http.d.ts.map +1 -0
  7. package/dist/extensions/chat-completions/http.js +80 -0
  8. package/dist/extensions/chat-completions/http.js.map +1 -0
  9. package/dist/extensions/chat-completions/index.d.ts +7 -0
  10. package/dist/extensions/chat-completions/index.d.ts.map +1 -0
  11. package/dist/extensions/chat-completions/index.js +18 -0
  12. package/dist/extensions/chat-completions/index.js.map +1 -0
  13. package/dist/extensions/chat-completions/provider.d.ts +5 -0
  14. package/dist/extensions/chat-completions/provider.d.ts.map +1 -0
  15. package/dist/extensions/chat-completions/provider.js +192 -0
  16. package/dist/extensions/chat-completions/provider.js.map +1 -0
  17. package/dist/extensions/chat-completions/structured-output.d.ts +18 -0
  18. package/dist/extensions/chat-completions/structured-output.d.ts.map +1 -0
  19. package/dist/extensions/{ollama → chat-completions}/structured-output.js +14 -10
  20. package/dist/extensions/chat-completions/structured-output.js.map +1 -0
  21. package/dist/extensions/chat-completions/types.d.ts +65 -0
  22. package/dist/extensions/chat-completions/types.d.ts.map +1 -0
  23. package/dist/extensions/chat-completions/types.js +19 -0
  24. package/dist/extensions/chat-completions/types.js.map +1 -0
  25. package/dist/extensions/openai/provider.d.ts +2 -2
  26. package/dist/extensions/pipelines/base/types.d.ts +6 -5
  27. package/dist/extensions/pipelines/base/types.d.ts.map +1 -1
  28. package/dist/lib/pipelines/stage-helpers.d.ts.map +1 -1
  29. package/dist/lib/pipelines/stage-helpers.js +37 -1
  30. package/dist/lib/pipelines/stage-helpers.js.map +1 -1
  31. package/dist/lib/pipelines/types.d.ts +2 -2
  32. package/package.json +6 -16
  33. package/dist/extensions/ollama/errors.d.ts +0 -73
  34. package/dist/extensions/ollama/errors.d.ts.map +0 -1
  35. package/dist/extensions/ollama/errors.js +0 -228
  36. package/dist/extensions/ollama/errors.js.map +0 -1
  37. package/dist/extensions/ollama/index.d.ts +0 -6
  38. package/dist/extensions/ollama/index.d.ts.map +0 -1
  39. package/dist/extensions/ollama/index.js +0 -17
  40. package/dist/extensions/ollama/index.js.map +0 -1
  41. package/dist/extensions/ollama/provider.d.ts +0 -22
  42. package/dist/extensions/ollama/provider.d.ts.map +0 -1
  43. package/dist/extensions/ollama/provider.js +0 -417
  44. package/dist/extensions/ollama/provider.js.map +0 -1
  45. package/dist/extensions/ollama/structured-output.d.ts +0 -18
  46. package/dist/extensions/ollama/structured-output.d.ts.map +0 -1
  47. package/dist/extensions/ollama/structured-output.js.map +0 -1
  48. package/dist/extensions/ollama/timeout-fetch.d.ts +0 -24
  49. package/dist/extensions/ollama/timeout-fetch.d.ts.map +0 -1
  50. package/dist/extensions/ollama/timeout-fetch.js +0 -76
  51. package/dist/extensions/ollama/timeout-fetch.js.map +0 -1
  52. package/dist/extensions/ollama/types.d.ts +0 -219
  53. package/dist/extensions/ollama/types.d.ts.map +0 -1
  54. package/dist/extensions/ollama/types.js +0 -7
  55. package/dist/extensions/ollama/types.js.map +0 -1
@@ -1,219 +0,0 @@
1
- import type { TOllamaJsonSchema } from "./structured-output.js";
2
- /**
3
- * The minimal subset of the `ollama` SDK's `chat()` response we read.
4
- * We model only the fields the provider touches so a mock client (and
5
- * a real `ChatResponse`) both satisfy it without importing the SDK type
6
- * (which would force the optional peer into the type graph).
7
- */
8
- export type TOllamaChatToolCall = {
9
- function: {
10
- name: string;
11
- arguments: Record<string, unknown>;
12
- };
13
- };
14
- export type TOllamaChatMessage = {
15
- role: string;
16
- content: string;
17
- /**
18
- * Thinking-model reasoning trace, present when `think` is enabled.
19
- * A wire field on the Ollama chat message; read so an empty
20
- * `content` accompanied by a thinking trace can be surfaced as a
21
- * deterministic, actionable failure instead of a silently-discarded
22
- * answer. See `OllamaProvider`'s empty-content handling.
23
- */
24
- thinking?: string;
25
- tool_calls?: TOllamaChatToolCall[];
26
- };
27
- export type TOllamaChatResponse = {
28
- message: TOllamaChatMessage;
29
- done?: boolean;
30
- prompt_eval_count?: number;
31
- eval_count?: number;
32
- };
33
- /** Tool spec in the `ollama` SDK's `chat({ tools })` wire shape. */
34
- export type TOllamaToolWire = {
35
- type: "function";
36
- function: {
37
- name: string;
38
- description: string;
39
- parameters: TOllamaJsonSchema;
40
- };
41
- };
42
- /** The `chat()` request body subset the provider builds. */
43
- export type TOllamaChatRequest = {
44
- model: string;
45
- messages: TOllamaChatMessage[];
46
- format?: string | object;
47
- /**
48
- * Toggle the model's thinking trace. Omitted → model default (ON for
49
- * reasoning models like qwen3). The provider sends this only when the
50
- * consumer configures `TOllamaProviderConfig.think`.
51
- */
52
- think?: boolean;
53
- tools?: TOllamaToolWire[];
54
- stream?: boolean;
55
- options?: {
56
- temperature?: number;
57
- num_predict?: number;
58
- num_ctx?: number;
59
- };
60
- };
61
- /**
62
- * The slice of the `ollama` SDK client surface the provider depends on:
63
- * a single `chat()` method and an `abort()` to honor `AbortSignal`.
64
- * Modeling it as a structural type (rather than importing `Ollama`)
65
- * keeps the optional peer out of the type graph and gives tests a clean
66
- * injection seam.
67
- */
68
- export type TOllamaClient = {
69
- chat(request: TOllamaChatRequest): Promise<TOllamaChatResponse | AsyncIterable<TOllamaChatResponse>>;
70
- abort(): void;
71
- };
72
- /**
73
- * The shape of the dynamically-imported `ollama` module. `Ollama` is
74
- * the SDK's exported class-constructor name (an external symbol), so it
75
- * is exempt from the in-repo camelCase property-naming rule. The SDK's
76
- * `Config` accepts an optional `fetch` override (used by the
77
- * per-provider raised-timeout dispatcher — see `./timeout-fetch.ts`).
78
- */
79
- export type TOllamaModule = {
80
- Ollama: new (config: {
81
- host: string;
82
- fetch?: typeof fetch;
83
- }) => TOllamaClient;
84
- };
85
- /**
86
- * Structural slice of the `undici` module the timeout-fetch helper uses.
87
- * Modeled (not imported) so the optional `undici` peer stays out of the
88
- * type graph — same pattern as {@link TOllamaModule} for the `ollama`
89
- * peer. The undici `Agent` constructor accepts millisecond timeout
90
- * options; we raise `headersTimeout` + `bodyTimeout` (and `connectTimeout`)
91
- * so a long local thinking-model generation isn't aborted at undici's
92
- * 300s default. `Agent` is undici's exported class-constructor name (an
93
- * external symbol), exempt from the camelCase rule.
94
- */
95
- export type TUndiciAgentOptions = {
96
- headersTimeout?: number;
97
- bodyTimeout?: number;
98
- connectTimeout?: number;
99
- };
100
- export type TUndiciDispatcher = object;
101
- export type TUndiciModule = {
102
- Agent: new (options: TUndiciAgentOptions) => TUndiciDispatcher;
103
- /**
104
- * undici's own `fetch`. The raised-timeout `Agent` MUST be passed as
105
- * a `dispatcher` to *this* fetch — the one from the same undici
106
- * module the `Agent` was constructed from. Node's bundled-undici
107
- * global `fetch` rejects a foreign-undici `Agent` dispatcher with
108
- * `UND_ERR_INVALID_ARG`, so the base fetch and the dispatcher must
109
- * come from the same undici instance. See `./timeout-fetch.ts`.
110
- */
111
- fetch: typeof fetch;
112
- };
113
- export type TOllamaProviderConfig = {
114
- /** Daemon base URL. Defaults to `http://localhost:11434`. */
115
- baseUrl?: string;
116
- /**
117
- * Pre-built SDK client. Primarily a test seam (inject a mock). When
118
- * omitted, the provider dynamically imports the `ollama` package and
119
- * constructs an `Ollama({ host: baseUrl })`; a missing package
120
- * surfaces as an actionable error at construction time.
121
- */
122
- client?: TOllamaClient;
123
- /**
124
- * Injectable `ollama`-module importer. Test seam — defaults to
125
- * `import("ollama")`. Lets tests assert the SDK client is constructed
126
- * with the per-provider timeout-fetch without touching the real
127
- * package. Ignored when `client` is provided.
128
- *
129
- * @internal
130
- */
131
- importOllama?: () => Promise<TOllamaModule>;
132
- /**
133
- * Injectable `undici`-module importer. Test seam — defaults to
134
- * `import("undici")`. See {@link requestTimeoutMs}.
135
- *
136
- * @internal
137
- */
138
- importUndici?: () => Promise<TUndiciModule>;
139
- /**
140
- * Per-request HTTP timeout in milliseconds, applied via a
141
- * **per-provider** undici `Agent` (raised `headersTimeout` +
142
- * `bodyTimeout`) passed as the `ollama` SDK client's `fetch`
143
- * dispatcher. Defaults to **1_200_000 (20 min)** — local thinking
144
- * models legitimately take many minutes per structured-extraction
145
- * stage, and undici's 300s default aborts them mid-generation with a
146
- * `UND_ERR_HEADERS_TIMEOUT` `fetch failed`.
147
- *
148
- * **No global state is mutated** — the raised timeout is scoped to
149
- * this provider's client only (never `setGlobalDispatcher`). Requires
150
- * the optional `undici` peer; if it is not installed the provider
151
- * falls back to the SDK's default fetch (300s) and relies on
152
- * `classifyOllamaError` retrying the resulting timeout as transient.
153
- *
154
- * Set `0` to disable the custom dispatcher entirely (use the SDK
155
- * default). A finite positive value is recommended.
156
- */
157
- requestTimeoutMs?: number;
158
- /**
159
- * Context-window size sent as Ollama's `options.num_ctx`. Defaults
160
- * to a generous **32768**.
161
- *
162
- * **Why this is set, and set generously.** Ollama's per-model
163
- * default `num_ctx` is small (often ~4096) and Ollama **silently
164
- * truncates** any prompt longer than `num_ctx` — no error is raised;
165
- * the model dutifully emits schema-valid JSON from a truncated
166
- * prompt, which then passes the framework's `Value.Check` and yields
167
- * a quietly-wrong parse. A real v2 ingestion prompt (segmenting a
168
- * multi-KB argument) easily exceeds 4096 tokens, so without a
169
- * generous default the stated goal — running the *whole* pipeline
170
- * locally on real text — would silently misbehave. Raise this
171
- * further for very large inputs; lower it only if VRAM-constrained
172
- * and inputs are known to be small.
173
- */
174
- numCtx?: number;
175
- /**
176
- * Stream the `chat()` generation and accumulate the chunks inside
177
- * the provider, returning a single synthesized response. Defaults
178
- * to **`true`** — streaming is the primary fix for the hardcoded
179
- * ~300s non-streaming Ollama timeout (ollama/ollama#5081): headers
180
- * and the first chunk arrive immediately and undici's `bodyTimeout`
181
- * resets per chunk, so a long local thinking-model generation is no
182
- * longer aborted mid-flight. Set `false` to restore the legacy
183
- * single one-shot (`stream: false`) request.
184
- */
185
- stream?: boolean;
186
- /**
187
- * Toggle Ollama's thinking trace (`think` on the chat request).
188
- *
189
- * **Opt-in.** When unset (the default) the provider sends no `think`
190
- * field and the model's own default applies (ON for reasoning models
191
- * like `qwen3.6:latest`, off for non-thinking models like `gemma2`).
192
- *
193
- * **There is no safe global default**, because on `qwen3.6:latest`
194
- * the thinking toggle's effect on structured-output fidelity is
195
- * stage-dependent and cuts both ways (verified empirically):
196
- *
197
- * - With `think: true`, some stages (e.g. claim-mention-extraction)
198
- * emit their entire answer in the thinking channel and return an
199
- * **empty `content`** — which the provider surfaces as a
200
- * deterministic {@link NonRetryableLlmError} (not a retry-burning
201
- * transient error) advising `think: false`.
202
- * - With `think: false`, other stages (e.g. segmentation) drop the
203
- * required object wrapper and return a **bare array**, failing the
204
- * downstream schema check. Ollama's `format` does NOT hard-enforce
205
- * the object envelope on this model.
206
- *
207
- * So set `think` per the stages a given provider instance serves, or
208
- * — simplest — run a non-thinking model (e.g. `gemma2:9b`) for the
209
- * whole ingestion pipeline, which sidesteps the toggle entirely.
210
- */
211
- think?: boolean;
212
- /**
213
- * Cap on function-tool agent-loop round-trips before throwing
214
- * `ToolLoopExhaustedError`. Defaults to 6, mirroring the OpenAI
215
- * provider. No ingestion stage uses tools, so this is secondary.
216
- */
217
- maxToolCallRounds?: number;
218
- };
219
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/extensions/ollama/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D;;;;;GAKG;AAEH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAA;QACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACrC,CAAA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7 +0,0 @@
1
- // Extension-internal types for the Ollama provider.
2
- //
3
- // Property names on the SDK request/response shapes are *wire* names
4
- // dictated by the Ollama HTTP API (snake_case); the in-repo brain-style
5
- // camelCase rule does not apply to external wire formats.
6
- export {};
7
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/extensions/ollama/types.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,qEAAqE;AACrE,wEAAwE;AACxE,0DAA0D"}