@proposit/proposit-core 1.9.0 → 1.11.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 (35) hide show
  1. package/dist/extensions/openai/errors.d.ts +23 -0
  2. package/dist/extensions/openai/errors.d.ts.map +1 -1
  3. package/dist/extensions/openai/errors.js +28 -0
  4. package/dist/extensions/openai/errors.js.map +1 -1
  5. package/dist/extensions/openai/index.d.ts +3 -3
  6. package/dist/extensions/openai/index.d.ts.map +1 -1
  7. package/dist/extensions/openai/index.js +4 -3
  8. package/dist/extensions/openai/index.js.map +1 -1
  9. package/dist/extensions/openai/provider.d.ts +167 -1
  10. package/dist/extensions/openai/provider.d.ts.map +1 -1
  11. package/dist/extensions/openai/provider.js +359 -17
  12. package/dist/extensions/openai/provider.js.map +1 -1
  13. package/dist/lib/index.d.ts +3 -3
  14. package/dist/lib/index.d.ts.map +1 -1
  15. package/dist/lib/index.js +1 -1
  16. package/dist/lib/index.js.map +1 -1
  17. package/dist/lib/llm/index.d.ts +1 -1
  18. package/dist/lib/llm/index.d.ts.map +1 -1
  19. package/dist/lib/llm/types.d.ts +55 -0
  20. package/dist/lib/llm/types.d.ts.map +1 -1
  21. package/dist/lib/pipelines/execute.d.ts +175 -3
  22. package/dist/lib/pipelines/execute.d.ts.map +1 -1
  23. package/dist/lib/pipelines/execute.js +574 -219
  24. package/dist/lib/pipelines/execute.js.map +1 -1
  25. package/dist/lib/pipelines/index.d.ts +2 -2
  26. package/dist/lib/pipelines/index.d.ts.map +1 -1
  27. package/dist/lib/pipelines/index.js +1 -1
  28. package/dist/lib/pipelines/index.js.map +1 -1
  29. package/dist/lib/pipelines/stage-helpers.d.ts +80 -1
  30. package/dist/lib/pipelines/stage-helpers.d.ts.map +1 -1
  31. package/dist/lib/pipelines/stage-helpers.js +247 -28
  32. package/dist/lib/pipelines/stage-helpers.js.map +1 -1
  33. package/dist/lib/pipelines/types.d.ts +25 -0
  34. package/dist/lib/pipelines/types.d.ts.map +1 -1
  35. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAK7E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AAG9E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAK9D,OAAO,EACH,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,GAC/B,MAAM,0CAA0C,CAAA;AAKjD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAEtE,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,GAC7B,MAAM,mBAAmB,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,cAAc,GAC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AAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAA"}
@@ -1,2 +1,2 @@
1
- export type { TLlmModel, TReasoningEffort, TToolSpec, TLlmRequest, TLlmResponse, TLlmProvider, TLlmTokenUsage, } from "./types.js";
1
+ export type { TLlmModel, TReasoningEffort, TToolSpec, TLlmRequest, TLlmResponse, TLlmProvider, TLlmTokenUsage, TResponseStatus, TRetrievedResponse, } from "./types.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/llm/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACR,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,GACjB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/llm/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACR,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,GACrB,MAAM,YAAY,CAAA"}
@@ -27,6 +27,21 @@ export type TLlmRequest<T> = {
27
27
  tools?: readonly TToolSpec[];
28
28
  maxOutputTokens?: number;
29
29
  signal?: AbortSignal;
30
+ /**
31
+ * Optional callback fired by a provider **as soon as the upstream
32
+ * response id is known — before the call resolves**. Lets a caller
33
+ * persist the id mid-flight so an interrupted in-flight call can be
34
+ * recovered from the upstream's stored copy.
35
+ *
36
+ * Only providers that can surface an id mid-flight invoke it (the
37
+ * OpenAI provider in background-stream mode, from the first
38
+ * `response.created` SSE event). Synchronous providers leave it
39
+ * uncalled and surface the id only at completion via
40
+ * {@link TLlmResponse.rawResponseId}. Optional + backward-compatible:
41
+ * callers that don't set it are unaffected. Invoked at most once per
42
+ * provider call (per attempt).
43
+ */
44
+ onResponseCreated?: (responseId: string) => void;
30
45
  /**
31
46
  * Phantom field that carries the structured-output type `T` from
32
47
  * `outputSchema` into the response. Always `undefined` at runtime.
@@ -46,4 +61,44 @@ export type TLlmResponse<T> = {
46
61
  export type TLlmProvider = {
47
62
  respond<T>(req: TLlmRequest<T>): Promise<TLlmResponse<T>>;
48
63
  };
64
+ /**
65
+ * Lifecycle status of a stored/background LLM response. `completed` /
66
+ * `failed` / `incomplete` / `cancelled` are terminal; `queued` /
67
+ * `in_progress` are transient.
68
+ *
69
+ * This is the framework-side mirror of the concrete provider's status
70
+ * union (the OpenAI extension exports a structurally-identical
71
+ * `TResponseStatus`). It lives here, in the SDK-free layer, so the
72
+ * pipeline's launch/complete entry points can reference a response
73
+ * status by its function/value type without importing the OpenAI
74
+ * extension — keeping `src/lib/` free of third-party SDK imports.
75
+ */
76
+ export type TResponseStatus = "queued" | "in_progress" | "completed" | "failed" | "incomplete" | "cancelled";
77
+ /**
78
+ * Framework-side structural mirror of a retrieved background-response
79
+ * shape, consumed by `completeStage`. The OpenAI extension's
80
+ * `retrieveResponse` returns a structurally-compatible object (it
81
+ * carries every field below), so a consumer can pass its result
82
+ * straight into `completeStage` — without `src/lib/` importing the
83
+ * extension type. `output` is the **raw assistant text** (not a parsed
84
+ * object); `completeStage` parses it against the stage's schema.
85
+ */
86
+ export type TRetrievedResponse = {
87
+ /** Current status of the stored response. */
88
+ status: TResponseStatus;
89
+ /** Raw assistant text output, present when `status === "completed"`. */
90
+ output?: string;
91
+ /** Token usage reported by the provider, when available. */
92
+ tokenUsage?: TLlmTokenUsage;
93
+ /** The provider response id that was retrieved. */
94
+ rawResponseId: string;
95
+ /**
96
+ * The provider's `incomplete_details.reason`, present when
97
+ * `status === "incomplete"` (e.g. `max_output_tokens`,
98
+ * `content_filter`). Drives `completeStage`'s classification.
99
+ */
100
+ incompleteReason?: string;
101
+ /** The provider's error message, present when `status === "failed"`. */
102
+ errorMessage?: string;
103
+ };
49
104
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","source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zB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA"}
@@ -1,5 +1,6 @@
1
- import type { TPipeline, TPipelineEvent, TPipelineResult } from "./types.js";
2
- import type { TLlmProvider } from "../llm/types.js";
1
+ import type { TPipeline, TPipelineEvent, TPipelineResult, TProcessingFailure, TStageStatus } from "./types.js";
2
+ import type { TRetryReason } from "./stage-helpers.js";
3
+ import type { TLlmProvider, TLlmRequest, TLlmTokenUsage, TResponseStatus, TRetrievedResponse } from "../llm/types.js";
3
4
  export type TExecutePipelineDeps = {
4
5
  llm: TLlmProvider;
5
6
  generateId?: () => string;
@@ -9,7 +10,7 @@ export type TExecutePipelineDeps = {
9
10
  concurrencyLimit?: number;
10
11
  };
11
12
  export declare class PipelineConfigurationError extends Error {
12
- readonly code: "DAG_CYCLE" | "SELF_DEP" | "UNKNOWN_DEP" | "DUPLICATE_STAGE_ID" | "GET_OUTSIDE_DEPS" | "STATUS_OUTSIDE_DEPS";
13
+ readonly code: "DAG_CYCLE" | "SELF_DEP" | "UNKNOWN_DEP" | "UNKNOWN_STAGE" | "DUPLICATE_STAGE_ID" | "GET_OUTSIDE_DEPS" | "STATUS_OUTSIDE_DEPS";
13
14
  readonly stageId?: string;
14
15
  readonly depId?: string;
15
16
  constructor(args: {
@@ -20,4 +21,175 @@ export declare class PipelineConfigurationError extends Error {
20
21
  });
21
22
  }
22
23
  export declare function executePipeline<TInput, TOutput>(pipeline: TPipeline<TInput, TOutput>, input: TInput, deps: TExecutePipelineDeps): Promise<TPipelineResult<TOutput>>;
24
+ /**
25
+ * The rehydration unit for one upstream stage. Carries both the outcome
26
+ * AND the output so a single-stage run reproduces the monolithic run's
27
+ * semantics exactly: `ctx.get(stageId)` returns the output only for a
28
+ * `completed` upstream, and `ctx.stageStatus(stageId)` returns the
29
+ * outcome. The serialized form of one stage is `{ outcome, output? }`
30
+ * where `output` is the value the stage's `outputSchema` accepts (JSON
31
+ * round-trippable) and is present iff `outcome === "completed"`.
32
+ */
33
+ export type TStageOutcomeRecord = {
34
+ outcome: TStageStatus;
35
+ /**
36
+ * The stage's validated output. Present only for
37
+ * `outcome === "completed"` — `executeStage` / `executeFinalize`
38
+ * defensively drop it for `skipped` / `failed` records, so a stale
39
+ * persisted output can never leak into a non-completed dependency.
40
+ */
41
+ output?: unknown;
42
+ };
43
+ /**
44
+ * Dependencies for a single-stage / single-finalize / launch / complete
45
+ * run. A subset of `TExecutePipelineDeps`: no `concurrencyLimit` (one unit
46
+ * runs at a time) and no run-level bookends.
47
+ */
48
+ export type TExecuteStageDeps = {
49
+ llm: TLlmProvider;
50
+ generateId?: () => string;
51
+ signal?: AbortSignal;
52
+ onEvent?: (event: TPipelineEvent) => void;
53
+ /**
54
+ * Submit-only background-response capability — required by
55
+ * `launchStage`, ignored by `executeStage` / `executeFinalize` /
56
+ * `completeStage`. Referenced by **function type only** so `src/lib/`
57
+ * takes no OpenAI-extension import (the zero-SDK-import boundary
58
+ * holds); the consumer supplies the concrete
59
+ * `extensions/openai`#`submitBackgroundResponse` (apiKey-bound). It
60
+ * submits a background response and resolves with `{ responseId,
61
+ * status }` WITHOUT awaiting completion.
62
+ */
63
+ submitBackgroundResponse?: (req: TLlmRequest<unknown>, opts: {
64
+ apiKey: string;
65
+ baseUrl?: string;
66
+ signal?: AbortSignal;
67
+ }) => Promise<{
68
+ responseId: string;
69
+ status: TResponseStatus;
70
+ }>;
71
+ };
72
+ /**
73
+ * The result of running one stage via `executeStage` (run-to-completion)
74
+ * or `completeStage` (the completion side of the launch/complete split).
75
+ */
76
+ export type TExecuteStageResult = {
77
+ /** The stage's own outcome after this single execution. */
78
+ outcome: TStageStatus;
79
+ /** The validated output when `outcome === "completed"`; else undefined. */
80
+ output?: unknown;
81
+ /** Any ProcessingFailure(s) the stage produced. */
82
+ failures: TProcessingFailure[];
83
+ /** Per-stage token usage, when the stage made an LLM call. */
84
+ tokenUsage?: TLlmTokenUsage;
85
+ /**
86
+ * The retry CLASSIFICATION when a `completeStage` result is `failed`
87
+ * for a RETRYABLE reason — a reason code, not a bare boolean, so a
88
+ * durable orchestrator can apply the same `retryOn` + bounded-attempt
89
+ * decision core would. Absent when `completed`, when the failure is
90
+ * non-retryable / fail-fast (`failed` envelope, `content_filter`), or
91
+ * when the outcome is `skipped` (a cancelled response). **Run-to-
92
+ * completion `executeStage` never sets this** (it owns its own retry
93
+ * loop); only `completeStage` does.
94
+ */
95
+ retryReason?: TRetryReason;
96
+ };
97
+ /**
98
+ * The result of `launchStage`: the submitted background response's id +
99
+ * its submit-time status. The caller persists `responseId` and builds the
100
+ * durable hook token before suspending; `status` may already be terminal
101
+ * on a small/cached submit (the caller then proceeds straight to
102
+ * `completeStage` via `retrieveResponse`).
103
+ */
104
+ export type TLaunchStageResult = {
105
+ responseId: string;
106
+ status: TResponseStatus;
107
+ };
108
+ /** The result of running the finalize via `executeFinalize`. */
109
+ export type TExecuteFinalizeResult<TOutput> = {
110
+ /**
111
+ * The pipeline output finalize produced; `null` when a required
112
+ * finalize dep was not `completed` (the same gate `executePipeline`
113
+ * applies) or when finalize itself threw (a `FINALIZE_UNCAUGHT_ERROR`
114
+ * failure).
115
+ */
116
+ output: TOutput | null;
117
+ failures: TProcessingFailure[];
118
+ };
119
+ /**
120
+ * Run a single stage of `pipeline` against the caller-supplied upstream
121
+ * records, without re-running the whole DAG. The upstream map carries
122
+ * each dependency's `{ outcome, output? }` so `ctx.get` / `ctx.stageStatus`
123
+ * reproduce monolithic-run semantics exactly. `input` is validated +
124
+ * transformed via `Value.Parse(pipeline.inputSchema, input)` (a schema
125
+ * mismatch throws, same as `executePipeline`) and the PARSED value seeds
126
+ * `ctx.input`.
127
+ *
128
+ * Emits the per-stage events only (`stage:start`, `stage:llm-request`,
129
+ * `stage:llm-response-created`, `stage:llm-call`, `stage:retry`,
130
+ * `stage:end`) — no `pipeline:*` bookends. Throws `PipelineConfigurationError`
131
+ * (`UNKNOWN_STAGE`) when `stageId` is not in `pipeline.stages`, and throws a
132
+ * `PipelineConfigurationError` (`GET_OUTSIDE_DEPS` / `STATUS_OUTSIDE_DEPS`)
133
+ * out directly when the stage reads a non-dependency — both are caller
134
+ * bugs, surfaced rather than swallowed into the result.
135
+ *
136
+ * The caller may pass a superset of `upstream` records; `executeStage`
137
+ * uses the stage's own `dependsOn` to pick the relevant ones. It does NOT
138
+ * decide whether the stage SHOULD run given its upstream outcomes — a
139
+ * required-failed upstream just means `ctx.get` returns `undefined`; the
140
+ * skip decision belongs to the caller's scheduler.
141
+ */
142
+ export declare function executeStage(pipeline: TPipeline<unknown, unknown>, stageId: string, upstream: Readonly<Record<string, TStageOutcomeRecord>>, input: unknown, deps: TExecuteStageDeps): Promise<TExecuteStageResult>;
143
+ /**
144
+ * Run `pipeline.finalize` against the caller-supplied upstream records,
145
+ * without re-running the whole DAG. Symmetric with `executeStage`:
146
+ * `input` is parsed via `Value.Parse(pipeline.inputSchema, input)` and the
147
+ * PARSED value seeds the finalize `ctx.input`; the finalize `ctx` is built
148
+ * with `pipeline.finalize.dependsOn` as its allowed-dep set; the
149
+ * required-finalize-dep gate (`output` stays `null` if any required dep is
150
+ * not `completed`) and the `FINALIZE_UNCAUGHT_ERROR` capture match
151
+ * `executePipeline`.
152
+ *
153
+ * Emits NO events (finalize is not a stage — it has no `stage:*`
154
+ * lifecycle — and there are no `pipeline:*` bookends). `async` purely for
155
+ * signature symmetry with `executeStage`; `TPipelineFinalize.run` stays
156
+ * synchronous and the `async` wrapper just resolves its result.
157
+ */
158
+ export declare function executeFinalize<TOutput>(pipeline: TPipeline<unknown, TOutput>, upstream: Readonly<Record<string, TStageOutcomeRecord>>, input: unknown, deps: TExecuteStageDeps): Promise<TExecuteFinalizeResult<TOutput>>;
159
+ /**
160
+ * Launch an LLM-background stage: rehydrate `ctx` from `upstream` +
161
+ * parsed input, build the request via the shared seam, submit it via the
162
+ * injected `deps.submitBackgroundResponse`, and return
163
+ * `{ responseId, status }` WITHOUT awaiting completion.
164
+ *
165
+ * Emits `stage:start`, `stage:llm-request`, and `stage:llm-response-created`
166
+ * (from the submit's returned id) — but NO `stage:llm-call` / `stage:end`
167
+ * (the completion side emits those, in a later invocation). The
168
+ * per-stage event pair therefore spans two invocations; an `onEvent`
169
+ * consumer must NOT assume a balanced start↔end per call.
170
+ *
171
+ * `deps.submitBackgroundResponse` is REQUIRED; `launchStage` throws if it
172
+ * is absent. `stageId` must name an LLM stage (built by `llmStage`);
173
+ * a non-LLM stage throws. `attempt` (default 1) lets a re-launch rebuild
174
+ * the retry-suffixed user message for attempt 2+.
175
+ */
176
+ export declare function launchStage(pipeline: TPipeline<unknown, unknown>, stageId: string, upstream: Readonly<Record<string, TStageOutcomeRecord>>, input: unknown, deps: TExecuteStageDeps, attempt?: number): Promise<TLaunchStageResult>;
177
+ /**
178
+ * Complete an LLM-background stage from its retrieved response. Recovers
179
+ * the stage's LLM config, parses the RAW assistant text in
180
+ * `retrieved.output` against the stage's schema (via the shared seam),
181
+ * classifies a non-`completed` status per the launch/complete table, and
182
+ * returns the standard `TExecuteStageResult`.
183
+ *
184
+ * Emits `stage:llm-call` + `stage:end` (NO `stage:start` — that fired in
185
+ * the launch invocation). `tokenUsage` is taken directly from
186
+ * `retrieved.tokenUsage` (the per-`ctx` WeakMap cannot bridge the two
187
+ * invocations). On a RETRYABLE failure the result carries `retryReason`
188
+ * (the reason code); a fail-fast failure (`failed` envelope,
189
+ * `content_filter`) carries none; a `cancelled` response settles as
190
+ * `outcome: "skipped"` with no `ProcessingFailure`.
191
+ *
192
+ * `stageId` must name an LLM stage; a non-LLM stage throws.
193
+ */
194
+ export declare function completeStage(pipeline: TPipeline<unknown, unknown>, stageId: string, retrieved: TRetrievedResponse, deps: TExecuteStageDeps, attempt?: number): Promise<TExecuteStageResult>;
23
195
  //# sourceMappingURL=execute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/lib/pipelines/execute.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAER,S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