@dcdr/contracts 1.9.6
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/LICENSE +176 -0
- package/README.md +411 -0
- package/dist/capabilities.contract.d.ts +69 -0
- package/dist/capabilities.contract.d.ts.map +1 -0
- package/dist/capabilities.contract.js +126 -0
- package/dist/control.contract.d.ts +39 -0
- package/dist/control.contract.d.ts.map +1 -0
- package/dist/control.contract.js +2 -0
- package/dist/credentials.contract.d.ts +37 -0
- package/dist/credentials.contract.d.ts.map +1 -0
- package/dist/credentials.contract.js +15 -0
- package/dist/entitlements.contract.d.ts +107 -0
- package/dist/entitlements.contract.d.ts.map +1 -0
- package/dist/entitlements.contract.js +11 -0
- package/dist/errors.contract.d.ts +47 -0
- package/dist/errors.contract.d.ts.map +1 -0
- package/dist/errors.contract.js +48 -0
- package/dist/execution.contract.d.ts +240 -0
- package/dist/execution.contract.d.ts.map +1 -0
- package/dist/execution.contract.js +22 -0
- package/dist/http.contract.d.ts +20 -0
- package/dist/http.contract.d.ts.map +1 -0
- package/dist/http.contract.js +8 -0
- package/dist/implementations.contract.d.ts +120 -0
- package/dist/implementations.contract.d.ts.map +1 -0
- package/dist/implementations.contract.js +2 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/intent.contract.d.ts +137 -0
- package/dist/intent.contract.d.ts.map +1 -0
- package/dist/intent.contract.js +76 -0
- package/dist/logs.contract.d.ts +10 -0
- package/dist/logs.contract.d.ts.map +1 -0
- package/dist/logs.contract.js +2 -0
- package/dist/messages.contract.d.ts +16 -0
- package/dist/messages.contract.d.ts.map +1 -0
- package/dist/messages.contract.js +2 -0
- package/dist/policies.contract.d.ts +253 -0
- package/dist/policies.contract.d.ts.map +1 -0
- package/dist/policies.contract.js +283 -0
- package/dist/prompt-variable-schema.contract.d.ts +75 -0
- package/dist/prompt-variable-schema.contract.d.ts.map +1 -0
- package/dist/prompt-variable-schema.contract.js +572 -0
- package/dist/prompts.contract.d.ts +97 -0
- package/dist/prompts.contract.d.ts.map +1 -0
- package/dist/prompts.contract.js +87 -0
- package/dist/provider.contract.d.ts +477 -0
- package/dist/provider.contract.d.ts.map +1 -0
- package/dist/provider.contract.js +3310 -0
- package/dist/registry.stats.contract.d.ts +39 -0
- package/dist/registry.stats.contract.d.ts.map +1 -0
- package/dist/registry.stats.contract.js +9 -0
- package/dist/runtime.client.d.ts +362 -0
- package/dist/runtime.client.d.ts.map +1 -0
- package/dist/runtime.client.js +545 -0
- package/dist/service-tokens.contract.d.ts +29 -0
- package/dist/service-tokens.contract.d.ts.map +1 -0
- package/dist/service-tokens.contract.js +10 -0
- package/dist/session.contract.d.ts +51 -0
- package/dist/session.contract.d.ts.map +1 -0
- package/dist/session.contract.js +187 -0
- package/dist/subscription.contract.d.ts +37 -0
- package/dist/subscription.contract.d.ts.map +1 -0
- package/dist/subscription.contract.js +45 -0
- package/dist/utils.contract.d.ts +21 -0
- package/dist/utils.contract.d.ts.map +1 -0
- package/dist/utils.contract.js +79 -0
- package/package.json +57 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Message } from "./messages.contract";
|
|
2
|
+
import { PromptParameters } from "./policies.contract";
|
|
3
|
+
export declare enum PromptTemplateInterpolationType {
|
|
4
|
+
/** {{var}} — Mustache style (RECOMMENDED) */
|
|
5
|
+
MUSTACHE = "MUSTACHE",
|
|
6
|
+
/** ${var} — JavaScript template literal style */
|
|
7
|
+
JS_TEMPLATE = "JS_TEMPLATE",
|
|
8
|
+
/** #var# — Simple legacy style */
|
|
9
|
+
HASH = "HASH",
|
|
10
|
+
/** <<var>> — XML / chatbot legacy style */
|
|
11
|
+
ANGLE = "ANGLE"
|
|
12
|
+
}
|
|
13
|
+
export declare enum PromptVariableType {
|
|
14
|
+
INTEGER = "integer",
|
|
15
|
+
FLOAT = "float",
|
|
16
|
+
STRING = "string",
|
|
17
|
+
BOOLEAN = "boolean",
|
|
18
|
+
JSON = "json",
|
|
19
|
+
ANY = "any",
|
|
20
|
+
ARRAY = "array",
|
|
21
|
+
OBJECT = "object",
|
|
22
|
+
ENUM = "enum"
|
|
23
|
+
}
|
|
24
|
+
export declare class PromptVariable {
|
|
25
|
+
type: PromptVariableType;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
description?: string;
|
|
28
|
+
itemsType?: PromptVariableType;
|
|
29
|
+
properties?: Record<string, PromptVariable>;
|
|
30
|
+
values?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Optional constraints:
|
|
33
|
+
* - For integer/float: min/max numeric value
|
|
34
|
+
* - For string: min/max length
|
|
35
|
+
*/
|
|
36
|
+
min?: number;
|
|
37
|
+
max?: number;
|
|
38
|
+
constructor(type: PromptVariableType, required?: boolean, description?: string, itemsType?: PromptVariableType, properties?: Record<string, PromptVariable>, values?: string[], // NEW
|
|
39
|
+
min?: number, max?: number);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A versioned prompt template.
|
|
43
|
+
* This should be stable and reproducible:
|
|
44
|
+
* - `id`, `version`, and `sha256` MUST uniquely identify the prompt content.
|
|
45
|
+
* - `semanticHash` MUST represent the semantic meaning (stable normalization).
|
|
46
|
+
* - `messages` is the canonical representation (avoid raw string prompts).
|
|
47
|
+
*/
|
|
48
|
+
export interface PromptTemplate {
|
|
49
|
+
/** Unique prompt identifier (e.g., UUID). */
|
|
50
|
+
id: string;
|
|
51
|
+
/** Human-friendly version label (e.g., "2026-02-17.1" or "v20260217.3"). */
|
|
52
|
+
version: string;
|
|
53
|
+
/** Human-readable name (e.g., "openai-format-parser"). */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Human-readable description for diagnostics. */
|
|
56
|
+
description?: string;
|
|
57
|
+
/**
|
|
58
|
+
* SHA256 hash of the canonical prompt payload (e.g., stable JSON serialization).
|
|
59
|
+
* Useful as an immutable fingerprint / audit trail.
|
|
60
|
+
*/
|
|
61
|
+
sha256: string;
|
|
62
|
+
/**
|
|
63
|
+
* Precomputed semantic hash (stable across irrelevant formatting changes).
|
|
64
|
+
* This MUST be exported from backend and used for:
|
|
65
|
+
* - problemHash (dataset dedupe)
|
|
66
|
+
* - runHash (execution dedupe)
|
|
67
|
+
*/
|
|
68
|
+
semanticHash: string;
|
|
69
|
+
/**
|
|
70
|
+
* Provider-agnostic prompt messages (with optional placeholders).
|
|
71
|
+
* This is the canonical representation.
|
|
72
|
+
*/
|
|
73
|
+
messages: Message[];
|
|
74
|
+
/**
|
|
75
|
+
* Declared variables contract (not values).
|
|
76
|
+
* Used for validation / preflight checks, not interpolation.
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Interpolation style to render placeholders in messages.
|
|
80
|
+
* Default MUST be MUSTACHE.
|
|
81
|
+
*/
|
|
82
|
+
variablesInterpolationType?: PromptTemplateInterpolationType;
|
|
83
|
+
/**
|
|
84
|
+
* Default runtime params (temperature, max_tokens, etc.).
|
|
85
|
+
* Can be overridden per request.
|
|
86
|
+
*
|
|
87
|
+
* NOTE:
|
|
88
|
+
* - AISemantics.buildRuntimeParamsKey can include these as another layer if you want:
|
|
89
|
+
* impl.runtimeConfig -> prompt.params -> model.params -> request.override
|
|
90
|
+
*/
|
|
91
|
+
params?: PromptParameters;
|
|
92
|
+
/** Optional tags for routing/diagnostics (e.g., "strict_json", "qc", "beta"). */
|
|
93
|
+
tags?: string[];
|
|
94
|
+
/** Optional metadata for audits/diagnostics. */
|
|
95
|
+
meta?: Record<string, any>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=prompts.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.contract.d.ts","sourceRoot":"","sources":["../src/prompts.contract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,oBAAY,+BAA+B;IAEvC,6CAA6C;IAC7C,QAAQ,aAAa;IAErB,iDAAiD;IACjD,WAAW,gBAAgB;IAE3B,kCAAkC;IAClC,IAAI,SAAS;IAEb,2CAA2C;IAC3C,KAAK,UAAU;CAClB;AAGD,oBAAY,kBAAkB;IAC1B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,IAAI,SAAS;CAChB;AAKD,qBAAa,cAAc;IAEvB,IAAI,EAAE,kBAAkB,CAAC;IAIzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAG/B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAM5C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;OAIG;IAGH,GAAG,CAAC,EAAE,MAAM,CAAC;IAIb,GAAG,CAAC,EAAE,MAAM,CAAC;gBAGT,IAAI,EAAE,kBAAkB,EACxB,QAAQ,GAAE,OAAe,EACzB,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,kBAAkB,EAC9B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAC3C,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM;IACzB,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM;CAWnB;AAKD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAE3B,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IAEX,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAEhB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IAEb,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,QAAQ,EAAE,OAAO,EAAE,CAAC;IAEpB;;;OAGG;IAGH;;;OAGG;IACH,0BAA0B,CAAC,EAAE,+BAA+B,CAAC;IAE7D;;;;;;;KAOC;IACD,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PromptVariable = exports.PromptVariableType = exports.PromptTemplateInterpolationType = void 0;
|
|
10
|
+
const class_validator_1 = require("class-validator");
|
|
11
|
+
var PromptTemplateInterpolationType;
|
|
12
|
+
(function (PromptTemplateInterpolationType) {
|
|
13
|
+
/** {{var}} — Mustache style (RECOMMENDED) */
|
|
14
|
+
PromptTemplateInterpolationType["MUSTACHE"] = "MUSTACHE";
|
|
15
|
+
/** ${var} — JavaScript template literal style */
|
|
16
|
+
PromptTemplateInterpolationType["JS_TEMPLATE"] = "JS_TEMPLATE";
|
|
17
|
+
/** #var# — Simple legacy style */
|
|
18
|
+
PromptTemplateInterpolationType["HASH"] = "HASH";
|
|
19
|
+
/** <<var>> — XML / chatbot legacy style */
|
|
20
|
+
PromptTemplateInterpolationType["ANGLE"] = "ANGLE";
|
|
21
|
+
})(PromptTemplateInterpolationType || (exports.PromptTemplateInterpolationType = PromptTemplateInterpolationType = {}));
|
|
22
|
+
var PromptVariableType;
|
|
23
|
+
(function (PromptVariableType) {
|
|
24
|
+
PromptVariableType["INTEGER"] = "integer";
|
|
25
|
+
PromptVariableType["FLOAT"] = "float";
|
|
26
|
+
PromptVariableType["STRING"] = "string";
|
|
27
|
+
PromptVariableType["BOOLEAN"] = "boolean";
|
|
28
|
+
PromptVariableType["JSON"] = "json";
|
|
29
|
+
PromptVariableType["ANY"] = "any";
|
|
30
|
+
PromptVariableType["ARRAY"] = "array";
|
|
31
|
+
PromptVariableType["OBJECT"] = "object";
|
|
32
|
+
PromptVariableType["ENUM"] = "enum";
|
|
33
|
+
})(PromptVariableType || (exports.PromptVariableType = PromptVariableType = {}));
|
|
34
|
+
class PromptVariable {
|
|
35
|
+
type;
|
|
36
|
+
required;
|
|
37
|
+
description;
|
|
38
|
+
itemsType;
|
|
39
|
+
properties; // NEW
|
|
40
|
+
// Enum values (only meaningful when type === "enum")
|
|
41
|
+
values;
|
|
42
|
+
/**
|
|
43
|
+
* Optional constraints:
|
|
44
|
+
* - For integer/float: min/max numeric value
|
|
45
|
+
* - For string: min/max length
|
|
46
|
+
*/
|
|
47
|
+
min;
|
|
48
|
+
max;
|
|
49
|
+
constructor(type, required = false, description, itemsType, properties, values, // NEW
|
|
50
|
+
min, max) {
|
|
51
|
+
this.type = type;
|
|
52
|
+
this.required = required;
|
|
53
|
+
this.description = description;
|
|
54
|
+
this.itemsType = itemsType;
|
|
55
|
+
this.properties = properties;
|
|
56
|
+
this.values = values;
|
|
57
|
+
this.min = min;
|
|
58
|
+
this.max = max;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.PromptVariable = PromptVariable;
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, class_validator_1.IsBoolean)(),
|
|
64
|
+
(0, class_validator_1.IsOptional)()
|
|
65
|
+
], PromptVariable.prototype, "required", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, class_validator_1.IsOptional)()
|
|
68
|
+
], PromptVariable.prototype, "description", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, class_validator_1.IsOptional)()
|
|
71
|
+
], PromptVariable.prototype, "itemsType", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, class_validator_1.IsOptional)()
|
|
74
|
+
], PromptVariable.prototype, "properties", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, class_validator_1.IsOptional)(),
|
|
77
|
+
(0, class_validator_1.IsArray)(),
|
|
78
|
+
(0, class_validator_1.IsString)({ each: true })
|
|
79
|
+
], PromptVariable.prototype, "values", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, class_validator_1.IsOptional)(),
|
|
82
|
+
(0, class_validator_1.IsNumber)()
|
|
83
|
+
], PromptVariable.prototype, "min", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, class_validator_1.IsOptional)(),
|
|
86
|
+
(0, class_validator_1.IsNumber)()
|
|
87
|
+
], PromptVariable.prototype, "max", void 0);
|
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { ImplementationContract } from "./implementations.contract";
|
|
2
|
+
import { Message } from "./messages.contract";
|
|
3
|
+
import { Intent, IntentContract, IntentType } from "./intent.contract";
|
|
4
|
+
import { PromptParameters } from "./policies.contract";
|
|
5
|
+
import { PromptTemplate } from "./prompts.contract";
|
|
6
|
+
import { CredentialsContract } from "./credentials.contract";
|
|
7
|
+
/**
|
|
8
|
+
* Supported provider backends capable of executing an intent.
|
|
9
|
+
*
|
|
10
|
+
* These represent the underlying execution engines used by the runtime.
|
|
11
|
+
* A provider may represent:
|
|
12
|
+
*
|
|
13
|
+
* - A hosted LLM service (OpenAI, Gemini, Grok, etc.)
|
|
14
|
+
* - A local inference runtime (OFFICE, OLLAMA, VLLM)
|
|
15
|
+
* - A specialized processing engine (OCR, CLIP)
|
|
16
|
+
* - An internal execution system (RULES, HTTP_TOOL)
|
|
17
|
+
*/
|
|
18
|
+
export declare enum IntentProvider {
|
|
19
|
+
/**
|
|
20
|
+
* Virtual provider managed by DCDR.
|
|
21
|
+
*
|
|
22
|
+
* Notes
|
|
23
|
+
* - Cloud-only concept: the registry/runtime can resolve the underlying real provider (OpenAI/Anthropic/Gemini/Office).
|
|
24
|
+
* - Model IDs are namespaced as `provider/model` (e.g. `openai/gpt-4o-mini`) for deterministic resolution.
|
|
25
|
+
*/
|
|
26
|
+
DCDR = "DCDR",
|
|
27
|
+
/** OpenAI hosted models (GPT family, embeddings, etc.) */
|
|
28
|
+
OPEN_AI = "OPEN_AI",
|
|
29
|
+
/** Google Gemini models */
|
|
30
|
+
GEMINI = "GEMINI",
|
|
31
|
+
/** xAI Grok models */
|
|
32
|
+
GROK = "GROK",
|
|
33
|
+
/** Anthropic Claude models */
|
|
34
|
+
ANTHROPIC = "ANTHROPIC",
|
|
35
|
+
/** Mistral hosted models */
|
|
36
|
+
MISTRAL = "MISTRAL",
|
|
37
|
+
/** Cohere models (chat + embeddings) */
|
|
38
|
+
COHERE = "COHERE",
|
|
39
|
+
/**
|
|
40
|
+
* Local inference runtime hosted internally (runtime-managed).
|
|
41
|
+
*
|
|
42
|
+
* Notes
|
|
43
|
+
* - Use this when the runtime/operator controls the endpoint (e.g. office GPU cluster running vLLM).
|
|
44
|
+
* - If a customer wants to plug in their own OpenAI-compatible endpoint, use OPEN_AI_COMPATIBLE.
|
|
45
|
+
*/
|
|
46
|
+
OFFICE = "OFFICE",
|
|
47
|
+
/**
|
|
48
|
+
* Ollama local inference runtime.
|
|
49
|
+
* Useful for developer setups and local deployments.
|
|
50
|
+
*/
|
|
51
|
+
OLLAMA = "OLLAMA",
|
|
52
|
+
/**
|
|
53
|
+
* Generic OpenAI-compatible endpoint (bring-your-own).
|
|
54
|
+
*
|
|
55
|
+
* Goal
|
|
56
|
+
* - Allow customers to plug in internal systems that expose an OpenAI-style API.
|
|
57
|
+
*
|
|
58
|
+
* Examples
|
|
59
|
+
* - vLLM, TGI, LM Studio, or custom gateways that mimic the OpenAI schema.
|
|
60
|
+
*/
|
|
61
|
+
OPEN_AI_COMPATIBLE = "OPEN_AI_COMPATIBLE",
|
|
62
|
+
/**
|
|
63
|
+
* Optical character recognition engine.
|
|
64
|
+
*/
|
|
65
|
+
OCR = "OCR",
|
|
66
|
+
/**
|
|
67
|
+
* CLIP-like models for multimodal embedding.
|
|
68
|
+
*/
|
|
69
|
+
CLIP = "CLIP",
|
|
70
|
+
/**
|
|
71
|
+
* Generic HTTP tool provider.
|
|
72
|
+
* Used to call external APIs or services.
|
|
73
|
+
*/
|
|
74
|
+
HTTP_TOOL = "HTTP_TOOL",
|
|
75
|
+
/**
|
|
76
|
+
* Internal rule-based execution engine.
|
|
77
|
+
* Used for deterministic logic instead of LLMs.
|
|
78
|
+
*/
|
|
79
|
+
RULES = "RULES"
|
|
80
|
+
}
|
|
81
|
+
export type ProviderExecuteArgs = {
|
|
82
|
+
intent: Intent;
|
|
83
|
+
implementation: ImplementationContract;
|
|
84
|
+
credentials: CredentialsContract | null;
|
|
85
|
+
prompt: PromptTemplate;
|
|
86
|
+
renderedMessages: Message[];
|
|
87
|
+
vars: Record<string, unknown>;
|
|
88
|
+
/**
|
|
89
|
+
* If provided, this is what will be sent to the provider.
|
|
90
|
+
*/
|
|
91
|
+
runtimeConfig?: PromptParameters;
|
|
92
|
+
/**
|
|
93
|
+
* ✅ Attempt timeout controlled by run policy.
|
|
94
|
+
*/
|
|
95
|
+
attemptTimeoutMs?: number;
|
|
96
|
+
/**
|
|
97
|
+
* ✅ Optional model contract for schemas, tool configs, etc.
|
|
98
|
+
* If you don't want to pass the whole model, pass outputSchema only.
|
|
99
|
+
*/
|
|
100
|
+
model?: IntentContract | null;
|
|
101
|
+
/** The hash of the problem associated with this execution. */
|
|
102
|
+
problemHash: string | null;
|
|
103
|
+
/** The hash of the run associated with this execution. */
|
|
104
|
+
runHash: string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Optional tenant/customer id to scope runtime-side caches and circuit breakers.
|
|
107
|
+
*
|
|
108
|
+
* Notes
|
|
109
|
+
* - When omitted, the runtime will treat it as internal/default scope.
|
|
110
|
+
*/
|
|
111
|
+
tenantCid?: string;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* The result of executing a provider call.
|
|
115
|
+
* This is what ProviderExecutor returns to ExecutionService, which later writes it to AICallLog.
|
|
116
|
+
*/
|
|
117
|
+
export type ProviderExecuteResult = {
|
|
118
|
+
output: unknown;
|
|
119
|
+
cached: boolean;
|
|
120
|
+
usage?: {
|
|
121
|
+
promptTokens?: number;
|
|
122
|
+
completionTokens?: number;
|
|
123
|
+
totalTokens?: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Pricing metadata shared across different pricing components.
|
|
128
|
+
*/
|
|
129
|
+
export interface ProviderPricingMeta {
|
|
130
|
+
currency: "USD" | "EURO" | "GBP" | string;
|
|
131
|
+
/** Optional URL to the provider pricing page used as the source. */
|
|
132
|
+
sourceUrl?: string;
|
|
133
|
+
/** Timestamp (ms) indicating when this pricing snapshot was last updated. */
|
|
134
|
+
updatedAt: number;
|
|
135
|
+
/** How confident this data is (design-time friendly). */
|
|
136
|
+
confidence?: "official" | "approx" | "unknown";
|
|
137
|
+
notes?: string;
|
|
138
|
+
}
|
|
139
|
+
export type ProviderPricingComponent = {
|
|
140
|
+
kind: "tokens";
|
|
141
|
+
unit: "per_million_tokens";
|
|
142
|
+
input: number;
|
|
143
|
+
outputUsd: number;
|
|
144
|
+
cachedInput?: number;
|
|
145
|
+
cachedOutput?: number;
|
|
146
|
+
/** Optional tiered pricing (e.g. different rates by modality or prompt size). */
|
|
147
|
+
tiers?: Array<{
|
|
148
|
+
name: string;
|
|
149
|
+
condition?: string;
|
|
150
|
+
input: number;
|
|
151
|
+
output: number;
|
|
152
|
+
cachedInput?: number;
|
|
153
|
+
cachedOutput?: number;
|
|
154
|
+
}>;
|
|
155
|
+
notes?: string;
|
|
156
|
+
} | {
|
|
157
|
+
kind: "characters";
|
|
158
|
+
unit: "per_million_characters";
|
|
159
|
+
input: number;
|
|
160
|
+
notes?: string;
|
|
161
|
+
} | {
|
|
162
|
+
kind: "audio_minutes";
|
|
163
|
+
unit: "per_minute";
|
|
164
|
+
input: number;
|
|
165
|
+
output?: number;
|
|
166
|
+
notes?: string;
|
|
167
|
+
} | {
|
|
168
|
+
kind: "images";
|
|
169
|
+
unit: "per_image";
|
|
170
|
+
input?: number;
|
|
171
|
+
output?: number;
|
|
172
|
+
notes?: string;
|
|
173
|
+
} | {
|
|
174
|
+
kind: "video_seconds";
|
|
175
|
+
unit: "per_second";
|
|
176
|
+
input?: number;
|
|
177
|
+
output?: number;
|
|
178
|
+
notes?: string;
|
|
179
|
+
} | {
|
|
180
|
+
kind: "pages";
|
|
181
|
+
unit: "per_1000_pages";
|
|
182
|
+
input: number;
|
|
183
|
+
notes?: string;
|
|
184
|
+
};
|
|
185
|
+
/** Unified pricing for a model: composed of 1..N pricing components. */
|
|
186
|
+
export interface ProviderModelPricing extends ProviderPricingMeta {
|
|
187
|
+
components: ProviderPricingComponent[];
|
|
188
|
+
}
|
|
189
|
+
/** Runtime-level support status for a (provider, modelId) pair. */
|
|
190
|
+
export declare enum ProviderModelRuntimeSupportStatus {
|
|
191
|
+
/** Supported by this runtime (intended to work). */
|
|
192
|
+
SUPPORTED = "SUPPORTED",
|
|
193
|
+
/** Explicitly not supported by this runtime (do not attempt provider calls). */
|
|
194
|
+
NOT_SUPPORTED = "NOT_SUPPORTED",
|
|
195
|
+
/** Known failing in current runtime; keep visible but treat as unstable. */
|
|
196
|
+
FAILING = "FAILING",
|
|
197
|
+
/** Under active work; may be partially implemented. */
|
|
198
|
+
IN_PROGRESS = "IN_PROGRESS"
|
|
199
|
+
}
|
|
200
|
+
/** Preferred upstream API surface for this model (when provider offers multiple). */
|
|
201
|
+
export declare enum ProviderModelPreferredApi {
|
|
202
|
+
CHAT_COMPLETIONS = "CHAT_COMPLETIONS",
|
|
203
|
+
RESPONSES = "RESPONSES"
|
|
204
|
+
}
|
|
205
|
+
/** Generic prompt/runtime parameter keys that can be exposed to users (UI) and adapters. */
|
|
206
|
+
export declare enum PromptParameterKey {
|
|
207
|
+
TEMPERATURE = "temperature",
|
|
208
|
+
TOP_P = "top_p",
|
|
209
|
+
TOP_K = "top_k",
|
|
210
|
+
MAX_TOKENS = "max_tokens",
|
|
211
|
+
SEED = "seed",
|
|
212
|
+
ENABLE_THINKING = "enable_thinking",
|
|
213
|
+
RESPONSE_FORMAT = "response_format",
|
|
214
|
+
PRESENCE_PENALTY = "presence_penalty",
|
|
215
|
+
FREQUENCY_PENALTY = "frequency_penalty"
|
|
216
|
+
}
|
|
217
|
+
/** Runtime-level parameter support status for a specific model. */
|
|
218
|
+
export declare enum ProviderModelParameterSupportStatus {
|
|
219
|
+
/** Parameter is supported and may be used. */
|
|
220
|
+
SUPPORTED = "SUPPORTED",
|
|
221
|
+
/** Parameter is not supported and should not be sent. */
|
|
222
|
+
NOT_SUPPORTED = "NOT_SUPPORTED",
|
|
223
|
+
/** Only provider default is supported; runtime should avoid sending custom values. */
|
|
224
|
+
DEFAULT_ONLY = "DEFAULT_ONLY"
|
|
225
|
+
}
|
|
226
|
+
/** Optional parameter support metadata attached to a model definition (for UI and adapter normalization). */
|
|
227
|
+
export interface ProviderModelParameterSupportInfo {
|
|
228
|
+
/** Per-parameter support mapping. Omitted keys mean "unknown" (use adapter defaults). */
|
|
229
|
+
parameters?: Partial<Record<PromptParameterKey, ProviderModelParameterSupportStatus>>;
|
|
230
|
+
/** Optional recommendations to avoid common misconfiguration. */
|
|
231
|
+
recommended?: {
|
|
232
|
+
/** Recommended minimum `max_tokens` to avoid empty/reasoning-only outputs on some models. */
|
|
233
|
+
minMaxTokens?: number;
|
|
234
|
+
};
|
|
235
|
+
/** Human-readable notes (safe for UI/logs). */
|
|
236
|
+
notes?: string;
|
|
237
|
+
/** ISO date string of last verification (e.g. from E2E/probes). */
|
|
238
|
+
updatedAt?: string;
|
|
239
|
+
}
|
|
240
|
+
/** Optional runtime support metadata attached to a model definition. */
|
|
241
|
+
export interface ProviderModelRuntimeSupportInfo {
|
|
242
|
+
status: ProviderModelRuntimeSupportStatus;
|
|
243
|
+
preferredApi?: ProviderModelPreferredApi;
|
|
244
|
+
/** Human-readable notes (safe for logs/CI). */
|
|
245
|
+
reason?: string;
|
|
246
|
+
/** ISO date string of last verification (e.g. from E2E/probes). */
|
|
247
|
+
updatedAt?: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Product-level managed categories for public customer models.
|
|
251
|
+
*
|
|
252
|
+
* Purpose
|
|
253
|
+
* - Provide a stable grouping/filtering abstraction for customer-facing UIs.
|
|
254
|
+
* - Avoid exposing a flat provider/model list by default.
|
|
255
|
+
*/
|
|
256
|
+
export declare enum DcdrPublicModelCategory {
|
|
257
|
+
/** Maximum quality / strongest reasoning; typically expensive. */
|
|
258
|
+
BEST = "BEST",
|
|
259
|
+
/** Best balance between quality and cost; recommended default for production chat. */
|
|
260
|
+
SMART = "SMART",
|
|
261
|
+
/** Low latency; good for interactive chat/support. */
|
|
262
|
+
FAST = "FAST",
|
|
263
|
+
/** Lowest cost; good for high-volume simple tasks. */
|
|
264
|
+
ECONOMY = "ECONOMY",
|
|
265
|
+
/** Internal/local/company-managed models (self-hosted, Office, etc.). */
|
|
266
|
+
PRIVATE = "PRIVATE"
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Canonical (de-duplicated) model definition.
|
|
270
|
+
*
|
|
271
|
+
* A single model can support multiple IntentType(s). Keeping the model metadata in one place
|
|
272
|
+
* avoids duplicating fields like cost/capabilities across multiple per-type listings.
|
|
273
|
+
*/
|
|
274
|
+
export interface ProviderModelDefinition {
|
|
275
|
+
id: string;
|
|
276
|
+
types: IntentType[];
|
|
277
|
+
/**
|
|
278
|
+
* If true, this model is eligible for customer-facing UIs.
|
|
279
|
+
*
|
|
280
|
+
* Notes
|
|
281
|
+
* - Fail-closed: missing/undefined is treated as false by the catalog normalizer.
|
|
282
|
+
* - This does not affect runtime execution support; it is a UI curation flag.
|
|
283
|
+
*/
|
|
284
|
+
publicForCustomers: boolean;
|
|
285
|
+
/** Stable customer-facing family name for managed public models (should not expose provider/model IDs). */
|
|
286
|
+
publicName?: string;
|
|
287
|
+
/** Small variant label displayed next to `publicName` (e.g. "OpenAI", "Fast", "Lowest cost"). */
|
|
288
|
+
badge?: string;
|
|
289
|
+
/** Primary managed category used for default grouping in simple UI mode. */
|
|
290
|
+
primaryCategory?: DcdrPublicModelCategory;
|
|
291
|
+
/** Additional managed categories/tags for badges and advanced filtering. */
|
|
292
|
+
categories?: DcdrPublicModelCategory[];
|
|
293
|
+
/** Quality tier (1..5), where 5 is best. */
|
|
294
|
+
qualityTier?: number;
|
|
295
|
+
/** Speed tier (1..5), where 5 is best. */
|
|
296
|
+
speedTier?: number;
|
|
297
|
+
/** Cost tier (1..5), where 5 is best (lowest cost). */
|
|
298
|
+
costTier?: number;
|
|
299
|
+
/** Optional suggested use cases (safe for UI). */
|
|
300
|
+
recommendedUseCases?: string[];
|
|
301
|
+
/** Model is generally recommended to customers. */
|
|
302
|
+
isRecommended?: boolean;
|
|
303
|
+
/** Global default model when the user has not chosen any model/category. Exactly one public model should be true. */
|
|
304
|
+
isGlobalDefault?: boolean;
|
|
305
|
+
/** Default model within its primaryCategory when a category is chosen but no specific model is selected. */
|
|
306
|
+
isCategoryDefault?: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* When true, this model has been verified (via E2E) to return token usage (`promptTokens`/`completionTokens`/`totalTokens`)
|
|
309
|
+
* in the runtime execution report.
|
|
310
|
+
*
|
|
311
|
+
* Notes
|
|
312
|
+
* - This is a billing invariant: public customer models must have token usage tracking.
|
|
313
|
+
* - Missing/undefined is treated as false (fail-closed).
|
|
314
|
+
*/
|
|
315
|
+
tokenUsageCovered?: boolean;
|
|
316
|
+
pricing?: ProviderModelPricing;
|
|
317
|
+
runtimeSupport?: ProviderModelRuntimeSupportInfo;
|
|
318
|
+
parameterSupport?: ProviderModelParameterSupportInfo;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Stricter shape for public customer models.
|
|
322
|
+
*
|
|
323
|
+
* Notes
|
|
324
|
+
* - This is an additive (non-breaking) interface.
|
|
325
|
+
* - The catalog normalizer enforces these fields at runtime for models where `publicForCustomers === true`.
|
|
326
|
+
*/
|
|
327
|
+
export interface ProviderPublicCustomerModelDefinition extends ProviderModelDefinition {
|
|
328
|
+
publicForCustomers: true;
|
|
329
|
+
publicName: string;
|
|
330
|
+
badge?: string;
|
|
331
|
+
tokenUsageCovered: boolean;
|
|
332
|
+
primaryCategory: DcdrPublicModelCategory;
|
|
333
|
+
categories: DcdrPublicModelCategory[];
|
|
334
|
+
qualityTier: number;
|
|
335
|
+
speedTier: number;
|
|
336
|
+
costTier: number;
|
|
337
|
+
recommendedUseCases: string[];
|
|
338
|
+
isRecommended: boolean;
|
|
339
|
+
isGlobalDefault: boolean;
|
|
340
|
+
isCategoryDefault: boolean;
|
|
341
|
+
}
|
|
342
|
+
/** Options for ProviderModelRegistry.listProviderModels(...). */
|
|
343
|
+
export interface ProviderModelListProviderModelsOptions {
|
|
344
|
+
/** When true, only returns models explicitly curated for customer-facing UIs. */
|
|
345
|
+
onlyPublicForCustomers?: boolean;
|
|
346
|
+
}
|
|
347
|
+
/** Provider + model pairing for public customer model listing helpers. */
|
|
348
|
+
export interface ProviderPublicCustomerModelRef {
|
|
349
|
+
provider: IntentProvider;
|
|
350
|
+
modelId: string;
|
|
351
|
+
model: ProviderPublicCustomerModelDefinition;
|
|
352
|
+
}
|
|
353
|
+
/** Options for ProviderModelRegistry.listPublicCustomerModels(...). */
|
|
354
|
+
export interface ProviderModelListPublicCustomerModelsOptions {
|
|
355
|
+
/** Optional filter: only include models whose primaryCategory matches this value. */
|
|
356
|
+
primaryCategory?: DcdrPublicModelCategory;
|
|
357
|
+
/** Optional filter: only include models that contain at least one of these categories. */
|
|
358
|
+
includeCategories?: DcdrPublicModelCategory[];
|
|
359
|
+
}
|
|
360
|
+
export interface DcdrVirtualModelResolution {
|
|
361
|
+
provider: IntentProvider;
|
|
362
|
+
modelId: string;
|
|
363
|
+
prefixedModelId: string;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Formats a DCDR virtual provider model id as `provider/model`.
|
|
367
|
+
*
|
|
368
|
+
* Returns an empty string for unsupported provider prefixes.
|
|
369
|
+
*/
|
|
370
|
+
export declare function formatDcdrVirtualModelId(provider: IntentProvider, modelId: string): string;
|
|
371
|
+
/**
|
|
372
|
+
* Parses a DCDR virtual provider model id of the form `provider/model`.
|
|
373
|
+
*
|
|
374
|
+
* Returns null when the id is not a valid DCDR virtual model id.
|
|
375
|
+
*/
|
|
376
|
+
export declare function parseDcdrVirtualModelId(prefixedModelId: string): DcdrVirtualModelResolution | null;
|
|
377
|
+
/**
|
|
378
|
+
* Canonical provider model catalog (after enrichment passes).
|
|
379
|
+
*/
|
|
380
|
+
export declare const PROVIDER_MODEL_DEFINITIONS_BY_PROVIDER: Record<IntentProvider, ProviderModelDefinition[]>;
|
|
381
|
+
/**
|
|
382
|
+
* Canonical lookup: provider -> modelId -> model definition.
|
|
383
|
+
*/
|
|
384
|
+
export declare const PROVIDER_MODEL_CATALOG: Record<IntentProvider, Record<string, ProviderModelDefinition>>;
|
|
385
|
+
/**
|
|
386
|
+
* Primary listing structure (no duplicated metadata): provider -> intent type -> model IDs.
|
|
387
|
+
*/
|
|
388
|
+
export declare const PROVIDER_MODEL_IDS_BY_PROVIDER_AND_TYPE: Record<IntentProvider, Record<IntentType, string[]>>;
|
|
389
|
+
/**
|
|
390
|
+
* E2E model status used by provider test suites.
|
|
391
|
+
*
|
|
392
|
+
* Notes
|
|
393
|
+
* - This is an opt-in testing mechanism; it does not affect runtime behavior.
|
|
394
|
+
* - Use `LEGACY` to explicitly skip obsolete/retired model IDs while still keeping them
|
|
395
|
+
* discoverable in the catalog for historical compatibility.
|
|
396
|
+
*/
|
|
397
|
+
export declare enum ProviderModelE2EStatus {
|
|
398
|
+
/** Model should be exercised by E2E suites (when provider is implemented and credentials exist). */
|
|
399
|
+
ACTIVE = "ACTIVE",
|
|
400
|
+
/** Model is considered legacy/obsolete and may be skipped by E2E suites. */
|
|
401
|
+
LEGACY = "LEGACY"
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Per-model E2E override metadata.
|
|
405
|
+
*/
|
|
406
|
+
export interface ProviderModelE2EOverride {
|
|
407
|
+
status: ProviderModelE2EStatus;
|
|
408
|
+
/** Human-readable skip rationale (keep short; safe for CI logs). */
|
|
409
|
+
reason: string;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Optional provider-model overrides consumed by the provider E2E matrix tests.
|
|
413
|
+
*
|
|
414
|
+
* How to use
|
|
415
|
+
* - When a model ID becomes obsolete/retired, mark it as `LEGACY` with a reason.
|
|
416
|
+
* - The E2E suite will still enumerate it (catalog stays complete) but will skip execution.
|
|
417
|
+
*/
|
|
418
|
+
export declare const PROVIDER_MODEL_E2E_OVERRIDES: Record<IntentProvider, Record<string, ProviderModelE2EOverride>>;
|
|
419
|
+
/**
|
|
420
|
+
* Static utility class for querying the provider model catalog.
|
|
421
|
+
*
|
|
422
|
+
* Designed for client consumption: `ProviderModelRegistry.listProvidersSupportingType(...)`.
|
|
423
|
+
*/
|
|
424
|
+
export declare class ProviderModelRegistry {
|
|
425
|
+
/** Canonical catalog view: provider -> modelId -> definition. */
|
|
426
|
+
static readonly catalog: Record<IntentProvider, Record<string, ProviderModelDefinition>>;
|
|
427
|
+
/** Primary listing view: provider -> intent type -> model IDs. */
|
|
428
|
+
static readonly idsByProviderAndType: Record<IntentProvider, Record<IntentType, string[]>>;
|
|
429
|
+
/** Source-of-truth definitions in declared order (useful for UI display). */
|
|
430
|
+
static readonly definitionsByProvider: Record<IntentProvider, ProviderModelDefinition[]>;
|
|
431
|
+
/** Returns the model definition if present; otherwise null. */
|
|
432
|
+
static getModelDefinition(provider: IntentProvider, modelId: string): ProviderModelDefinition | null;
|
|
433
|
+
/** Lists all model IDs for a provider (stable order as declared in the catalog). */
|
|
434
|
+
static listProviderModelIds(provider: IntentProvider): string[];
|
|
435
|
+
/** Lists all model definitions for a provider (stable order as declared in the catalog). */
|
|
436
|
+
static listProviderModels(provider: IntentProvider, options?: ProviderModelListProviderModelsOptions): ProviderModelDefinition[];
|
|
437
|
+
/**
|
|
438
|
+
* Lists all public customer models across all providers.
|
|
439
|
+
*
|
|
440
|
+
* Notes
|
|
441
|
+
* - Uses the catalog declared order (provider order, then per-provider declaration order).
|
|
442
|
+
* - This is a UI/helper surface only; execution still uses provider+modelId.
|
|
443
|
+
*/
|
|
444
|
+
static listPublicCustomerModels(options?: ProviderModelListPublicCustomerModelsOptions): ProviderPublicCustomerModelRef[];
|
|
445
|
+
/**
|
|
446
|
+
* Groups all public customer models by their primaryCategory.
|
|
447
|
+
*
|
|
448
|
+
* Intended for the "simple UI" mode where the UI shows high-level DCDR groups.
|
|
449
|
+
*/
|
|
450
|
+
static listPublicCustomerModelsByPrimaryCategory(): Record<DcdrPublicModelCategory, ProviderPublicCustomerModelRef[]>;
|
|
451
|
+
/** Lists model IDs for a provider that support a given IntentType. */
|
|
452
|
+
static listProviderModelIdsForType(provider: IntentProvider, type: IntentType): string[];
|
|
453
|
+
/** Lists model definitions for a provider that support a given IntentType. */
|
|
454
|
+
static listProviderModelsForType(provider: IntentProvider, type: IntentType): ProviderModelDefinition[];
|
|
455
|
+
/** Returns true if the provider has at least one model for the given IntentType. */
|
|
456
|
+
static providerSupportsType(provider: IntentProvider, type: IntentType): boolean;
|
|
457
|
+
/** Returns true if the model supports the given IntentType (based on the catalog). */
|
|
458
|
+
static modelSupportsType(provider: IntentProvider, modelId: string, type: IntentType): boolean;
|
|
459
|
+
/** Lists all providers that have at least one model supporting the given IntentType. */
|
|
460
|
+
static listProvidersSupportingType(type: IntentType): IntentProvider[];
|
|
461
|
+
/** Returns all model IDs across all providers for a given type. */
|
|
462
|
+
static listAllModelIdsForType(type: IntentType): Array<{
|
|
463
|
+
provider: IntentProvider;
|
|
464
|
+
modelId: string;
|
|
465
|
+
}>;
|
|
466
|
+
/** Convenience: get unified pricing if present (or null if not set/unknown). */
|
|
467
|
+
static getModelPricing(provider: IntentProvider, modelId: string): ProviderModelPricing | null;
|
|
468
|
+
/** Get a specific pricing component from a model by kind (or null if absent). */
|
|
469
|
+
static getPricingComponent<TKind extends ProviderPricingComponent["kind"]>(provider: IntentProvider, modelId: string, kind: TKind): Extract<ProviderPricingComponent, {
|
|
470
|
+
kind: TKind;
|
|
471
|
+
}> | null;
|
|
472
|
+
/** Convenience: token pricing (per MTok) if present. */
|
|
473
|
+
static getTokenPricing(provider: IntentProvider, modelId: string): Extract<ProviderPricingComponent, {
|
|
474
|
+
kind: "tokens";
|
|
475
|
+
}> | null;
|
|
476
|
+
}
|
|
477
|
+
//# sourceMappingURL=provider.contract.d.ts.map
|