@owlmeans/llm-common 0.1.18-rc.9 → 0.1.18
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 +2 -2
- package/agent-meta/manifest.json +3 -3
- package/agent-meta/skills/llm-common/SKILL.md +64 -12
- package/build/consts.d.ts +107 -7
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +125 -5
- package/build/consts.js.map +1 -1
- package/build/delegate/consts.d.ts +25 -0
- package/build/delegate/consts.d.ts.map +1 -0
- package/build/delegate/consts.js +28 -0
- package/build/delegate/consts.js.map +1 -0
- package/build/delegate/index.d.ts +3 -0
- package/build/delegate/index.d.ts.map +1 -0
- package/build/delegate/index.js +3 -0
- package/build/delegate/index.js.map +1 -0
- package/build/delegate/types.d.ts +85 -0
- package/build/delegate/types.d.ts.map +1 -0
- package/build/delegate/types.js +13 -0
- package/build/delegate/types.js.map +1 -0
- package/build/files/types.d.ts +10 -0
- package/build/files/types.d.ts.map +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build/inquiry/consts.d.ts +48 -0
- package/build/inquiry/consts.d.ts.map +1 -0
- package/build/inquiry/consts.js +50 -0
- package/build/inquiry/consts.js.map +1 -0
- package/build/inquiry/helper/types.d.ts +47 -0
- package/build/inquiry/helper/types.d.ts.map +1 -0
- package/build/inquiry/helper/types.js +2 -0
- package/build/inquiry/helper/types.js.map +1 -0
- package/build/inquiry/helper.d.ts +4 -0
- package/build/inquiry/helper.d.ts.map +1 -0
- package/build/inquiry/helper.js +39 -0
- package/build/inquiry/helper.js.map +1 -0
- package/build/inquiry/index.d.ts +6 -0
- package/build/inquiry/index.d.ts.map +1 -0
- package/build/inquiry/index.js +4 -0
- package/build/inquiry/index.js.map +1 -0
- package/build/inquiry/types.d.ts +72 -0
- package/build/inquiry/types.d.ts.map +1 -0
- package/build/inquiry/types.js +2 -0
- package/build/inquiry/types.js.map +1 -0
- package/build/inquiry/utils.d.ts +14 -0
- package/build/inquiry/utils.d.ts.map +1 -0
- package/build/inquiry/utils.js +14 -0
- package/build/inquiry/utils.js.map +1 -0
- package/build/results/consts.d.ts +19 -0
- package/build/results/consts.d.ts.map +1 -0
- package/build/results/consts.js +30 -0
- package/build/results/consts.js.map +1 -0
- package/build/results/consts.local.d.ts +3 -0
- package/build/results/consts.local.d.ts.map +1 -0
- package/build/results/consts.local.js +3 -0
- package/build/results/consts.local.js.map +1 -0
- package/build/results/index.d.ts +4 -0
- package/build/results/index.d.ts.map +1 -0
- package/build/results/index.js +3 -0
- package/build/results/index.js.map +1 -0
- package/build/results/types.d.ts +37 -0
- package/build/results/types.d.ts.map +1 -0
- package/build/results/types.js +2 -0
- package/build/results/types.js.map +1 -0
- package/build/results/utils.d.ts +11 -0
- package/build/results/utils.d.ts.map +1 -0
- package/build/results/utils.js +27 -0
- package/build/results/utils.js.map +1 -0
- package/build/spectator/types.d.ts +6 -0
- package/build/spectator/types.d.ts.map +1 -1
- package/build/types.d.ts +99 -7
- package/build/types.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/consts.ts +129 -5
- package/src/delegate/consts.ts +26 -0
- package/src/delegate/index.ts +2 -0
- package/src/delegate/types.ts +91 -0
- package/src/files/types.ts +11 -0
- package/src/index.ts +3 -0
- package/src/inquiry/consts.ts +52 -0
- package/src/inquiry/helper/types.ts +47 -0
- package/src/inquiry/helper.ts +53 -0
- package/src/inquiry/index.ts +5 -0
- package/src/inquiry/types.ts +77 -0
- package/src/inquiry/utils.ts +20 -0
- package/src/results/consts.local.ts +2 -0
- package/src/results/consts.ts +32 -0
- package/src/results/index.ts +3 -0
- package/src/results/types.ts +37 -0
- package/src/results/utils.ts +34 -0
- package/src/spectator/types.ts +6 -0
- package/src/types.ts +101 -7
- package/tests/inquiry.spec.ts +111 -0
- package/tests/results.spec.ts +81 -0
- package/tsconfig.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/results/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/results/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAE3B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One producing step's contribution to a {@link CumulativeResults} view, already rendered.
|
|
3
|
+
*
|
|
4
|
+
* `step` names the step that produced it — for a step of a pipeline composed under another, the
|
|
5
|
+
* composing path as well (`design/screens`) — so two pipelines' steps of the same name never read
|
|
6
|
+
* as one.
|
|
7
|
+
*/
|
|
8
|
+
export interface CumulativeResultsSection {
|
|
9
|
+
step: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What the earlier steps of a pipeline produced, cut for ONE later step.
|
|
14
|
+
*
|
|
15
|
+
* Serializable and immutable: it travels on `ExecutionState.results`, so it survives a snapshot and
|
|
16
|
+
* a restore, and a resumed run composes the same prompt the interrupted one did. Everything in it is
|
|
17
|
+
* already rendered — the view is cut by the pipeline runtime, where the budgets are known, and the
|
|
18
|
+
* prompt layer only places it.
|
|
19
|
+
*/
|
|
20
|
+
export interface CumulativeResults {
|
|
21
|
+
/** The step this view was cut for. */
|
|
22
|
+
step: string;
|
|
23
|
+
/** Oldest first. Each is one producing step, rendered in full or as names only. */
|
|
24
|
+
sections: CumulativeResultsSection[];
|
|
25
|
+
/** Steps whose results exist but were left out of this view to stay inside its budget. */
|
|
26
|
+
omitted: string[];
|
|
27
|
+
/** Characters of the sections as rendered, separators included. */
|
|
28
|
+
chars: number;
|
|
29
|
+
/**
|
|
30
|
+
* A digest of the sections — for a trace line or a debugger, to tell two views apart.
|
|
31
|
+
*
|
|
32
|
+
* NEVER rendered into a prompt: it is exactly the kind of varying, meaningless byte a model would
|
|
33
|
+
* copy into its answer or treat as an instruction.
|
|
34
|
+
*/
|
|
35
|
+
digest: string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/results/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,mFAAmF;IACnF,QAAQ,EAAE,wBAAwB,EAAE,CAAA;IACpC,0FAA0F;IAC1F,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/results/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CumulativeResults } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A {@link CumulativeResults} view as prompt text, or `''` when there is nothing to say.
|
|
4
|
+
*
|
|
5
|
+
* Pure and total: the same view renders to the same bytes on every runtime, and an absent or empty
|
|
6
|
+
* view renders to NOTHING — not a heading over an empty list, which a model would read as "no
|
|
7
|
+
* earlier step produced anything" and act on. The view's digest is never rendered; its sections are
|
|
8
|
+
* placed in the order the view holds them, which is oldest first.
|
|
9
|
+
*/
|
|
10
|
+
export declare const renderCumulativeResults: (view: CumulativeResults | null | undefined) => string;
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/results/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGnD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,SAAU,iBAAiB,GAAG,IAAI,GAAG,SAAS,KAAG,MAmBpF,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CUMULATIVE_RESULTS_OMITTED_LEAD, CUMULATIVE_RESULTS_OMITTED_TAIL, CUMULATIVE_RESULTS_PREAMBLE, } from './consts.js';
|
|
2
|
+
import { SEPARATOR } from './consts.local.js';
|
|
3
|
+
/**
|
|
4
|
+
* A {@link CumulativeResults} view as prompt text, or `''` when there is nothing to say.
|
|
5
|
+
*
|
|
6
|
+
* Pure and total: the same view renders to the same bytes on every runtime, and an absent or empty
|
|
7
|
+
* view renders to NOTHING — not a heading over an empty list, which a model would read as "no
|
|
8
|
+
* earlier step produced anything" and act on. The view's digest is never rendered; its sections are
|
|
9
|
+
* placed in the order the view holds them, which is oldest first.
|
|
10
|
+
*/
|
|
11
|
+
export const renderCumulativeResults = (view) => {
|
|
12
|
+
if (view == null) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
const sections = view.sections.map(section => section.text.trim()).filter(text => text !== '');
|
|
16
|
+
const omitted = view.omitted.filter(step => step.trim() !== '');
|
|
17
|
+
if (sections.length === 0 && omitted.length === 0) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
const parts = [CUMULATIVE_RESULTS_PREAMBLE, ...sections];
|
|
21
|
+
if (omitted.length > 0) {
|
|
22
|
+
parts.push(`${CUMULATIVE_RESULTS_OMITTED_LEAD} ${omitted.map(step => `\`${step}\``).join(', ')}. `
|
|
23
|
+
+ CUMULATIVE_RESULTS_OMITTED_TAIL);
|
|
24
|
+
}
|
|
25
|
+
return parts.join(SEPARATOR);
|
|
26
|
+
};
|
|
27
|
+
//# s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C,CAAA;AAC9B,CAAC,CAAA"}
|
|
@@ -8,6 +8,12 @@ export interface SpectatorArgument {
|
|
|
8
8
|
tries?: number;
|
|
9
9
|
messages: SpectatorEntryMessage[];
|
|
10
10
|
startedAt?: number;
|
|
11
|
+
/**
|
|
12
|
+
* The model that ANSWERED — the active rung's own model id, which differs from the role's
|
|
13
|
+
* primary once a fallback took over. Absent when the caller could not tell; a sink then falls
|
|
14
|
+
* back to its own resolution.
|
|
15
|
+
*/
|
|
16
|
+
model?: string;
|
|
11
17
|
}
|
|
12
18
|
/** A stored spectator record — the argument plus the resolved call context. */
|
|
13
19
|
export interface SpectatorEntry extends SpectatorArgument {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/spectator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,qBAAqB,EAAE,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/spectator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,qBAAqB,EAAE,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,sEAAsE;AACtE,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,EAAE,EAAE,MAAM,CAAA;CACX;AAED,mEAAmE;AACnE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,oBAAoB,CAAA;IACjC,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb"}
|
package/build/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { ExecutionEffort, ExecutionLevel, PromptBlock } from './consts.js';
|
|
1
|
+
import type { ExecutionEffort, ExecutionLevel, ModelEffort, PackagePurpose, PromptBlock } from './consts.js';
|
|
2
|
+
import type { InquiryConfig } from './inquiry/types.js';
|
|
3
|
+
import type { CumulativeResults } from './results/types.js';
|
|
2
4
|
/**
|
|
3
5
|
* Free-form observability metadata attached to every model call — forwarded to the
|
|
4
6
|
* inference provider as run metadata and recorded on every spectator entry. Kept
|
|
@@ -29,6 +31,8 @@ export interface ModelConfigPatch {
|
|
|
29
31
|
maxTokensCap?: number;
|
|
30
32
|
topP?: number;
|
|
31
33
|
disableThinking?: boolean;
|
|
34
|
+
/** Provider-native effort; clamped to what the model accepts, dropped where it accepts none. */
|
|
35
|
+
effort?: ModelEffort;
|
|
32
36
|
/** Total window the model accepts (input + output). Informational / validation only. */
|
|
33
37
|
contextWindow?: number;
|
|
34
38
|
/** What the PROVIDER can emit in one request. Hard ceiling for `maxTokens`/`maxTokensCap`. */
|
|
@@ -50,6 +54,12 @@ export interface ModelPolicy {
|
|
|
50
54
|
roleOverrides?: Partial<Record<ModelRole, ModelRole>>;
|
|
51
55
|
/** "Pin a role to a specific model/config" — alias or partial config override. */
|
|
52
56
|
modelOverrides?: Partial<Record<ModelRole, ModelConfigOverride>>;
|
|
57
|
+
/**
|
|
58
|
+
* Role resolved by `ExecutionService.utility` for cheap side calls. Defaults to
|
|
59
|
+
* `UTILITY_ROLE`; name another alias when the deployment calls its cheap tier
|
|
60
|
+
* something else. `roleOverrides` still applies on top of whichever one is used.
|
|
61
|
+
*/
|
|
62
|
+
utilityRole?: ModelRole;
|
|
53
63
|
}
|
|
54
64
|
/**
|
|
55
65
|
* Lifetime of a provider-side prompt cache entry. `'1h'` costs roughly twice as much to
|
|
@@ -57,6 +67,46 @@ export interface ModelPolicy {
|
|
|
57
67
|
* prefix that survives a long run, not for a one-shot call.
|
|
58
68
|
*/
|
|
59
69
|
export type CacheTtl = '5m' | '1h';
|
|
70
|
+
/**
|
|
71
|
+
* A cache lifetime per breakpoint of the prompt layout, earliest first. An omitted key keeps the
|
|
72
|
+
* level below it (the service default, then `'5m'`). Whatever is asked, the lifetimes never RISE
|
|
73
|
+
* along the prefix — a provider refuses a longer-lived entry after a shorter-lived one — so a
|
|
74
|
+
* `'1h'` behind a `'5m'` is clamped to `'5m'`.
|
|
75
|
+
*/
|
|
76
|
+
export interface CacheTtlPolicy {
|
|
77
|
+
/** The role + skills breakpoint — stable for a persona. */
|
|
78
|
+
skills?: CacheTtl;
|
|
79
|
+
/** The packages breakpoint — stable for a persona working on one story. */
|
|
80
|
+
packages?: CacheTtl;
|
|
81
|
+
/** The project message's breakpoint — stable for one step of the work. */
|
|
82
|
+
project?: CacheTtl;
|
|
83
|
+
/** The breakpoint after the caller's `stable` lead messages — stable for one batch of calls. */
|
|
84
|
+
stable?: CacheTtl;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Which package documentation a persona works with, chosen ONCE per persona and story rather than
|
|
88
|
+
* detected from each message — so the packages block stays byte-identical for every call of that
|
|
89
|
+
* work. Present, it switches the package plugin from detection to selection; absent, packages are
|
|
90
|
+
* detected from the messages as before.
|
|
91
|
+
*
|
|
92
|
+
* Arrays merge down the execution chain as a first-seen union; the plugin sorts what it renders.
|
|
93
|
+
*/
|
|
94
|
+
export interface PromptFocus {
|
|
95
|
+
/** The `@owlmeans/*` packages whose documentation belongs in the cached packages block. */
|
|
96
|
+
packages?: string[];
|
|
97
|
+
/** Which parts of those packages to load, by what they are for. */
|
|
98
|
+
purposes?: PackagePurpose[];
|
|
99
|
+
/** Parts named outright, as `<package>#<part>` (`@owlmeans/web-panel#picker`). */
|
|
100
|
+
parts?: string[];
|
|
101
|
+
/** Domain types whose definitions belong in the project message. */
|
|
102
|
+
types?: string[];
|
|
103
|
+
/**
|
|
104
|
+
* Whether a package a call's messages IMPORT but the focus lacks is still loaded, into the
|
|
105
|
+
* uncached tail (cores only, capped). Defaults to `true`; `false` keeps the prompt to the focus.
|
|
106
|
+
* The deepest level that sets it wins.
|
|
107
|
+
*/
|
|
108
|
+
late?: boolean;
|
|
109
|
+
}
|
|
60
110
|
/**
|
|
61
111
|
* One named, reusable chunk of system-prompt knowledge — a capability the model is told
|
|
62
112
|
* it has. Registered once (by the package that owns the knowledge or by the final app)
|
|
@@ -94,10 +144,15 @@ export interface PromptPolicy {
|
|
|
94
144
|
role?: string;
|
|
95
145
|
/** Skill aliases enabled at this level. */
|
|
96
146
|
skills?: string[];
|
|
97
|
-
/** Mark the composed system
|
|
147
|
+
/** Mark the composed prompt cacheable (system and project message). Defaults to `true`. */
|
|
98
148
|
cacheSystem?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Cache lifetimes: one for every breakpoint, or one per breakpoint. Defaults to `'5m'`
|
|
151
|
+
* everywhere; `'1h'` is opt-in and never rises along the prefix (see {@link CacheTtlPolicy}).
|
|
152
|
+
*/
|
|
153
|
+
cacheTtl?: CacheTtl | CacheTtlPolicy;
|
|
154
|
+
/** Which package documentation and types this work uses — see {@link PromptFocus}. */
|
|
155
|
+
focus?: PromptFocus;
|
|
101
156
|
}
|
|
102
157
|
/**
|
|
103
158
|
* Prompt-cache accounting for a single call, normalized across providers. The only
|
|
@@ -107,8 +162,13 @@ export interface PromptPolicy {
|
|
|
107
162
|
export interface CacheUsage {
|
|
108
163
|
/** Tokens served from cache (~0.1x price). */
|
|
109
164
|
read: number;
|
|
110
|
-
/** Tokens written to cache (~1.25x price at 5m TTL, ~2x at 1h). */
|
|
165
|
+
/** Tokens written to cache (~1.25x price at 5m TTL, ~2x at 1h) — both lifetimes together. */
|
|
111
166
|
creation: number;
|
|
167
|
+
/**
|
|
168
|
+
* Of {@link creation}, the tokens written at the 1-hour TTL. Present only when the provider
|
|
169
|
+
* reported a non-zero 1-hour write.
|
|
170
|
+
*/
|
|
171
|
+
creationLong?: number;
|
|
112
172
|
/** Tokens processed at full price. */
|
|
113
173
|
input: number;
|
|
114
174
|
output: number;
|
|
@@ -125,10 +185,32 @@ export interface ExecutionState {
|
|
|
125
185
|
policy: ModelPolicy;
|
|
126
186
|
/** Role + skills for this level; merged downward by `ExecutionService`. */
|
|
127
187
|
prompt?: PromptPolicy;
|
|
188
|
+
/**
|
|
189
|
+
* How this run may put a question to a person. Serializable, and deliberately NOT a
|
|
190
|
+
* collaborator: a run that is resumed days later must ask through the same channel, under the
|
|
191
|
+
* same policy, as the one that parked it.
|
|
192
|
+
*/
|
|
193
|
+
inquiry?: InquiryConfig;
|
|
194
|
+
/**
|
|
195
|
+
* What the earlier steps of the pipeline this execution works inside produced, cut for the step
|
|
196
|
+
* at hand. Rendered into `PromptBlock.Results` by the prompt service.
|
|
197
|
+
*
|
|
198
|
+
* State, not a collaborator: it is plain rendered text, and a resumed run must compose the
|
|
199
|
+
* prompt the interrupted one did. Inherited by every refinement like any other state field, and
|
|
200
|
+
* replaced — never merged — when a later step is handed its own view.
|
|
201
|
+
*/
|
|
202
|
+
results?: CumulativeResults;
|
|
128
203
|
}
|
|
129
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* The task level's own fields.
|
|
206
|
+
*
|
|
207
|
+
* `phase`, `completed` and `cursor` are LABELS — for a trace line, a prompt, a log — and never a
|
|
208
|
+
* workflow position. Recoverable position lives on a pipeline run row (`@owlmeans/agent`), which is
|
|
209
|
+
* a single authority; an execution that also claimed to know where a run stood would be a second
|
|
210
|
+
* one, and the two would disagree the first time a step wrote only one of them.
|
|
211
|
+
*/
|
|
130
212
|
export interface TaskExecutionState extends ExecutionState {
|
|
131
|
-
/**
|
|
213
|
+
/** A label for the stage a task considers itself in. Never read back to decide anything. */
|
|
132
214
|
phase?: string;
|
|
133
215
|
completed?: string[];
|
|
134
216
|
cursor?: string;
|
|
@@ -167,7 +249,10 @@ export interface NullCapture {
|
|
|
167
249
|
toolName: string;
|
|
168
250
|
innerSchema: unknown;
|
|
169
251
|
};
|
|
252
|
+
/** Whether the prepared request carried at least one cache breakpoint. */
|
|
170
253
|
useCache: boolean;
|
|
254
|
+
/** How many lead messages the caller declared stable across calls (`LlmCallOptions.stable`). */
|
|
255
|
+
stable?: number;
|
|
171
256
|
};
|
|
172
257
|
response: {
|
|
173
258
|
content: unknown;
|
|
@@ -177,11 +262,18 @@ export interface NullCapture {
|
|
|
177
262
|
tool_calls?: unknown;
|
|
178
263
|
} | null;
|
|
179
264
|
diagnostics: {
|
|
265
|
+
/** Whatever the provider called it — OpenAI's `finish_reason` or Anthropic's `stop_reason`. */
|
|
180
266
|
finishReason?: string;
|
|
181
267
|
inputTokens?: number;
|
|
182
268
|
outputTokens?: number;
|
|
183
269
|
reasoningTokens?: number;
|
|
184
270
|
contentEmpty: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Content arrived, but none of it was text — the shape of an answer that was all reasoning.
|
|
273
|
+
* Distinguishes "spent the budget thinking" from "returned nothing at all", which
|
|
274
|
+
* `contentEmpty` alone cannot.
|
|
275
|
+
*/
|
|
276
|
+
thinkingOnly?: boolean;
|
|
185
277
|
hadToolCall: boolean;
|
|
186
278
|
};
|
|
187
279
|
}
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC5G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,eAAe,CAAC,EAAE,OAAO,CA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,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO,CAAA;QAChB,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,GAAG,IAAI,CAAA;IACR,WAAW,EAAE;QACX,+FAA+F;QAC/F,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,YAAY,EAAE,OAAO,CAAA;QACrB;;;;WAIG;QACH,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,WAAW,EAAE,OAAO,CAAA;KACrB,CAAA;CACF"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/llm-common",
|
|
3
|
-
"version": "0.1.18
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc -b",
|
|
8
8
|
"dev": "sleep 171 && nodemon -e ts,tsx,json --watch src --exec \"tsc -p ./tsconfig.json\"",
|
|
9
|
-
"watch": "tsc -b -w --preserveWatchOutput --pretty"
|
|
9
|
+
"watch": "tsc -b -w --preserveWatchOutput --pretty",
|
|
10
|
+
"test": "bun test ./tests"
|
|
10
11
|
},
|
|
11
12
|
"main": "build/index.js",
|
|
12
13
|
"module": "build/index.js",
|
|
@@ -21,8 +22,8 @@
|
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"@langchain/core": "^1.2.
|
|
25
|
-
"@owlmeans/dep-config": "
|
|
25
|
+
"@langchain/core": "^1.2.14",
|
|
26
|
+
"@owlmeans/dep-config": "^0.1.18",
|
|
26
27
|
"nodemon": "^3.1.14",
|
|
27
28
|
"typescript": "^7.0.2"
|
|
28
29
|
},
|
package/src/consts.ts
CHANGED
|
@@ -11,6 +11,20 @@ export enum ModelProvider {
|
|
|
11
11
|
Anthropic = 'anthropic',
|
|
12
12
|
/** Any OpenAI-compatible endpoint — OpenRouter, HuggingFace router, Together, vLLM, … */
|
|
13
13
|
Compatible = 'compatible',
|
|
14
|
+
/**
|
|
15
|
+
* No endpoint at all: the call is handed to whoever holds the execution.
|
|
16
|
+
*
|
|
17
|
+
* A delegated model does not talk to a provider. It packages the call — the system prompt, the
|
|
18
|
+
* conversation, the tools or the schema — and hands it to a transport the application seated,
|
|
19
|
+
* which carries it to something outside this process entirely: a coding agent driving the
|
|
20
|
+
* application through a connector, a human, a test. The answer comes back the same way and is
|
|
21
|
+
* turned into a completion the rest of the stack cannot tell apart from a provider's.
|
|
22
|
+
*
|
|
23
|
+
* It exists so that "who performs this call" can be a property of the SESSION rather than of the
|
|
24
|
+
* code: the same pipeline, the same prompts and the same retry rules, billed to somebody else's
|
|
25
|
+
* model.
|
|
26
|
+
*/
|
|
27
|
+
Delegated = 'delegated',
|
|
14
28
|
}
|
|
15
29
|
|
|
16
30
|
/**
|
|
@@ -35,6 +49,28 @@ export enum ExecutionEffort {
|
|
|
35
49
|
Max = 'max',
|
|
36
50
|
}
|
|
37
51
|
|
|
52
|
+
/**
|
|
53
|
+
* The PROVIDER's own effort knob — OpenAI `reasoning.effort`, Anthropic
|
|
54
|
+
* `output_config.effort`. Not {@link ExecutionEffort}: that is this package's tier, which
|
|
55
|
+
* sizes token budgets; this is a value sent on the wire. Which levels a model accepts is a
|
|
56
|
+
* provider-plugin fact in `@owlmeans/llm`.
|
|
57
|
+
*/
|
|
58
|
+
export enum ModelEffort {
|
|
59
|
+
None = 'none',
|
|
60
|
+
Minimal = 'minimal',
|
|
61
|
+
Low = 'low',
|
|
62
|
+
Medium = 'medium',
|
|
63
|
+
High = 'high',
|
|
64
|
+
XHigh = 'xhigh',
|
|
65
|
+
Max = 'max',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** {@link ModelEffort} from least to most work — the order an escalation climbs. */
|
|
69
|
+
export const MODEL_EFFORT_ORDER: readonly ModelEffort[] = [
|
|
70
|
+
ModelEffort.None, ModelEffort.Minimal, ModelEffort.Low, ModelEffort.Medium,
|
|
71
|
+
ModelEffort.High, ModelEffort.XHigh, ModelEffort.Max,
|
|
72
|
+
]
|
|
73
|
+
|
|
38
74
|
/**
|
|
39
75
|
* How a model is asked to produce a schema-conforming object.
|
|
40
76
|
*
|
|
@@ -61,7 +97,7 @@ export enum SpectatorContentType {
|
|
|
61
97
|
export const SPECTATOR_GENERAL = 'general'
|
|
62
98
|
|
|
63
99
|
/**
|
|
64
|
-
* Ordered sections of a composed
|
|
100
|
+
* Ordered sections of a composed prompt.
|
|
65
101
|
*
|
|
66
102
|
* The ordering is not cosmetic — it IS the prompt-cache design. Every provider caches
|
|
67
103
|
* a prompt by exact PREFIX match, so the sections are laid out most-stable first and a
|
|
@@ -70,16 +106,27 @@ export const SPECTATOR_GENERAL = 'general'
|
|
|
70
106
|
* - `Role` — the base system prompt defining who the model is. Stable per role.
|
|
71
107
|
* - `Skills` — the statically declared capabilities, rendered in a deterministic
|
|
72
108
|
* order. Stable per helper. A breakpoint closes `Role` + `Skills`.
|
|
73
|
-
* - `Packages` —
|
|
74
|
-
*
|
|
75
|
-
* invalidate the two blocks above it.
|
|
76
|
-
* - `
|
|
109
|
+
* - `Packages` — the package documentation this persona needs for the work at hand (a focus),
|
|
110
|
+
* or what the request happens to mention. It gets its OWN breakpoint and can
|
|
111
|
+
* never invalidate the two blocks above it.
|
|
112
|
+
* - `Results` — what the earlier steps of the pipeline this call runs in produced
|
|
113
|
+
* (`ExecutionState.results`). Stable within one step, different on the
|
|
114
|
+
* next, so it sits BELOW every boundary that is cached across steps and
|
|
115
|
+
* is emitted only when a view is present.
|
|
116
|
+
* - `Context` — caller-supplied system text and project facts. Stable for one step of the work,
|
|
117
|
+
* so it sits in the project message with `Results`.
|
|
118
|
+
* - `Tail` — what belongs to ONE call: per-call skills, late packages and types. Appended to the
|
|
119
|
+
* final message after the call's payload and never cached.
|
|
120
|
+
*
|
|
121
|
+
* Where each block is sent is {@link PROMPT_REGIONS}.
|
|
77
122
|
*/
|
|
78
123
|
export enum PromptBlock {
|
|
79
124
|
Role = 'role',
|
|
80
125
|
Skills = 'skills',
|
|
81
126
|
Packages = 'packages',
|
|
127
|
+
Results = 'results',
|
|
82
128
|
Context = 'context',
|
|
129
|
+
Tail = 'tail',
|
|
83
130
|
}
|
|
84
131
|
|
|
85
132
|
/**
|
|
@@ -91,8 +138,85 @@ export const PROMPT_BLOCK_ORDER: readonly PromptBlock[] = [
|
|
|
91
138
|
PromptBlock.Role,
|
|
92
139
|
PromptBlock.Skills,
|
|
93
140
|
PromptBlock.Packages,
|
|
141
|
+
PromptBlock.Results,
|
|
94
142
|
PromptBlock.Context,
|
|
143
|
+
PromptBlock.Tail,
|
|
95
144
|
] as const
|
|
96
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Where a composed block travels in a request. Each region is stable for a different span of
|
|
148
|
+
* work, so each closes on its own cache breakpoint (the tail on none):
|
|
149
|
+
*
|
|
150
|
+
* - `System` — the system message: who the model is and what it may use. Stable per persona
|
|
151
|
+
* (role + skills) and per persona and story (packages).
|
|
152
|
+
* - `Project` — the user turn right after the system: facts about this project and step.
|
|
153
|
+
* - `Tail` — appended to the final message, after the call's own payload.
|
|
154
|
+
*/
|
|
155
|
+
export enum PromptRegion {
|
|
156
|
+
System = 'system',
|
|
157
|
+
Project = 'project',
|
|
158
|
+
Tail = 'tail',
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** The blocks of each {@link PromptRegion}, in emission order. */
|
|
162
|
+
export const PROMPT_REGIONS: Readonly<Record<PromptRegion, readonly PromptBlock[]>> = Object.freeze({
|
|
163
|
+
[PromptRegion.System]: [PromptBlock.Role, PromptBlock.Skills, PromptBlock.Packages],
|
|
164
|
+
[PromptRegion.Project]: [PromptBlock.Results, PromptBlock.Context],
|
|
165
|
+
[PromptRegion.Tail]: [PromptBlock.Tail],
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* What a part of a package's documentation is FOR — the closed vocabulary a chunked package skill
|
|
170
|
+
* tags its parts with, and a {@link PromptFocus} selects them by. `library-manager` keeps a copy
|
|
171
|
+
* (it cannot import this package) and a test pins that the two are equal.
|
|
172
|
+
*/
|
|
173
|
+
export enum PackagePurpose {
|
|
174
|
+
View = 'view',
|
|
175
|
+
Form = 'form',
|
|
176
|
+
List = 'list',
|
|
177
|
+
Detail = 'detail',
|
|
178
|
+
Dialog = 'dialog',
|
|
179
|
+
Picker = 'picker',
|
|
180
|
+
Navigation = 'navigation',
|
|
181
|
+
Layout = 'layout',
|
|
182
|
+
Screen = 'screen',
|
|
183
|
+
Theme = 'theme',
|
|
184
|
+
Feedback = 'feedback',
|
|
185
|
+
State = 'state',
|
|
186
|
+
ClientApi = 'client-api',
|
|
187
|
+
ServerApi = 'server-api',
|
|
188
|
+
Data = 'data',
|
|
189
|
+
Migration = 'migration',
|
|
190
|
+
Query = 'query',
|
|
191
|
+
Auth = 'auth',
|
|
192
|
+
Consent = 'consent',
|
|
193
|
+
Payment = 'payment',
|
|
194
|
+
Planning = 'planning',
|
|
195
|
+
Job = 'job',
|
|
196
|
+
Agent = 'agent',
|
|
197
|
+
Config = 'config',
|
|
198
|
+
Test = 'test',
|
|
199
|
+
Ops = 'ops',
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Every {@link PackagePurpose}, in declaration order — declared, not derived from the enum. */
|
|
203
|
+
export const PACKAGE_PURPOSES: readonly PackagePurpose[] = Object.freeze([
|
|
204
|
+
PackagePurpose.View, PackagePurpose.Form, PackagePurpose.List, PackagePurpose.Detail,
|
|
205
|
+
PackagePurpose.Dialog, PackagePurpose.Picker, PackagePurpose.Navigation, PackagePurpose.Layout,
|
|
206
|
+
PackagePurpose.Screen, PackagePurpose.Theme, PackagePurpose.Feedback, PackagePurpose.State,
|
|
207
|
+
PackagePurpose.ClientApi, PackagePurpose.ServerApi, PackagePurpose.Data, PackagePurpose.Migration,
|
|
208
|
+
PackagePurpose.Query, PackagePurpose.Auth, PackagePurpose.Consent, PackagePurpose.Payment,
|
|
209
|
+
PackagePurpose.Planning, PackagePurpose.Job, PackagePurpose.Agent, PackagePurpose.Config,
|
|
210
|
+
PackagePurpose.Test, PackagePurpose.Ops,
|
|
211
|
+
])
|
|
212
|
+
|
|
97
213
|
/** Sort weight of a skill that declares none — see `SkillDefinition.order`. */
|
|
98
214
|
export const DEFAULT_SKILL_ORDER = 100
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Conventional {@link ModelRole} for the cheap side calls the layer makes on its own
|
|
218
|
+
* behalf — a relevance pick, a classification, a one-line judgement — rather than for the
|
|
219
|
+
* work a caller asked for. A deployment that names its cheap tier differently points
|
|
220
|
+
* `ModelPolicy.utilityRole` at its own alias; nothing else has to change.
|
|
221
|
+
*/
|
|
222
|
+
export const UTILITY_ROLE = 'utility'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** What the answer must be. */
|
|
2
|
+
export enum DelegatedMode {
|
|
3
|
+
/** Prose or code. */
|
|
4
|
+
Text = 'text',
|
|
5
|
+
/** Exactly one JSON object satisfying `outputSchema`. */
|
|
6
|
+
Json = 'json',
|
|
7
|
+
/** A list of calls chosen from `tools`. */
|
|
8
|
+
Tools = 'tools',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Who a message came from. Deliberately the four roles every chat API agrees on. */
|
|
12
|
+
export enum DelegatedRole {
|
|
13
|
+
System = 'system',
|
|
14
|
+
User = 'user',
|
|
15
|
+
Assistant = 'assistant',
|
|
16
|
+
Tool = 'tool',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** What shape an answer came back in. */
|
|
20
|
+
export enum DelegatedResultKind {
|
|
21
|
+
Text = 'text',
|
|
22
|
+
Json = 'json',
|
|
23
|
+
ToolCalls = 'tool-calls',
|
|
24
|
+
/** The performer could not answer. Treated as a malformed answer: asked again, with the reason. */
|
|
25
|
+
Error = 'error',
|
|
26
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The serializable form of one model call, for a performer outside this process.
|
|
3
|
+
*
|
|
4
|
+
* A delegated call cannot pass a `BaseChatModel` or a langchain message anywhere: the thing that
|
|
5
|
+
* answers it is a coding agent on somebody's laptop, a test double, or a person. So the call is
|
|
6
|
+
* reduced to what any of them can act on — a persona, a conversation, and the shape the answer
|
|
7
|
+
* must take — and everything provider-specific is left behind.
|
|
8
|
+
*
|
|
9
|
+
* There is no vocabulary here from whatever pipeline asked. A `role` and a `tier` travel because
|
|
10
|
+
* the performer has to choose a model; nothing else about the caller does.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { DelegatedMode, DelegatedResultKind, DelegatedRole } from './consts.js'
|
|
14
|
+
|
|
15
|
+
export interface DelegatedToolCall {
|
|
16
|
+
id?: string
|
|
17
|
+
name: string
|
|
18
|
+
args: Record<string, unknown>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DelegatedMessage {
|
|
22
|
+
role: DelegatedRole
|
|
23
|
+
content: string
|
|
24
|
+
/** Assistant turns that called tools. */
|
|
25
|
+
toolCalls?: DelegatedToolCall[]
|
|
26
|
+
/** Tool turns answer one call, and name the tool they answer. */
|
|
27
|
+
toolCallId?: string
|
|
28
|
+
name?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DelegatedTool {
|
|
32
|
+
name: string
|
|
33
|
+
description?: string
|
|
34
|
+
/** JSON Schema of the arguments. */
|
|
35
|
+
parameters: Record<string, unknown>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type DelegatedToolChoice = 'auto' | 'none' | { name: string }
|
|
39
|
+
|
|
40
|
+
export interface DelegatedTask {
|
|
41
|
+
id: string
|
|
42
|
+
/** Which transport is expected to answer it — the key the application seated it under. */
|
|
43
|
+
delegate: string
|
|
44
|
+
/** The performer's role name, for its own logging. Never load-bearing. */
|
|
45
|
+
role?: string
|
|
46
|
+
/** Which power class the performer should run this on. */
|
|
47
|
+
tier?: string
|
|
48
|
+
/** 0-based. Above zero means a previous answer was refused; `feedback` says why. */
|
|
49
|
+
attempt: number
|
|
50
|
+
mode: DelegatedMode
|
|
51
|
+
system?: string
|
|
52
|
+
messages: DelegatedMessage[]
|
|
53
|
+
tools?: DelegatedTool[]
|
|
54
|
+
toolChoice?: DelegatedToolChoice
|
|
55
|
+
outputSchema?: Record<string, unknown>
|
|
56
|
+
/** A soft cap, stated so a performer can size its own call. */
|
|
57
|
+
maxOutputChars?: number
|
|
58
|
+
feedback?: string
|
|
59
|
+
/** ISO. A performer past this may say so rather than answer. */
|
|
60
|
+
expiresAt?: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface DelegatedUsage {
|
|
64
|
+
inputTokens?: number
|
|
65
|
+
outputTokens?: number
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface DelegatedResult {
|
|
69
|
+
taskId: string
|
|
70
|
+
kind: DelegatedResultKind
|
|
71
|
+
text?: string
|
|
72
|
+
json?: unknown
|
|
73
|
+
toolCalls?: DelegatedToolCall[]
|
|
74
|
+
error?: string
|
|
75
|
+
/** What the performer spent. Recorded; it costs this deployment nothing. */
|
|
76
|
+
usage?: DelegatedUsage
|
|
77
|
+
/** What the performer actually ran. Display only. */
|
|
78
|
+
model?: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* How a delegated call reaches its performer.
|
|
83
|
+
*
|
|
84
|
+
* One method, because that is the whole seam: everything about routing, waiting, redelivery and
|
|
85
|
+
* giving up belongs to whoever implements it. A transport that cannot serve the call must THROW
|
|
86
|
+
* rather than answer with an error result — an error result is a bad answer, which is retried,
|
|
87
|
+
* while a transport that is gone is terminal.
|
|
88
|
+
*/
|
|
89
|
+
export interface DelegateTransport {
|
|
90
|
+
dispatch: (task: DelegatedTask, signal?: AbortSignal) => Promise<DelegatedResult>
|
|
91
|
+
}
|