@xemahq/kernel-contracts 0.40.0 → 0.42.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.
- package/dist/agent-composition/lib/model-resolution-matrix.d.ts +5 -2
- package/dist/agent-composition/lib/model-resolution-matrix.d.ts.map +1 -1
- package/dist/agent-composition/lib/model-resolution-matrix.js +1 -0
- package/dist/agent-composition/lib/model-resolution-matrix.js.map +1 -1
- package/dist/connector/lib/canonical-operation-binding.d.ts +1 -1
- package/dist/connector/lib/canonical-operation-binding.d.ts.map +1 -1
- package/dist/connector/lib/canonical-operation-binding.js +2 -2
- package/dist/connector/lib/canonical-operation-binding.js.map +1 -1
- package/dist/connector/lib/integration-provider-contribution.d.ts +2 -2
- package/dist/contribution/lib/contribution-kind.d.ts +2 -1
- package/dist/contribution/lib/contribution-kind.d.ts.map +1 -1
- package/dist/contribution/lib/contribution-kind.js +1 -0
- package/dist/contribution/lib/contribution-kind.js.map +1 -1
- package/dist/enterprise-context/index.d.ts +5 -0
- package/dist/enterprise-context/index.d.ts.map +1 -0
- package/dist/enterprise-context/index.js +21 -0
- package/dist/enterprise-context/index.js.map +1 -0
- package/dist/enterprise-context/lib/context-bundle.d.ts +13 -0
- package/dist/enterprise-context/lib/context-bundle.d.ts.map +1 -0
- package/dist/enterprise-context/lib/context-bundle.js +3 -0
- package/dist/enterprise-context/lib/context-bundle.js.map +1 -0
- package/dist/enterprise-context/lib/context-document.d.ts +9 -0
- package/dist/enterprise-context/lib/context-document.d.ts.map +1 -0
- package/dist/enterprise-context/lib/context-document.js +3 -0
- package/dist/enterprise-context/lib/context-document.js.map +1 -0
- package/dist/enterprise-context/lib/context-mount-entry.d.ts +8 -0
- package/dist/enterprise-context/lib/context-mount-entry.d.ts.map +1 -0
- package/dist/enterprise-context/lib/context-mount-entry.js +5 -0
- package/dist/enterprise-context/lib/context-mount-entry.js.map +1 -0
- package/dist/enterprise-context/lib/dropped-context.d.ts +9 -0
- package/dist/enterprise-context/lib/dropped-context.d.ts.map +1 -0
- package/dist/enterprise-context/lib/dropped-context.js +8 -0
- package/dist/enterprise-context/lib/dropped-context.js.map +1 -0
- package/dist/ingestion-source/index.d.ts +2 -0
- package/dist/ingestion-source/index.d.ts.map +1 -0
- package/dist/ingestion-source/index.js +18 -0
- package/dist/ingestion-source/index.js.map +1 -0
- package/dist/ingestion-source/lib/ingestion-source-contribution.d.ts +62 -0
- package/dist/ingestion-source/lib/ingestion-source-contribution.d.ts.map +1 -0
- package/dist/ingestion-source/lib/ingestion-source-contribution.js +78 -0
- package/dist/ingestion-source/lib/ingestion-source-contribution.js.map +1 -0
- package/dist/llm-gateway/lib/errors.d.ts +5 -0
- package/dist/llm-gateway/lib/errors.d.ts.map +1 -1
- package/dist/llm-gateway/lib/errors.js +21 -1
- package/dist/llm-gateway/lib/errors.js.map +1 -1
- package/dist/output/index.d.ts +1 -0
- package/dist/output/index.d.ts.map +1 -1
- package/dist/output/index.js +1 -0
- package/dist/output/index.js.map +1 -1
- package/dist/output/lib/output-version-dto.d.ts +2 -0
- package/dist/output/lib/output-version-dto.d.ts.map +1 -1
- package/dist/output/lib/point-of-attention.d.ts +19 -0
- package/dist/output/lib/point-of-attention.d.ts.map +1 -0
- package/dist/output/lib/point-of-attention.js +24 -0
- package/dist/output/lib/point-of-attention.js.map +1 -0
- package/dist/worker-runtime/index.d.ts +1 -0
- package/dist/worker-runtime/index.d.ts.map +1 -1
- package/dist/worker-runtime/index.js +1 -0
- package/dist/worker-runtime/index.js.map +1 -1
- package/dist/worker-runtime/lib/enums.d.ts +5 -0
- package/dist/worker-runtime/lib/enums.d.ts.map +1 -1
- package/dist/worker-runtime/lib/enums.js +7 -1
- package/dist/worker-runtime/lib/enums.js.map +1 -1
- package/dist/worker-runtime/lib/runtime-layout-profile.d.ts +4 -1
- package/dist/worker-runtime/lib/runtime-layout-profile.d.ts.map +1 -1
- package/dist/worker-runtime/lib/runtime-layout-profile.js +12 -0
- package/dist/worker-runtime/lib/runtime-layout-profile.js.map +1 -1
- package/dist/worker-runtime/lib/workspace-sandbox.d.ts +7 -0
- package/dist/worker-runtime/lib/workspace-sandbox.d.ts.map +1 -0
- package/dist/worker-runtime/lib/workspace-sandbox.js +36 -0
- package/dist/worker-runtime/lib/workspace-sandbox.js.map +1 -0
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +1 -0
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/lib/enums.d.ts +1 -0
- package/dist/workflow/lib/enums.d.ts.map +1 -1
- package/dist/workflow/lib/enums.js +1 -0
- package/dist/workflow/lib/enums.js.map +1 -1
- package/dist/workflow/lib/model-ref.d.ts +17 -0
- package/dist/workflow/lib/model-ref.d.ts.map +1 -1
- package/dist/workflow/lib/model-ref.js +19 -1
- package/dist/workflow/lib/model-ref.js.map +1 -1
- package/dist/workflow/lib/workflow-control.d.ts +91 -0
- package/dist/workflow/lib/workflow-control.d.ts.map +1 -0
- package/dist/workflow/lib/workflow-control.js +84 -0
- package/dist/workflow/lib/workflow-control.js.map +1 -0
- package/package.json +1 -1
- package/src/agent-composition/lib/model-resolution-matrix.ts +16 -1
- package/src/connector/lib/canonical-operation-binding.ts +1 -1
- package/src/contribution/lib/contribution-kind.ts +18 -0
- package/src/enterprise-context/index.ts +4 -0
- package/src/enterprise-context/lib/context-bundle.ts +35 -0
- package/src/enterprise-context/lib/context-document.ts +23 -0
- package/src/enterprise-context/lib/context-mount-entry.ts +29 -0
- package/src/enterprise-context/lib/dropped-context.ts +24 -0
- package/src/ingestion-source/index.ts +20 -0
- package/src/ingestion-source/lib/ingestion-source-contribution.ts +238 -0
- package/src/llm-gateway/lib/errors.ts +46 -0
- package/src/output/index.ts +1 -0
- package/src/output/lib/output-version-dto.ts +9 -0
- package/src/output/lib/point-of-attention.ts +69 -0
- package/src/worker-runtime/index.ts +1 -0
- package/src/worker-runtime/lib/enums.ts +29 -0
- package/src/worker-runtime/lib/runtime-layout-profile.ts +61 -1
- package/src/worker-runtime/lib/workspace-sandbox.ts +129 -0
- package/src/workflow/index.ts +1 -0
- package/src/workflow/lib/enums.ts +8 -0
- package/src/workflow/lib/model-ref.ts +45 -0
- package/src/workflow/lib/workflow-control.ts +198 -0
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// boundaries — agent start, sub-agent spawn, and `/skill` launch.
|
|
16
16
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
17
17
|
|
|
18
|
-
import type { ModelRef } from '../../workflow';
|
|
18
|
+
import type { ModelCapability, ModelRef } from '../../workflow';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Open registry of matrix dimensions. v1 ships agent/skill/project/stage;
|
|
@@ -34,6 +34,7 @@ export enum ResolutionDimension {
|
|
|
34
34
|
Stage = 'stage',
|
|
35
35
|
ModelClass = 'modelClass',
|
|
36
36
|
Purpose = 'purpose',
|
|
37
|
+
ModelCapability = 'modelCapability',
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -55,6 +56,14 @@ export interface ModelMatrixSelector {
|
|
|
55
56
|
readonly stage?: string;
|
|
56
57
|
/** Match when the resolving agent's modelClass equals this value. */
|
|
57
58
|
readonly modelClass?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Match when the resolving model's intrinsic capability includes this value
|
|
61
|
+
* (e.g. route every `vision`-capable invocation to a multimodal model). A
|
|
62
|
+
* typed, first-class dimension — never routed through `extra`. Closed set
|
|
63
|
+
* owned by the kernel (`ModelCapability` in
|
|
64
|
+
* `@xemahq/kernel-contracts/workflow`).
|
|
65
|
+
*/
|
|
66
|
+
readonly modelCapability?: ModelCapability;
|
|
58
67
|
/**
|
|
59
68
|
* Match when the invocation's non-agent purpose equals this value. Used
|
|
60
69
|
* for system flows that route LLM calls outside the agent/skill model —
|
|
@@ -93,6 +102,12 @@ export interface ModelResolutionContext {
|
|
|
93
102
|
* sites; undefined for non-agent purposes.
|
|
94
103
|
*/
|
|
95
104
|
readonly modelClass?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The resolving model's intrinsic capability — populated at agent-invocation
|
|
107
|
+
* build sites when the routing needs a capability-gated model; undefined
|
|
108
|
+
* otherwise. Matched against `ModelMatrixSelector.modelCapability`.
|
|
109
|
+
*/
|
|
110
|
+
readonly modelCapability?: ModelCapability;
|
|
96
111
|
/**
|
|
97
112
|
* Non-agent invocation purpose (e.g. memory summarization/embedding).
|
|
98
113
|
* Optional — agent and skill invocations leave this undefined.
|
|
@@ -24,7 +24,7 @@ import { z } from 'zod';
|
|
|
24
24
|
import {
|
|
25
25
|
CanonicalObjectTypeRefSchema,
|
|
26
26
|
type CanonicalObjectTypeRef,
|
|
27
|
-
} from '../../canonical-object
|
|
27
|
+
} from '../../canonical-object';
|
|
28
28
|
|
|
29
29
|
/** Which way a bound operation maps between provider records and canonical objects. */
|
|
30
30
|
export enum CanonicalMappingDirection {
|
|
@@ -283,6 +283,24 @@ export enum ContributionKind {
|
|
|
283
283
|
* point. Provenance (`biome.id/version`) is stamped by the parser.
|
|
284
284
|
*/
|
|
285
285
|
CanonicalObjectType = 'canonical-object-type',
|
|
286
|
+
|
|
287
|
+
// -- External-source ingestion plane ---------------------------------------
|
|
288
|
+
/**
|
|
289
|
+
* Category 1 (biome-host `KindParser`). A PULL-BASED EXTERNAL DATA SOURCE a
|
|
290
|
+
* biome declares so the platform can materialize an external dataset into a
|
|
291
|
+
* local catalog on a cadence, with change-detection and provenance. The
|
|
292
|
+
* descriptor is pure data — WHERE the data comes from (`fetch`), HOW OFTEN to
|
|
293
|
+
* pull (`cadence`), HOW to tell it changed (`changeDetection`), and WHERE the
|
|
294
|
+
* pulled records land (`catalog`) — never any mint/transform code. The kernel
|
|
295
|
+
* owns this member AND the manifest schema
|
|
296
|
+
* (`IngestionSourceContributionManifestSchema`, exported from
|
|
297
|
+
* `@xemahq/kernel-contracts/ingestion-source`), mirroring the `Capability` /
|
|
298
|
+
* `SearchType` / `CanonicalObjectType` kinds: one value-identical wire shape
|
|
299
|
+
* validated fail-fast by BOTH the biome-host parser and the owning ingestion
|
|
300
|
+
* service. Provenance (`biome.id/version`) is stamped by the parser — never
|
|
301
|
+
* declared inline.
|
|
302
|
+
*/
|
|
303
|
+
IngestionSource = 'ingestion-source',
|
|
286
304
|
}
|
|
287
305
|
|
|
288
306
|
/**
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ContextDocument } from './context-document';
|
|
2
|
+
import type { ContextMountEntry } from './context-mount-entry';
|
|
3
|
+
import type { DroppedContextDocument } from './dropped-context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The assembled Enterprise-Context bundle — the result of retrieving and
|
|
7
|
+
* ranking documents about a canonical object and packing them into a
|
|
8
|
+
* budget-bounded, materialisable mount plan.
|
|
9
|
+
*
|
|
10
|
+
* The bundle is producer-neutral: the first producer is
|
|
11
|
+
* connector-gateway-api's enterprise-context module, but the shape is a
|
|
12
|
+
* kernel contract so any assembler and any consumer (e.g. an agent-session
|
|
13
|
+
* launch that materialises the mount plan) agree on the wire.
|
|
14
|
+
*
|
|
15
|
+
* `primary` is the canonical entity echoed back verbatim (the retrieval
|
|
16
|
+
* subject), serialised into the first `static-literal` mount entry. It is
|
|
17
|
+
* the raw object, not a ranked {@link ContextDocument}. `documents` are the
|
|
18
|
+
* ranked retrieval hits; `mountPlan` materialises the entity plus every
|
|
19
|
+
* document that fit the budget; `dropped` lists documents excluded by the
|
|
20
|
+
* budget. `bytesUsed` is the total content bytes actually placed in the
|
|
21
|
+
* mount plan and never exceeds `byteBudget`.
|
|
22
|
+
*/
|
|
23
|
+
export interface ContextBundle {
|
|
24
|
+
/** The canonical object type this bundle was assembled for. */
|
|
25
|
+
readonly objectType: string;
|
|
26
|
+
/** The canonical entity echoed back (the retrieval subject). */
|
|
27
|
+
readonly primary?: Readonly<Record<string, unknown>>;
|
|
28
|
+
readonly documents: readonly ContextDocument[];
|
|
29
|
+
readonly mountPlan: readonly ContextMountEntry[];
|
|
30
|
+
readonly dropped: readonly DroppedContextDocument[];
|
|
31
|
+
/** Total content-byte budget applied while packing the mount plan. */
|
|
32
|
+
readonly byteBudget: number;
|
|
33
|
+
/** Total content bytes materialised in the mount plan (≤ `byteBudget`). */
|
|
34
|
+
readonly bytesUsed: number;
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One retrieved, ranked document included in an assembled
|
|
3
|
+
* {@link ContextBundle}. Sourced from a search/retrieval pass over the
|
|
4
|
+
* canonical-object corpus; `score` is the fused relevance (max across
|
|
5
|
+
* retrieval passes).
|
|
6
|
+
*
|
|
7
|
+
* `content` is the retrieved body (a summary/snippet when the retrieval
|
|
8
|
+
* pass does not return full content). It is the same string materialised
|
|
9
|
+
* as the document's `static-literal` mount bytes when the document fits
|
|
10
|
+
* the byte budget.
|
|
11
|
+
*/
|
|
12
|
+
export interface ContextDocument {
|
|
13
|
+
/** Stable document reference, e.g. `kb_page:src_abc123`. */
|
|
14
|
+
readonly ref: string;
|
|
15
|
+
/** Document type discriminator, e.g. `kb_page`. */
|
|
16
|
+
readonly docType: string;
|
|
17
|
+
readonly title?: string;
|
|
18
|
+
readonly summary?: string;
|
|
19
|
+
/** Retrieved content (summary/snippet when full content is unavailable). */
|
|
20
|
+
readonly content?: string;
|
|
21
|
+
/** Fused relevance score (max across retrieval passes). */
|
|
22
|
+
readonly score: number;
|
|
23
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MountSource } from '../../workflow';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Access mode of a context mount entry. Assembled enterprise context is
|
|
5
|
+
* never written by the agent, so the mode is closed to `read-only`.
|
|
6
|
+
*
|
|
7
|
+
* Modelled as a single-value closed type (const + `typeof` type) rather
|
|
8
|
+
* than a two-member enum: the domain today has exactly one legal value and
|
|
9
|
+
* a wider mode would misrepresent the contract. A future read-write context
|
|
10
|
+
* mode is a deliberate contract change, not an open string.
|
|
11
|
+
*/
|
|
12
|
+
export const CONTEXT_MOUNT_MODE = 'read-only' as const;
|
|
13
|
+
|
|
14
|
+
export type ContextMountMode = typeof CONTEXT_MOUNT_MODE;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One materialisable mount entry in an assembled {@link ContextBundle}.
|
|
18
|
+
*
|
|
19
|
+
* `source` is the full kernel {@link MountSource} discriminated union — not
|
|
20
|
+
* narrowed to the `static-literal` variant the first producer
|
|
21
|
+
* (connector-gateway-api) emits — so future producers can attach other
|
|
22
|
+
* kinds (e.g. `kb-pages`) without a contract change. The session's
|
|
23
|
+
* mount-apply pipeline materialises every entry as a typed mount, so the
|
|
24
|
+
* assembled context lands under `/workspace/` as real files.
|
|
25
|
+
*/
|
|
26
|
+
export interface ContextMountEntry {
|
|
27
|
+
readonly mode: ContextMountMode;
|
|
28
|
+
readonly source: MountSource;
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a retrieved document was excluded from an assembled
|
|
3
|
+
* {@link ContextBundle}. Closed set — a dropped document is always
|
|
4
|
+
* reported (never silently discarded), and the reason is a typed enum so
|
|
5
|
+
* consumers can branch on it without string matching.
|
|
6
|
+
*
|
|
7
|
+
* Today the only exclusion path is the byte-budget cap applied while
|
|
8
|
+
* charging ranked documents against the bundle's `byteBudget`. New
|
|
9
|
+
* exclusion reasons extend this enum (one member) — do not introduce a
|
|
10
|
+
* free-form reason string.
|
|
11
|
+
*/
|
|
12
|
+
export enum DroppedContextReason {
|
|
13
|
+
/** Adding the document's content would exceed the bundle byte budget. */
|
|
14
|
+
BYTE_BUDGET_EXCEEDED = 'BYTE_BUDGET_EXCEEDED',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A document excluded from the bundle — reported, never silently dropped. */
|
|
18
|
+
export interface DroppedContextDocument {
|
|
19
|
+
/** Stable document reference of the excluded document. */
|
|
20
|
+
readonly ref: string;
|
|
21
|
+
/** Content byte-size that would have been added had it been included. */
|
|
22
|
+
readonly bytes: number;
|
|
23
|
+
readonly reason: DroppedContextReason;
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// @xemahq/kernel-contracts/ingestion-source — external-source ingestion
|
|
3
|
+
// contribution contract.
|
|
4
|
+
//
|
|
5
|
+
// Pure types + Zod schemas for the `ContributionKind.IngestionSource` manifest:
|
|
6
|
+
// the declarative, boot-time registration of a PULL-BASED external data source
|
|
7
|
+
// a biome contributes so the platform materializes an external dataset into a
|
|
8
|
+
// local catalog on a cadence, with change-detection and provenance. The
|
|
9
|
+
// manifest is pure data — WHERE (`fetch`), HOW OFTEN (`cadence`), HOW-CHANGED
|
|
10
|
+
// (`changeDetection`), WHERE-IT-LANDS (`catalog`) — never mint/transform code
|
|
11
|
+
// and never a secret. Self-contained: zero cross-subpath edges, zero runtime
|
|
12
|
+
// deps beyond `zod`.
|
|
13
|
+
//
|
|
14
|
+
// NOTE: this is distinct from `search-source` (runtime `IndexableDocument`,
|
|
15
|
+
// event-fed document INSTANCES) and from `search` (search RESULT-TYPES). An
|
|
16
|
+
// ingestion source is the CONTRIBUTED (declarative, boot-time) declaration of a
|
|
17
|
+
// pull-based origin; the records it yields flow to their catalog at runtime.
|
|
18
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
19
|
+
|
|
20
|
+
export * from './lib/ingestion-source-contribution';
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Maximum length of the short identifier / label / tag strings on an ingestion
|
|
5
|
+
* source manifest. Bounded so list/describe responses stay small and persisted
|
|
6
|
+
* rows have a predictable upper size.
|
|
7
|
+
*/
|
|
8
|
+
const INGESTION_SOURCE_STRING_MAX = 200;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Maximum length of the free-text summary. A summary is a one-liner, not a
|
|
12
|
+
* document.
|
|
13
|
+
*/
|
|
14
|
+
const INGESTION_SOURCE_SUMMARY_MAX = 1000;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Maximum length of a fetch URL / cadence expression / record selector — each
|
|
18
|
+
* is a small path/pattern, never a document.
|
|
19
|
+
*/
|
|
20
|
+
const INGESTION_SOURCE_URL_MAX = 2000;
|
|
21
|
+
const INGESTION_SOURCE_EXPRESSION_MAX = 200;
|
|
22
|
+
const INGESTION_SOURCE_SELECTOR_MAX = 500;
|
|
23
|
+
|
|
24
|
+
/** Hard cap on the number of static request headers a source may declare. */
|
|
25
|
+
const INGESTION_SOURCE_HEADERS_MAX = 50;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* HTTP method used to pull from an ingestion source. Closed set — a source
|
|
29
|
+
* either GETs a resource or POSTs a query body.
|
|
30
|
+
*/
|
|
31
|
+
export enum IngestionFetchMethod {
|
|
32
|
+
GET = 'GET',
|
|
33
|
+
POST = 'POST',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const INGESTION_FETCH_METHOD_VALUES: readonly IngestionFetchMethod[] = [
|
|
37
|
+
IngestionFetchMethod.GET,
|
|
38
|
+
IngestionFetchMethod.POST,
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export const IngestionFetchMethodSchema = z.enum(
|
|
42
|
+
INGESTION_FETCH_METHOD_VALUES as readonly [
|
|
43
|
+
IngestionFetchMethod,
|
|
44
|
+
...IngestionFetchMethod[],
|
|
45
|
+
],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* How the pull cadence is expressed. Closed set: a fixed interval or a cron
|
|
50
|
+
* expression. The `expression` field carries the concrete value (a duration
|
|
51
|
+
* string for `interval`, a cron string for `cron`).
|
|
52
|
+
*/
|
|
53
|
+
export enum IngestionCadenceKind {
|
|
54
|
+
INTERVAL = 'interval',
|
|
55
|
+
CRON = 'cron',
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const INGESTION_CADENCE_KIND_VALUES: readonly IngestionCadenceKind[] = [
|
|
59
|
+
IngestionCadenceKind.INTERVAL,
|
|
60
|
+
IngestionCadenceKind.CRON,
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
export const IngestionCadenceKindSchema = z.enum(
|
|
64
|
+
INGESTION_CADENCE_KIND_VALUES as readonly [
|
|
65
|
+
IngestionCadenceKind,
|
|
66
|
+
...IngestionCadenceKind[],
|
|
67
|
+
],
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* How the platform decides a pulled resource CHANGED since the last pull.
|
|
72
|
+
* Closed set — the source declares which signal is authoritative so the puller
|
|
73
|
+
* never guesses.
|
|
74
|
+
*/
|
|
75
|
+
export enum IngestionChangeDetectionStrategy {
|
|
76
|
+
/** Compare the HTTP `ETag` response header. */
|
|
77
|
+
ETAG = 'etag',
|
|
78
|
+
/** Compare the HTTP `Last-Modified` response header. */
|
|
79
|
+
LAST_MODIFIED = 'last-modified',
|
|
80
|
+
/** Hash the fetched body and compare content hashes. */
|
|
81
|
+
CONTENT_HASH = 'content-hash',
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const INGESTION_CHANGE_DETECTION_STRATEGY_VALUES: readonly IngestionChangeDetectionStrategy[] =
|
|
85
|
+
[
|
|
86
|
+
IngestionChangeDetectionStrategy.ETAG,
|
|
87
|
+
IngestionChangeDetectionStrategy.LAST_MODIFIED,
|
|
88
|
+
IngestionChangeDetectionStrategy.CONTENT_HASH,
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
export const IngestionChangeDetectionStrategySchema = z.enum(
|
|
92
|
+
INGESTION_CHANGE_DETECTION_STRATEGY_VALUES as readonly [
|
|
93
|
+
IngestionChangeDetectionStrategy,
|
|
94
|
+
...IngestionChangeDetectionStrategy[],
|
|
95
|
+
],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* `IngestionFetchSpec` — WHERE the data comes from and HOW to request it. A
|
|
100
|
+
* plain HTTP pull descriptor: URL, method, and optional static headers. No
|
|
101
|
+
* credential is carried inline — a private source references a broker-resolved
|
|
102
|
+
* credential through the platform, never a secret in the manifest.
|
|
103
|
+
*/
|
|
104
|
+
export interface IngestionFetchSpec {
|
|
105
|
+
/** Absolute URL to pull from. ≤ 2000 chars. */
|
|
106
|
+
readonly url: string;
|
|
107
|
+
/** HTTP method. Absent ⇒ `GET`. */
|
|
108
|
+
readonly method?: IngestionFetchMethod;
|
|
109
|
+
/** Static request headers (non-secret). Hard-capped at 50 entries. */
|
|
110
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const IngestionFetchSpecSchema: z.ZodType<IngestionFetchSpec> = z.object({
|
|
114
|
+
url: z.string().min(1).max(INGESTION_SOURCE_URL_MAX),
|
|
115
|
+
method: IngestionFetchMethodSchema.optional(),
|
|
116
|
+
headers: z
|
|
117
|
+
.record(
|
|
118
|
+
z.string().min(1).max(INGESTION_SOURCE_STRING_MAX),
|
|
119
|
+
z.string().max(INGESTION_SOURCE_STRING_MAX),
|
|
120
|
+
)
|
|
121
|
+
.refine((h) => Object.keys(h).length <= INGESTION_SOURCE_HEADERS_MAX, {
|
|
122
|
+
message: `at most ${INGESTION_SOURCE_HEADERS_MAX} headers`,
|
|
123
|
+
})
|
|
124
|
+
.optional(),
|
|
125
|
+
}) as z.ZodType<IngestionFetchSpec>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* `IngestionCadenceSpec` — HOW OFTEN the source is pulled. `kind` selects the
|
|
129
|
+
* grammar; `expression` carries the concrete value.
|
|
130
|
+
*/
|
|
131
|
+
export interface IngestionCadenceSpec {
|
|
132
|
+
readonly kind: IngestionCadenceKind;
|
|
133
|
+
/** Interval duration (for `interval`) or cron expression (for `cron`). */
|
|
134
|
+
readonly expression: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const IngestionCadenceSpecSchema: z.ZodType<IngestionCadenceSpec> =
|
|
138
|
+
z.object({
|
|
139
|
+
kind: IngestionCadenceKindSchema,
|
|
140
|
+
expression: z.string().min(1).max(INGESTION_SOURCE_EXPRESSION_MAX),
|
|
141
|
+
}) as z.ZodType<IngestionCadenceSpec>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* `IngestionChangeDetectionSpec` — HOW the puller decides a resource changed.
|
|
145
|
+
*/
|
|
146
|
+
export interface IngestionChangeDetectionSpec {
|
|
147
|
+
readonly strategy: IngestionChangeDetectionStrategy;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const IngestionChangeDetectionSpecSchema: z.ZodType<IngestionChangeDetectionSpec> =
|
|
151
|
+
z.object({
|
|
152
|
+
strategy: IngestionChangeDetectionStrategySchema,
|
|
153
|
+
}) as z.ZodType<IngestionChangeDetectionSpec>;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* `IngestionCatalogSpec` — WHERE pulled records land and how they are tagged
|
|
157
|
+
* for provenance. `targetIndex` is the local catalog/index the records are
|
|
158
|
+
* written into; `provenanceTag` stamps each record so a downstream reader can
|
|
159
|
+
* trace it back to this source.
|
|
160
|
+
*/
|
|
161
|
+
export interface IngestionCatalogSpec {
|
|
162
|
+
/** The local catalog/index pulled records are written into. ≤ 200 chars. */
|
|
163
|
+
readonly targetIndex: string;
|
|
164
|
+
/** Provenance tag stamped on every pulled record. ≤ 200 chars. */
|
|
165
|
+
readonly provenanceTag: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const IngestionCatalogSpecSchema: z.ZodType<IngestionCatalogSpec> =
|
|
169
|
+
z.object({
|
|
170
|
+
targetIndex: z.string().min(1).max(INGESTION_SOURCE_STRING_MAX),
|
|
171
|
+
provenanceTag: z.string().min(1).max(INGESTION_SOURCE_STRING_MAX),
|
|
172
|
+
}) as z.ZodType<IngestionCatalogSpec>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Manifest shape carried by every `ContributionKind.IngestionSource` envelope.
|
|
176
|
+
* One contribution = one PULL-BASED external data source.
|
|
177
|
+
*
|
|
178
|
+
* Mirrors `CapabilityContributionManifest` / `SearchTypeContributionManifest`
|
|
179
|
+
* precisely: a value-identical subset of the wire body the owning ingestion
|
|
180
|
+
* service accepts, validated fail-fast at biome-discovery time. Provenance
|
|
181
|
+
* (`biome.id`, `biome.version`) is NOT a field here — the parser stamps it from
|
|
182
|
+
* the discovering biome's `xema-biome.json`. Authors do not declare provenance
|
|
183
|
+
* inline.
|
|
184
|
+
*
|
|
185
|
+
* The descriptor is pure DATA: it declares WHERE the data comes from
|
|
186
|
+
* (`fetch`), HOW OFTEN to pull it (`cadence`), HOW to detect change
|
|
187
|
+
* (`changeDetection`), WHERE records land (`catalog`), and OPTIONALLY how to
|
|
188
|
+
* extract records from the fetched body (`recordSelector`). It never carries
|
|
189
|
+
* transform/mint code and never carries a secret.
|
|
190
|
+
*
|
|
191
|
+
* Validation is fail-fast: a contribution that violates any constraint is
|
|
192
|
+
* rejected at boot. No silent coercion.
|
|
193
|
+
*/
|
|
194
|
+
export interface IngestionSourceContributionManifest {
|
|
195
|
+
/** Stable identifier for this source within its owning biome. ≤ 200 chars. */
|
|
196
|
+
readonly sourceKey: string;
|
|
197
|
+
/** Human-readable source title. ≤ 200 chars. */
|
|
198
|
+
readonly title: string;
|
|
199
|
+
/** Optional one-line summary. ≤ 1000 chars. */
|
|
200
|
+
readonly summary?: string;
|
|
201
|
+
/** WHERE the data comes from and HOW to request it. */
|
|
202
|
+
readonly fetch: IngestionFetchSpec;
|
|
203
|
+
/** HOW OFTEN the source is pulled. */
|
|
204
|
+
readonly cadence: IngestionCadenceSpec;
|
|
205
|
+
/** HOW the puller decides a resource changed since the last pull. */
|
|
206
|
+
readonly changeDetection: IngestionChangeDetectionSpec;
|
|
207
|
+
/** WHERE pulled records land and how they are tagged for provenance. */
|
|
208
|
+
readonly catalog: IngestionCatalogSpec;
|
|
209
|
+
/**
|
|
210
|
+
* Optional JSONPath-ish selector applied to the fetched body to extract the
|
|
211
|
+
* record array. Absent ⇒ the whole body is treated as a single record.
|
|
212
|
+
* ≤ 500 chars.
|
|
213
|
+
*/
|
|
214
|
+
readonly recordSelector?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Zod validator for `IngestionSourceContributionManifest`. The biome-discovery
|
|
219
|
+
* parser AND the owning ingestion service's contribution-sync handler BOTH
|
|
220
|
+
* route every candidate envelope through this schema, so a malformed
|
|
221
|
+
* contribution fails at the boundary instead of at the wire (mirrors
|
|
222
|
+
* `CapabilityContributionManifestSchema`).
|
|
223
|
+
*/
|
|
224
|
+
export const IngestionSourceContributionManifestSchema: z.ZodType<IngestionSourceContributionManifest> =
|
|
225
|
+
z.object({
|
|
226
|
+
sourceKey: z.string().min(1).max(INGESTION_SOURCE_STRING_MAX),
|
|
227
|
+
title: z.string().min(1).max(INGESTION_SOURCE_STRING_MAX),
|
|
228
|
+
summary: z.string().min(1).max(INGESTION_SOURCE_SUMMARY_MAX).optional(),
|
|
229
|
+
fetch: IngestionFetchSpecSchema,
|
|
230
|
+
cadence: IngestionCadenceSpecSchema,
|
|
231
|
+
changeDetection: IngestionChangeDetectionSpecSchema,
|
|
232
|
+
catalog: IngestionCatalogSpecSchema,
|
|
233
|
+
recordSelector: z
|
|
234
|
+
.string()
|
|
235
|
+
.min(1)
|
|
236
|
+
.max(INGESTION_SOURCE_SELECTOR_MAX)
|
|
237
|
+
.optional(),
|
|
238
|
+
}) as z.ZodType<IngestionSourceContributionManifest>;
|
|
@@ -77,6 +77,52 @@ export interface LlmGatewayErrorFrame {
|
|
|
77
77
|
error: LlmGatewayErrorPayload;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Message signatures that identify a context-window overflow when NO typed
|
|
82
|
+
* {@link LlmGatewayErrorCode} survived to the consumer.
|
|
83
|
+
*
|
|
84
|
+
* The authoritative provider-message → code classification lives in
|
|
85
|
+
* llm-gateway-api's `upstream-error-classifier.ts` (an independent submodule
|
|
86
|
+
* that cannot import this kernel package). This list is the CONSUMER-side
|
|
87
|
+
* counterpart: when an agentic runtime (e.g. OpenCode) swallows the gateway's
|
|
88
|
+
* typed code and re-surfaces only a human-readable string, this is the single
|
|
89
|
+
* place a consumer recognizes the overflow. Keep the two lists in parity when
|
|
90
|
+
* a new provider phrasing appears.
|
|
91
|
+
*/
|
|
92
|
+
export const CONTEXT_OVERFLOW_MESSAGE_PATTERNS: readonly RegExp[] = [
|
|
93
|
+
/maximum context length is \d+ tokens/i,
|
|
94
|
+
/input length and max_tokens exceed context limit/i,
|
|
95
|
+
/context_length_exceeded/i,
|
|
96
|
+
/context window/i,
|
|
97
|
+
/prompt is too long/i,
|
|
98
|
+
/reduce the length of (?:the )?messages/i,
|
|
99
|
+
/exceed(?:s|ed)?\b[^.]{0,40}\bcontext/i,
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Deterministically decide whether an error signal is a context-window
|
|
104
|
+
* overflow — the single well-named predicate every consumer uses instead of
|
|
105
|
+
* an ad-hoc string match. Prefers the TYPED code
|
|
106
|
+
* ({@link LlmGatewayErrorCode.CONTEXT_LENGTH_EXCEEDED}); falls back to the
|
|
107
|
+
* centralized {@link CONTEXT_OVERFLOW_MESSAGE_PATTERNS} ONLY when the code did
|
|
108
|
+
* not survive to the consumer (e.g. a runtime that forwards a raw message).
|
|
109
|
+
*
|
|
110
|
+
* Passing NEITHER a code nor a message returns `false` — never a silent true.
|
|
111
|
+
*/
|
|
112
|
+
export function isContextOverflowError(input: {
|
|
113
|
+
code?: string | null;
|
|
114
|
+
message?: string | null;
|
|
115
|
+
}): boolean {
|
|
116
|
+
if (input.code === LlmGatewayErrorCode.CONTEXT_LENGTH_EXCEEDED) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
const message = input.message;
|
|
120
|
+
if (typeof message !== 'string' || message.length === 0) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return CONTEXT_OVERFLOW_MESSAGE_PATTERNS.some((p) => p.test(message));
|
|
124
|
+
}
|
|
125
|
+
|
|
80
126
|
/**
|
|
81
127
|
* Type guard for {@link LlmGatewayErrorFrame}.
|
|
82
128
|
*/
|
package/src/output/index.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
14
14
|
|
|
15
15
|
export * from './lib/output-kind';
|
|
16
|
+
export * from './lib/point-of-attention';
|
|
16
17
|
export * from './lib/output-render-hint';
|
|
17
18
|
export * from './lib/output-deliverable-expectation';
|
|
18
19
|
export * from './lib/output-version-dto';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { PointOfAttention } from './point-of-attention';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* One row in the version history of an output. The Outputs panel
|
|
3
5
|
* renders a dropdown when `versions.length > 1`; clicking a non-current
|
|
@@ -18,4 +20,11 @@ export interface OutputVersionDto {
|
|
|
18
20
|
readonly producerAgentSlug: string | null;
|
|
19
21
|
/** True when this row is the latest version. Exactly one row has this set. */
|
|
20
22
|
readonly isCurrent: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Generic producer-authored highlights for THIS version — the salient
|
|
25
|
+
* things a reader should notice (an assumption, a gap, a risk). Optional
|
|
26
|
+
* extensibility escape hatch so the fixed version schema stays open without
|
|
27
|
+
* a per-domain field. Absent/empty ⇒ nothing flagged.
|
|
28
|
+
*/
|
|
29
|
+
readonly pointsOfAttention?: readonly PointOfAttention[];
|
|
21
30
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bounded maxes for the short label / longer detail strings on a point of
|
|
5
|
+
* attention. Kept small so a version row carrying a handful of them stays a
|
|
6
|
+
* cheap, list-safe payload.
|
|
7
|
+
*/
|
|
8
|
+
const POINT_OF_ATTENTION_LABEL_MAX = 200;
|
|
9
|
+
const POINT_OF_ATTENTION_DETAIL_MAX = 2000;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Severity of a {@link PointOfAttention}. Closed set — a consumer renders each
|
|
13
|
+
* value with a fixed badge/colour, so the domain must never be a free-form
|
|
14
|
+
* string.
|
|
15
|
+
*/
|
|
16
|
+
export enum PointOfAttentionSeverity {
|
|
17
|
+
/** Neutral highlight — worth surfacing, no action implied. */
|
|
18
|
+
INFO = 'info',
|
|
19
|
+
/** Something the reader should scrutinise before relying on the artifact. */
|
|
20
|
+
WARNING = 'warning',
|
|
21
|
+
/** A blocking concern — the artifact should not be trusted/acted on as-is. */
|
|
22
|
+
CRITICAL = 'critical',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const POINT_OF_ATTENTION_SEVERITY_VALUES: readonly PointOfAttentionSeverity[] =
|
|
26
|
+
[
|
|
27
|
+
PointOfAttentionSeverity.INFO,
|
|
28
|
+
PointOfAttentionSeverity.WARNING,
|
|
29
|
+
PointOfAttentionSeverity.CRITICAL,
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Zod schema for {@link PointOfAttentionSeverity}. Built from the enum so the
|
|
34
|
+
* literal list lives in exactly one place.
|
|
35
|
+
*/
|
|
36
|
+
export const PointOfAttentionSeveritySchema = z.enum(
|
|
37
|
+
POINT_OF_ATTENTION_SEVERITY_VALUES as readonly [
|
|
38
|
+
PointOfAttentionSeverity,
|
|
39
|
+
...PointOfAttentionSeverity[],
|
|
40
|
+
],
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A GENERIC "point of attention" / highlight attached to a per-version
|
|
45
|
+
* artifact. This is the deliberate extensibility escape hatch that keeps a
|
|
46
|
+
* fixed artifact schema open: a producer can flag the salient things a reader
|
|
47
|
+
* should notice (an assumption made, a gap, a risk) WITHOUT the kernel growing
|
|
48
|
+
* a domain-specific field for each. Domain-agnostic — carries only a label, a
|
|
49
|
+
* detail, and a {@link PointOfAttentionSeverity}; the meaning is the
|
|
50
|
+
* producer's, never the kernel's.
|
|
51
|
+
*/
|
|
52
|
+
export interface PointOfAttention {
|
|
53
|
+
/** Short headline for the point (≤ 200 chars). */
|
|
54
|
+
readonly label: string;
|
|
55
|
+
/** Longer human-readable explanation (≤ 2000 chars). */
|
|
56
|
+
readonly detail: string;
|
|
57
|
+
/** How much scrutiny this point warrants. */
|
|
58
|
+
readonly severity: PointOfAttentionSeverity;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Zod validator for {@link PointOfAttention}. Fail-fast: a malformed point is
|
|
63
|
+
* rejected at the boundary rather than silently coerced.
|
|
64
|
+
*/
|
|
65
|
+
export const PointOfAttentionSchema: z.ZodType<PointOfAttention> = z.object({
|
|
66
|
+
label: z.string().min(1).max(POINT_OF_ATTENTION_LABEL_MAX),
|
|
67
|
+
detail: z.string().min(1).max(POINT_OF_ATTENTION_DETAIL_MAX),
|
|
68
|
+
severity: PointOfAttentionSeveritySchema,
|
|
69
|
+
}) as z.ZodType<PointOfAttention>;
|
|
@@ -26,6 +26,35 @@ export enum WorkerRuntimeKind {
|
|
|
26
26
|
Hermes = 'hermes',
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* How a runtime consumes a per-skill "slash command" launcher file, if at
|
|
31
|
+
* all. Closed set — a runtime that grows a new command surface adds a member
|
|
32
|
+
* here and the composer/proxy switch exhaustively on it.
|
|
33
|
+
*
|
|
34
|
+
* The platform composes ONE per-skill launch command (markdown body with a
|
|
35
|
+
* `$ARGUMENTS` placeholder) so typing `/<skill>` loads + applies that skill.
|
|
36
|
+
* WHETHER and in WHICH FORMAT a runtime reads that file differs:
|
|
37
|
+
*
|
|
38
|
+
* - `Markdown` — the runtime reads markdown command files from its
|
|
39
|
+
* `commandsDir` (OpenCode: `.opencode/{command,commands}/**.md`; Claude
|
|
40
|
+
* Code: `.claude/commands/*.md`). Xema emits the launcher for these.
|
|
41
|
+
* - `Toml` — the runtime's custom commands are TOML, NOT markdown (Qwen).
|
|
42
|
+
* Xema does NOT synthesise TOML skill launchers — skills launch via the
|
|
43
|
+
* runtime's own `/skills <name>` surface / model-invoked skill tool — so
|
|
44
|
+
* the platform emits NOTHING for a TOML runtime rather than a file the
|
|
45
|
+
* runtime silently ignores.
|
|
46
|
+
* - `None` — the runtime has no file-based slash-command surface at all
|
|
47
|
+
* (Hermes: `commandsDir` is `null`). Emit nothing.
|
|
48
|
+
*
|
|
49
|
+
* Only `Markdown` runtimes receive a materialised per-skill command file;
|
|
50
|
+
* `Toml`/`None` receive none (never a stray, silently-ignored file).
|
|
51
|
+
*/
|
|
52
|
+
export enum RuntimeCommandFormat {
|
|
53
|
+
Markdown = 'markdown',
|
|
54
|
+
Toml = 'toml',
|
|
55
|
+
None = 'none',
|
|
56
|
+
}
|
|
57
|
+
|
|
29
58
|
/**
|
|
30
59
|
* Lifecycle hook surfaces that a runtime may support. The set is closed —
|
|
31
60
|
* adding a new hook is a kernel change.
|