@victframework/runtime 0.1.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-governance.d.ts +285 -0
- package/dist/agent-governance.js +438 -0
- package/dist/agent-governance.js.map +1 -0
- package/dist/agent-registry.d.ts +103 -0
- package/dist/agent-registry.js +758 -0
- package/dist/agent-registry.js.map +1 -0
- package/dist/agent-types.d.ts +433 -0
- package/dist/agent-types.js +480 -0
- package/dist/agent-types.js.map +1 -0
- package/dist/authority.d.ts +83 -0
- package/dist/authority.js +170 -0
- package/dist/authority.js.map +1 -0
- package/dist/boundary-conformance.d.ts +51 -0
- package/dist/boundary-conformance.js +364 -0
- package/dist/boundary-conformance.js.map +1 -0
- package/dist/control-conformance.d.ts +68 -0
- package/dist/control-conformance.js +1131 -0
- package/dist/control-conformance.js.map +1 -0
- package/dist/control-in-memory.d.ts +257 -0
- package/dist/control-in-memory.js +886 -0
- package/dist/control-in-memory.js.map +1 -0
- package/dist/control-types.d.ts +1017 -0
- package/dist/control-types.js +779 -0
- package/dist/control-types.js.map +1 -0
- package/dist/durable-run.d.ts +73 -0
- package/dist/durable-run.js +262 -0
- package/dist/durable-run.js.map +1 -0
- package/dist/effect-policy.d.ts +22 -0
- package/dist/effect-policy.js +45 -0
- package/dist/effect-policy.js.map +1 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.js +71 -0
- package/dist/errors.js.map +1 -0
- package/dist/in-memory-stores.d.ts +16 -0
- package/dist/in-memory-stores.js +522 -0
- package/dist/in-memory-stores.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/operator-config.d.ts +141 -0
- package/dist/operator-config.js +289 -0
- package/dist/operator-config.js.map +1 -0
- package/dist/orchestration-activation.d.ts +116 -0
- package/dist/orchestration-activation.js +223 -0
- package/dist/orchestration-activation.js.map +1 -0
- package/dist/orchestration-canary-conformance.d.ts +10 -0
- package/dist/orchestration-canary-conformance.js +726 -0
- package/dist/orchestration-canary-conformance.js.map +1 -0
- package/dist/orchestration-commands.d.ts +47 -0
- package/dist/orchestration-commands.js +538 -0
- package/dist/orchestration-commands.js.map +1 -0
- package/dist/orchestration-conformance.d.ts +59 -0
- package/dist/orchestration-conformance.js +594 -0
- package/dist/orchestration-conformance.js.map +1 -0
- package/dist/orchestration-driver-types.d.ts +163 -0
- package/dist/orchestration-driver-types.js +21 -0
- package/dist/orchestration-driver-types.js.map +1 -0
- package/dist/orchestration-driver.d.ts +48 -0
- package/dist/orchestration-driver.js +1030 -0
- package/dist/orchestration-driver.js.map +1 -0
- package/dist/orchestration-in-memory.d.ts +18 -0
- package/dist/orchestration-in-memory.js +1313 -0
- package/dist/orchestration-in-memory.js.map +1 -0
- package/dist/orchestration-join-conformance.d.ts +20 -0
- package/dist/orchestration-join-conformance.js +542 -0
- package/dist/orchestration-join-conformance.js.map +1 -0
- package/dist/orchestration-plan.d.ts +52 -0
- package/dist/orchestration-plan.js +265 -0
- package/dist/orchestration-plan.js.map +1 -0
- package/dist/orchestration-race-conformance.d.ts +35 -0
- package/dist/orchestration-race-conformance.js +1265 -0
- package/dist/orchestration-race-conformance.js.map +1 -0
- package/dist/orchestration-remediation-conformance.d.ts +54 -0
- package/dist/orchestration-remediation-conformance.js +632 -0
- package/dist/orchestration-remediation-conformance.js.map +1 -0
- package/dist/orchestration-store-types.d.ts +568 -0
- package/dist/orchestration-store-types.js +2 -0
- package/dist/orchestration-store-types.js.map +1 -0
- package/dist/pack-conformance.d.ts +59 -0
- package/dist/pack-conformance.js +222 -0
- package/dist/pack-conformance.js.map +1 -0
- package/dist/pack-install.d.ts +44 -0
- package/dist/pack-install.js +126 -0
- package/dist/pack-install.js.map +1 -0
- package/dist/registry.d.ts +107 -0
- package/dist/registry.js +481 -0
- package/dist/registry.js.map +1 -0
- package/dist/runtime.d.ts +158 -0
- package/dist/runtime.js +1341 -0
- package/dist/runtime.js.map +1 -0
- package/dist/serialization.d.ts +26 -0
- package/dist/serialization.js +162 -0
- package/dist/serialization.js.map +1 -0
- package/dist/store-conformance.d.ts +45 -0
- package/dist/store-conformance.js +876 -0
- package/dist/store-conformance.js.map +1 -0
- package/dist/store-errors.d.ts +49 -0
- package/dist/store-errors.js +48 -0
- package/dist/store-errors.js.map +1 -0
- package/dist/store-types.d.ts +331 -0
- package/dist/store-types.js +14 -0
- package/dist/store-types.js.map +1 -0
- package/dist/store-validation.d.ts +63 -0
- package/dist/store-validation.js +164 -0
- package/dist/store-validation.js.map +1 -0
- package/dist/stream-hub.d.ts +151 -0
- package/dist/stream-hub.js +402 -0
- package/dist/stream-hub.js.map +1 -0
- package/dist/testing.d.ts +25 -0
- package/dist/testing.js +19 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +221 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgDA,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAsChF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,6BAA6B;AAC7B,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAK1E,OAAO,EAAE,oBAAoB,EAAE,MAAM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,EAC9B,gCAAgC,EAChC,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,gFAAgF;AAChF,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,kCAAkC,EAClC,yBAAyB,EACzB,4BAA4B,EAC5B,+BAA+B,EAC/B,sBAAsB,EACtB,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAmB9B,OAAO,EACL,sCAAsC,EACtC,+BAA+B,GAChC,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 07A work item 6 — the bounded protected operator-configuration
|
|
3
|
+
* resolution foundation (pre-Quellight).
|
|
4
|
+
*
|
|
5
|
+
* Quellight (Stage 07B+) will need to configure one pinned model-provider
|
|
6
|
+
* profile, store locations, and retention bounds through operator
|
|
7
|
+
* configuration. This module is the VICT-side FOUNDATION for that
|
|
8
|
+
* composition: typed resolution, name-pattern validation, and fail-closed
|
|
9
|
+
* credential handling — extending the Verified Stage 06A
|
|
10
|
+
* `protectCredentialPort`/`requireCredential` discipline (MSTR-011) to
|
|
11
|
+
* product-facing operator configuration.
|
|
12
|
+
*
|
|
13
|
+
* Scope guard (handoff work item 6): this is resolution types, a loader,
|
|
14
|
+
* validation, and tests ONLY. It is NOT a real provider integration, NOT a
|
|
15
|
+
* live-provider wrapper, and NOT any Quellight product code. No generalized
|
|
16
|
+
* secrets-management platform is created.
|
|
17
|
+
*
|
|
18
|
+
* Protected-credential discipline (SEC-003, MSTR-011, AI-004):
|
|
19
|
+
* - the operator configuration carries the provider credential VARIABLE
|
|
20
|
+
* NAME (`credentialVar`) — NEVER a credential value;
|
|
21
|
+
* - credential VALUES enter only through `requireOperatorCredential`,
|
|
22
|
+
* which resolves just-in time from the operator-provided environment
|
|
23
|
+
* source and is never cached, logged, serialized, or persisted;
|
|
24
|
+
* - failures are stable and non-echoing: no provider content, no
|
|
25
|
+
* environment content, and no credential value can enter an error, a
|
|
26
|
+
* diagnostic, or the serialized configuration;
|
|
27
|
+
* - the serialized configuration surface (`serializeOperatorConfiguration`)
|
|
28
|
+
* is structural: a configuration object HAS no credential-value field, so
|
|
29
|
+
* no serialization path can leak one.
|
|
30
|
+
*/
|
|
31
|
+
import type { AgentCredentialPort } from './agent-types.js';
|
|
32
|
+
/** The closed schema marker of the operator configuration foundation. */
|
|
33
|
+
export declare const OPERATOR_CONFIG_SCHEMA: "vict.operator-config@1";
|
|
34
|
+
/** Stable non-echoing operator-configuration failure codes. */
|
|
35
|
+
export type OperatorConfigErrorCode = 'VICT_OPERATOR_CONFIG_INVALID' | 'VICT_OPERATOR_CREDENTIAL_UNAVAILABLE';
|
|
36
|
+
/** Error thrown for operator-configuration failures (stable, non-echoing). */
|
|
37
|
+
export declare class OperatorConfigError extends Error {
|
|
38
|
+
readonly code: OperatorConfigErrorCode;
|
|
39
|
+
constructor(code: OperatorConfigErrorCode, message: string);
|
|
40
|
+
}
|
|
41
|
+
/** Error thrown when a required operator credential cannot be resolved. */
|
|
42
|
+
export declare class OperatorCredentialUnavailableError extends OperatorConfigError {
|
|
43
|
+
/** The credential VARIABLE NAME (never a value, never provider content). */
|
|
44
|
+
readonly credentialName: string;
|
|
45
|
+
constructor(credentialName: string);
|
|
46
|
+
}
|
|
47
|
+
/** One validated provider-profile selection (credential NAME only). */
|
|
48
|
+
export interface ProviderProfileSelection {
|
|
49
|
+
/** Stable profile ID (the pinned preferred profile; rotation deferred, OQ4). */
|
|
50
|
+
readonly profileId: string;
|
|
51
|
+
/** Provider identifier intent (e.g. `offline-fixture`). */
|
|
52
|
+
readonly provider: string;
|
|
53
|
+
/** The pinned model-router intent string (`provider/model`). */
|
|
54
|
+
readonly routerModel: string;
|
|
55
|
+
/** The provider credential ENVIRONMENT-VARIABLE NAME — never a value. */
|
|
56
|
+
readonly credentialVar: string;
|
|
57
|
+
}
|
|
58
|
+
/** Validated store locations (bounded relative paths; never URLs). */
|
|
59
|
+
export interface StoreLocationPlan {
|
|
60
|
+
/** VICT operational store location, when configured. */
|
|
61
|
+
readonly operationalStorePath?: string;
|
|
62
|
+
/** VICT application-domain store location, when configured. */
|
|
63
|
+
readonly applicationStorePath?: string;
|
|
64
|
+
/** Dedicated Mastra store location, when configured. */
|
|
65
|
+
readonly mastraStorePath?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Validated retention bounds (positive finite safe integer milliseconds). */
|
|
68
|
+
export interface RetentionBounds {
|
|
69
|
+
/** Conversation-message retention bound, when configured. */
|
|
70
|
+
readonly messagesMaxAgeMs?: number;
|
|
71
|
+
/** Thread retention bound, when configured. */
|
|
72
|
+
readonly threadsMaxAgeMs?: number;
|
|
73
|
+
/** Observability-span retention bound, when configured. */
|
|
74
|
+
readonly spansMaxAgeMs?: number;
|
|
75
|
+
}
|
|
76
|
+
/** One resolved, frozen operator configuration. */
|
|
77
|
+
export interface OperatorConfiguration {
|
|
78
|
+
readonly schema: typeof OPERATOR_CONFIG_SCHEMA;
|
|
79
|
+
readonly profile: ProviderProfileSelection;
|
|
80
|
+
readonly stores: StoreLocationPlan;
|
|
81
|
+
readonly retention: RetentionBounds;
|
|
82
|
+
}
|
|
83
|
+
/** The operator input for one profile selection (credential NAME only). */
|
|
84
|
+
export interface OperatorProfileInput {
|
|
85
|
+
readonly profileId: unknown;
|
|
86
|
+
readonly provider: unknown;
|
|
87
|
+
readonly routerModel: unknown;
|
|
88
|
+
readonly credentialVar: unknown;
|
|
89
|
+
}
|
|
90
|
+
/** The operator input for store locations. */
|
|
91
|
+
export interface OperatorStoresInput {
|
|
92
|
+
readonly operationalStorePath?: unknown;
|
|
93
|
+
readonly applicationStorePath?: unknown;
|
|
94
|
+
readonly mastraStorePath?: unknown;
|
|
95
|
+
}
|
|
96
|
+
/** The operator input for retention bounds. */
|
|
97
|
+
export interface OperatorRetentionInput {
|
|
98
|
+
readonly messagesMaxAgeMs?: unknown;
|
|
99
|
+
readonly threadsMaxAgeMs?: unknown;
|
|
100
|
+
readonly spansMaxAgeMs?: unknown;
|
|
101
|
+
}
|
|
102
|
+
/** The operator configuration input document. */
|
|
103
|
+
export interface OperatorConfigInput {
|
|
104
|
+
readonly profile: unknown;
|
|
105
|
+
readonly stores?: unknown;
|
|
106
|
+
readonly retention?: unknown;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Resolve one provider-profile selection. Only the credential VARIABLE
|
|
110
|
+
* NAME is accepted; any value-shaped attempt is a structural rejection.
|
|
111
|
+
*/
|
|
112
|
+
export declare function resolveProviderProfileSelection(input: unknown): ProviderProfileSelection;
|
|
113
|
+
/** Resolve the store-location plan. */
|
|
114
|
+
export declare function resolveStoreLocationPlan(input: unknown): StoreLocationPlan;
|
|
115
|
+
/** Resolve the retention bounds. */
|
|
116
|
+
export declare function resolveRetentionBounds(input: unknown): RetentionBounds;
|
|
117
|
+
/**
|
|
118
|
+
* Resolve the complete operator configuration from operator-supplied
|
|
119
|
+
* configuration data. Credential VALUES are structurally absent: the
|
|
120
|
+
* result carries the credential VARIABLE NAME only.
|
|
121
|
+
*/
|
|
122
|
+
export declare function resolveOperatorConfiguration(input: OperatorConfigInput): OperatorConfiguration;
|
|
123
|
+
/**
|
|
124
|
+
* The deterministic, safe serialization surface of an operator
|
|
125
|
+
* configuration. Because the configuration object structurally HAS no
|
|
126
|
+
* credential-value field, no serialization of it can leak a credential
|
|
127
|
+
* value. The serialization is canonical (sorted keys) and bounded.
|
|
128
|
+
*/
|
|
129
|
+
export declare function serializeOperatorConfiguration(config: OperatorConfiguration): string;
|
|
130
|
+
/** The minimal environment source: a credential VARIABLE NAME → value read. */
|
|
131
|
+
export type OperatorCredentialEnvironment = AgentCredentialPort | Record<string, string | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Resolve the REQUIRED provider credential just in time through the
|
|
134
|
+
* protected discipline: the value is read from the operator-provided
|
|
135
|
+
* environment source, never cached, never logged, never serialized, and a
|
|
136
|
+
* missing value fails closed with the stable non-echoing
|
|
137
|
+
* `VICT_OPERATOR_CREDENTIAL_UNAVAILABLE` code. The error carries the
|
|
138
|
+
* credential VARIABLE NAME only — never a value, never environment
|
|
139
|
+
* content.
|
|
140
|
+
*/
|
|
141
|
+
export declare function requireOperatorCredential(config: OperatorConfiguration, environment: OperatorCredentialEnvironment): Promise<string>;
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 07A work item 6 — the bounded protected operator-configuration
|
|
3
|
+
* resolution foundation (pre-Quellight).
|
|
4
|
+
*
|
|
5
|
+
* Quellight (Stage 07B+) will need to configure one pinned model-provider
|
|
6
|
+
* profile, store locations, and retention bounds through operator
|
|
7
|
+
* configuration. This module is the VICT-side FOUNDATION for that
|
|
8
|
+
* composition: typed resolution, name-pattern validation, and fail-closed
|
|
9
|
+
* credential handling — extending the Verified Stage 06A
|
|
10
|
+
* `protectCredentialPort`/`requireCredential` discipline (MSTR-011) to
|
|
11
|
+
* product-facing operator configuration.
|
|
12
|
+
*
|
|
13
|
+
* Scope guard (handoff work item 6): this is resolution types, a loader,
|
|
14
|
+
* validation, and tests ONLY. It is NOT a real provider integration, NOT a
|
|
15
|
+
* live-provider wrapper, and NOT any Quellight product code. No generalized
|
|
16
|
+
* secrets-management platform is created.
|
|
17
|
+
*
|
|
18
|
+
* Protected-credential discipline (SEC-003, MSTR-011, AI-004):
|
|
19
|
+
* - the operator configuration carries the provider credential VARIABLE
|
|
20
|
+
* NAME (`credentialVar`) — NEVER a credential value;
|
|
21
|
+
* - credential VALUES enter only through `requireOperatorCredential`,
|
|
22
|
+
* which resolves just-in time from the operator-provided environment
|
|
23
|
+
* source and is never cached, logged, serialized, or persisted;
|
|
24
|
+
* - failures are stable and non-echoing: no provider content, no
|
|
25
|
+
* environment content, and no credential value can enter an error, a
|
|
26
|
+
* diagnostic, or the serialized configuration;
|
|
27
|
+
* - the serialized configuration surface (`serializeOperatorConfiguration`)
|
|
28
|
+
* is structural: a configuration object HAS no credential-value field, so
|
|
29
|
+
* no serialization path can leak one.
|
|
30
|
+
*/
|
|
31
|
+
import { protectCredentialPort } from './agent-governance.js';
|
|
32
|
+
/** The closed schema marker of the operator configuration foundation. */
|
|
33
|
+
export const OPERATOR_CONFIG_SCHEMA = 'vict.operator-config@1';
|
|
34
|
+
/** Error thrown for operator-configuration failures (stable, non-echoing). */
|
|
35
|
+
export class OperatorConfigError extends Error {
|
|
36
|
+
code;
|
|
37
|
+
constructor(code, message) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = 'OperatorConfigError';
|
|
40
|
+
this.code = code;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Error thrown when a required operator credential cannot be resolved. */
|
|
44
|
+
export class OperatorCredentialUnavailableError extends OperatorConfigError {
|
|
45
|
+
/** The credential VARIABLE NAME (never a value, never provider content). */
|
|
46
|
+
credentialName;
|
|
47
|
+
constructor(credentialName) {
|
|
48
|
+
super('VICT_OPERATOR_CREDENTIAL_UNAVAILABLE', `Credential '${credentialName}' could not be resolved through the protected operator configuration.`);
|
|
49
|
+
this.name = 'OperatorCredentialUnavailableError';
|
|
50
|
+
this.credentialName = credentialName;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Bounded identifier: the same accepted ID discipline as the runtime. */
|
|
54
|
+
const ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
|
|
55
|
+
const MAX_ID_LENGTH = 128;
|
|
56
|
+
/** Environment-variable NAME pattern (never a value): `OPENAI_API_KEY`. */
|
|
57
|
+
const CREDENTIAL_VAR_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
58
|
+
const MAX_CREDENTIAL_VAR_LENGTH = 128;
|
|
59
|
+
/** Model-router intent string: `provider/model`, both bounded identifiers. */
|
|
60
|
+
const ROUTER_MODEL_PATTERN = /^[a-z][a-z0-9-]*(?:[.-][a-z0-9]+)*\/[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
|
|
61
|
+
const MAX_ROUTER_MODEL_LENGTH = 200;
|
|
62
|
+
/** Relative store-location discipline: bounded POSIX-style relative path. */
|
|
63
|
+
const STORE_PATH_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._/-]{0,500}$/;
|
|
64
|
+
const MAX_STORE_PATH_LENGTH = 512;
|
|
65
|
+
function invalid(reason) {
|
|
66
|
+
// The reason is a FIXED structural description — never operator content.
|
|
67
|
+
throw new OperatorConfigError('VICT_OPERATOR_CONFIG_INVALID', reason);
|
|
68
|
+
}
|
|
69
|
+
/** Require a bounded identifier string. */
|
|
70
|
+
function requireId(value, field) {
|
|
71
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > MAX_ID_LENGTH) {
|
|
72
|
+
invalid(`${field} must be a bounded non-empty identifier string`);
|
|
73
|
+
}
|
|
74
|
+
if (!ID_PATTERN.test(value)) {
|
|
75
|
+
invalid(`${field} must match the bounded VICT identifier pattern`);
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
/** Require an environment-variable NAME (credential values are unnameable). */
|
|
80
|
+
function requireCredentialVar(value) {
|
|
81
|
+
if (typeof value !== 'string' ||
|
|
82
|
+
value.length === 0 ||
|
|
83
|
+
value.length > MAX_CREDENTIAL_VAR_LENGTH ||
|
|
84
|
+
!CREDENTIAL_VAR_PATTERN.test(value)) {
|
|
85
|
+
invalid('credentialVar must be an environment-variable NAME matching [A-Za-z_][A-Za-z0-9_]*');
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
/** Require a bounded `provider/model` router intent string. */
|
|
90
|
+
function requireRouterModel(value) {
|
|
91
|
+
if (typeof value !== 'string' ||
|
|
92
|
+
value.length === 0 ||
|
|
93
|
+
value.length > MAX_ROUTER_MODEL_LENGTH ||
|
|
94
|
+
!ROUTER_MODEL_PATTERN.test(value)) {
|
|
95
|
+
invalid('routerModel must be a bounded provider/model intent string');
|
|
96
|
+
}
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
/** Require an optional bounded relative store path (never a URL). */
|
|
100
|
+
function requireOptionalStorePath(value, field) {
|
|
101
|
+
if (value === undefined) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
if (typeof value !== 'string' ||
|
|
105
|
+
value.length === 0 ||
|
|
106
|
+
value.length > MAX_STORE_PATH_LENGTH ||
|
|
107
|
+
value.includes('://') ||
|
|
108
|
+
value.includes('\\') ||
|
|
109
|
+
value.includes('//') ||
|
|
110
|
+
!STORE_PATH_PATTERN.test(value) ||
|
|
111
|
+
value.includes('..')) {
|
|
112
|
+
invalid(`${field} must be a bounded relative store path without URL schemes or traversal`);
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
/** Require an optional positive-finite-safe-integer millisecond bound. */
|
|
117
|
+
function requireOptionalRetentionMs(value, field) {
|
|
118
|
+
if (value === undefined) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0) {
|
|
122
|
+
invalid(`${field} must be a positive safe-integer millisecond bound`);
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Require the input document to be a PLAIN canonical object with EXACTLY
|
|
128
|
+
* the accepted field set: own enumerable string-keyed DATA properties,
|
|
129
|
+
* `Object.prototype` or null prototype, no symbol keys. Unknown fields are
|
|
130
|
+
* rejected (fail closed) — a configuration can never smuggle, for example,
|
|
131
|
+
* a `credential` or `apiKey` VALUE field past this boundary.
|
|
132
|
+
*/
|
|
133
|
+
function requirePlainObjectWithFields(value, what, acceptedFields) {
|
|
134
|
+
if (typeof value !== 'object' || value === null) {
|
|
135
|
+
invalid(`${what} must be a plain object`);
|
|
136
|
+
}
|
|
137
|
+
const proto = Object.getPrototypeOf(value);
|
|
138
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
139
|
+
invalid(`${what} must have Object.prototype or a null prototype`);
|
|
140
|
+
}
|
|
141
|
+
const ownKeys = Reflect.ownKeys(value);
|
|
142
|
+
for (const key of ownKeys) {
|
|
143
|
+
if (typeof key !== 'string') {
|
|
144
|
+
invalid(`${what} must not carry symbol-keyed fields`);
|
|
145
|
+
}
|
|
146
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
147
|
+
if (descriptor === undefined) {
|
|
148
|
+
invalid(`${what} structure could not be proven`);
|
|
149
|
+
}
|
|
150
|
+
if (!Object.prototype.propertyIsEnumerable.call(value, key) ||
|
|
151
|
+
descriptor.get ||
|
|
152
|
+
descriptor.set) {
|
|
153
|
+
invalid(`${what} fields must be own enumerable data properties`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const key of ownKeys) {
|
|
157
|
+
if (!acceptedFields.includes(key)) {
|
|
158
|
+
invalid(`${what} carries an unknown field (closed field set)`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Resolve one provider-profile selection. Only the credential VARIABLE
|
|
165
|
+
* NAME is accepted; any value-shaped attempt is a structural rejection.
|
|
166
|
+
*/
|
|
167
|
+
export function resolveProviderProfileSelection(input) {
|
|
168
|
+
const record = requirePlainObjectWithFields(input, 'profile', [
|
|
169
|
+
'profileId',
|
|
170
|
+
'provider',
|
|
171
|
+
'routerModel',
|
|
172
|
+
'credentialVar',
|
|
173
|
+
]);
|
|
174
|
+
const selection = Object.freeze({
|
|
175
|
+
profileId: requireId(record.profileId, 'profile.profileId'),
|
|
176
|
+
provider: requireId(record.provider, 'profile.provider'),
|
|
177
|
+
routerModel: requireRouterModel(record.routerModel),
|
|
178
|
+
credentialVar: requireCredentialVar(record.credentialVar),
|
|
179
|
+
});
|
|
180
|
+
return selection;
|
|
181
|
+
}
|
|
182
|
+
/** Resolve the store-location plan. */
|
|
183
|
+
export function resolveStoreLocationPlan(input) {
|
|
184
|
+
const record = requirePlainObjectWithFields(input, 'stores', [
|
|
185
|
+
'operationalStorePath',
|
|
186
|
+
'applicationStorePath',
|
|
187
|
+
'mastraStorePath',
|
|
188
|
+
]);
|
|
189
|
+
return Object.freeze({
|
|
190
|
+
operationalStorePath: requireOptionalStorePath(record.operationalStorePath, 'stores.operationalStorePath'),
|
|
191
|
+
applicationStorePath: requireOptionalStorePath(record.applicationStorePath, 'stores.applicationStorePath'),
|
|
192
|
+
mastraStorePath: requireOptionalStorePath(record.mastraStorePath, 'stores.mastraStorePath'),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/** Resolve the retention bounds. */
|
|
196
|
+
export function resolveRetentionBounds(input) {
|
|
197
|
+
const record = requirePlainObjectWithFields(input, 'retention', [
|
|
198
|
+
'messagesMaxAgeMs',
|
|
199
|
+
'threadsMaxAgeMs',
|
|
200
|
+
'spansMaxAgeMs',
|
|
201
|
+
]);
|
|
202
|
+
return Object.freeze({
|
|
203
|
+
messagesMaxAgeMs: requireOptionalRetentionMs(record.messagesMaxAgeMs, 'retention.messagesMaxAgeMs'),
|
|
204
|
+
threadsMaxAgeMs: requireOptionalRetentionMs(record.threadsMaxAgeMs, 'retention.threadsMaxAgeMs'),
|
|
205
|
+
spansMaxAgeMs: requireOptionalRetentionMs(record.spansMaxAgeMs, 'retention.spansMaxAgeMs'),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Resolve the complete operator configuration from operator-supplied
|
|
210
|
+
* configuration data. Credential VALUES are structurally absent: the
|
|
211
|
+
* result carries the credential VARIABLE NAME only.
|
|
212
|
+
*/
|
|
213
|
+
export function resolveOperatorConfiguration(input) {
|
|
214
|
+
const document = requirePlainObjectWithFields(input, 'operator configuration', [
|
|
215
|
+
'profile',
|
|
216
|
+
'stores',
|
|
217
|
+
'retention',
|
|
218
|
+
]);
|
|
219
|
+
const profile = resolveProviderProfileSelection(document.profile);
|
|
220
|
+
const stores = document.stores === undefined
|
|
221
|
+
? Object.freeze({})
|
|
222
|
+
: resolveStoreLocationPlan(document.stores);
|
|
223
|
+
const retention = document.retention === undefined
|
|
224
|
+
? Object.freeze({})
|
|
225
|
+
: resolveRetentionBounds(document.retention);
|
|
226
|
+
return Object.freeze({
|
|
227
|
+
schema: OPERATOR_CONFIG_SCHEMA,
|
|
228
|
+
profile,
|
|
229
|
+
stores,
|
|
230
|
+
retention,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The deterministic, safe serialization surface of an operator
|
|
235
|
+
* configuration. Because the configuration object structurally HAS no
|
|
236
|
+
* credential-value field, no serialization of it can leak a credential
|
|
237
|
+
* value. The serialization is canonical (sorted keys) and bounded.
|
|
238
|
+
*/
|
|
239
|
+
export function serializeOperatorConfiguration(config) {
|
|
240
|
+
if (config.schema !== OPERATOR_CONFIG_SCHEMA) {
|
|
241
|
+
invalid('operator configuration carries an unknown schema marker');
|
|
242
|
+
}
|
|
243
|
+
const ordered = {
|
|
244
|
+
profile: {
|
|
245
|
+
credentialVar: config.profile.credentialVar,
|
|
246
|
+
profileId: config.profile.profileId,
|
|
247
|
+
provider: config.profile.provider,
|
|
248
|
+
routerModel: config.profile.routerModel,
|
|
249
|
+
},
|
|
250
|
+
retention: { ...config.retention },
|
|
251
|
+
schema: config.schema,
|
|
252
|
+
stores: { ...config.stores },
|
|
253
|
+
};
|
|
254
|
+
return JSON.stringify(ordered);
|
|
255
|
+
}
|
|
256
|
+
function asCredentialPort(environment) {
|
|
257
|
+
if (typeof environment.get === 'function') {
|
|
258
|
+
return protectCredentialPort(environment);
|
|
259
|
+
}
|
|
260
|
+
const record = environment;
|
|
261
|
+
return protectCredentialPort({
|
|
262
|
+
async get(name) {
|
|
263
|
+
return record[name];
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Resolve the REQUIRED provider credential just in time through the
|
|
269
|
+
* protected discipline: the value is read from the operator-provided
|
|
270
|
+
* environment source, never cached, never logged, never serialized, and a
|
|
271
|
+
* missing value fails closed with the stable non-echoing
|
|
272
|
+
* `VICT_OPERATOR_CREDENTIAL_UNAVAILABLE` code. The error carries the
|
|
273
|
+
* credential VARIABLE NAME only — never a value, never environment
|
|
274
|
+
* content.
|
|
275
|
+
*/
|
|
276
|
+
export async function requireOperatorCredential(config, environment) {
|
|
277
|
+
const port = asCredentialPort(environment);
|
|
278
|
+
// Protected resolution: provider failures collapse to `undefined` (never
|
|
279
|
+
// propagated provider content), then the value passes the same
|
|
280
|
+
// just-in-time, non-caching, non-echoing requirement as every other
|
|
281
|
+
// protected credential read. The failure carries the credential VARIABLE
|
|
282
|
+
// NAME only.
|
|
283
|
+
const value = await port.get(config.profile.credentialVar).catch(() => undefined);
|
|
284
|
+
if (value === undefined || typeof value !== 'string') {
|
|
285
|
+
throw new OperatorCredentialUnavailableError(config.profile.credentialVar);
|
|
286
|
+
}
|
|
287
|
+
return value;
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=operator-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator-config.js","sourceRoot":"","sources":["../src/operator-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,yEAAyE;AACzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAiC,CAAC;AAMxE,8EAA8E;AAC9E,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,CAA0B;IAEvC,YAAY,IAA6B,EAAE,OAAe;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,2EAA2E;AAC3E,MAAM,OAAO,kCAAmC,SAAQ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,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAClF,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrD,MAAM,IAAI,kCAAkC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type CompiledGraph, type GraphIssue } from '@victframework/kernel';
|
|
2
|
+
import type { ActivationManifest, StoredActivation } from './store-types.js';
|
|
3
|
+
import type { CapabilityRegistry, FrozenCapabilityBinding } from './registry.js';
|
|
4
|
+
/**
|
|
5
|
+
* Exact-activation resolution for Stage 03 (handoff §17).
|
|
6
|
+
*
|
|
7
|
+
* A suspended run resolves its graph and bindings ONLY from the stored
|
|
8
|
+
* manifest of its pinned activationVersion, rebuilt against the registry's
|
|
9
|
+
* revision-pinned lookups. Missing artifacts produce structured unavailable
|
|
10
|
+
* errors — never a nearby/substitute revision. Multiple immutable
|
|
11
|
+
* snapshots can coexist, cached by activationVersion.
|
|
12
|
+
*/
|
|
13
|
+
/** A frozen contract parsing handle captured at resolution time. */
|
|
14
|
+
export interface FrozenContractHandle {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly revision: string;
|
|
17
|
+
readonly expected: string;
|
|
18
|
+
readonly parse: (input: unknown) => {
|
|
19
|
+
readonly ok: boolean;
|
|
20
|
+
readonly value?: unknown;
|
|
21
|
+
readonly issues?: readonly {
|
|
22
|
+
code: string;
|
|
23
|
+
path: string;
|
|
24
|
+
message: string;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface ResolvedBindings {
|
|
29
|
+
readonly bindings: ReadonlyMap<string, FrozenCapabilityBinding>;
|
|
30
|
+
readonly contracts: ReadonlyMap<string, FrozenContractHandle>;
|
|
31
|
+
}
|
|
32
|
+
export type ActivationResolution<T> = {
|
|
33
|
+
readonly ok: true;
|
|
34
|
+
readonly value: T;
|
|
35
|
+
} | {
|
|
36
|
+
readonly ok: false;
|
|
37
|
+
readonly code: string;
|
|
38
|
+
readonly message: string;
|
|
39
|
+
};
|
|
40
|
+
export interface ActivationResolverDeps {
|
|
41
|
+
readonly catalog: {
|
|
42
|
+
get(activationVersion: string): Promise<StoredActivation | undefined>;
|
|
43
|
+
};
|
|
44
|
+
readonly registry: CapabilityRegistry;
|
|
45
|
+
}
|
|
46
|
+
/** Load and validate the stored manifest for an activation version. */
|
|
47
|
+
export declare function loadManifest(deps: Pick<ActivationResolverDeps, 'catalog'>, activationVersion: string): Promise<ActivationManifest>;
|
|
48
|
+
/**
|
|
49
|
+
* Rebuild the exact compiled graph for a stored activation from the
|
|
50
|
+
* registry's revision-pinned lookups. Cache by activationVersion is the
|
|
51
|
+
* caller's concern (immutable results).
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveGraphForActivation(deps: ActivationResolverDeps, activationVersion: string): Promise<CompiledGraphResolution>;
|
|
54
|
+
export interface CompiledGraphResolution {
|
|
55
|
+
readonly ok: boolean;
|
|
56
|
+
readonly graph?: CompiledGraph;
|
|
57
|
+
readonly code?: string;
|
|
58
|
+
readonly message?: string;
|
|
59
|
+
readonly issues?: readonly GraphIssue[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the exact execution bindings (invoke handles + captured contract
|
|
63
|
+
* parsing handles) for a run's pinned activation.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveBindings(deps: ActivationResolverDeps, activationVersion: string): Promise<ResolvedBindingsResolution>;
|
|
66
|
+
export interface ResolvedBindingsResolution {
|
|
67
|
+
readonly ok: boolean;
|
|
68
|
+
readonly bindings?: ReadonlyMap<string, FrozenCapabilityBinding>;
|
|
69
|
+
readonly contracts?: ReadonlyMap<string, FrozenContractHandle>;
|
|
70
|
+
readonly code?: string;
|
|
71
|
+
readonly message?: string;
|
|
72
|
+
}
|
|
73
|
+
/** Stable opaque idempotency key from durable identity (handoff §12.2). */
|
|
74
|
+
export declare function deriveIdempotencyKey(parts: {
|
|
75
|
+
runId: string;
|
|
76
|
+
activationVersion: string;
|
|
77
|
+
lineage: string;
|
|
78
|
+
nodeId: string;
|
|
79
|
+
invocationId: string;
|
|
80
|
+
}): string;
|
|
81
|
+
/** Deterministic logical invocation id: invariant across retries and restarts. */
|
|
82
|
+
export declare function deriveInvocationId(parts: {
|
|
83
|
+
runId: string;
|
|
84
|
+
activationVersion: string;
|
|
85
|
+
lineage: string;
|
|
86
|
+
nodeId: string;
|
|
87
|
+
}): string;
|
|
88
|
+
export declare function deriveAttemptId(invocationId: string, attemptNumber: number): string;
|
|
89
|
+
/** Deterministic token ids from stable run/node/branch identity. */
|
|
90
|
+
export declare function rootTokenId(runId: string): string;
|
|
91
|
+
export declare function forkChildTokenId(runId: string, forkId: string, branchKey: string): string;
|
|
92
|
+
export declare function joinTokenId(runId: string, joinId: string): string;
|
|
93
|
+
export declare function waitIdFor(runId: string, lineage: string, nodeId: string): string;
|
|
94
|
+
export declare function canonicalBranchLineage(parentLineage: string, forkId: string, branchKey: string): string;
|
|
95
|
+
/** Branch lineage of the post-join continuation: the fork's own lineage. */
|
|
96
|
+
export declare function forkLineageOf(childLineage: string, forkId: string, branchKey: string): string;
|
|
97
|
+
export declare function signalCommandHash(command: {
|
|
98
|
+
runId: string;
|
|
99
|
+
waitId: string;
|
|
100
|
+
signalId: string;
|
|
101
|
+
signalName?: string;
|
|
102
|
+
payload: unknown;
|
|
103
|
+
}): string;
|
|
104
|
+
export declare function cancellationCommandHash(command: {
|
|
105
|
+
runId: string;
|
|
106
|
+
requestId: string;
|
|
107
|
+
reasonCode: string;
|
|
108
|
+
}): string;
|
|
109
|
+
export declare function resolutionCommandHash(command: {
|
|
110
|
+
runId: string;
|
|
111
|
+
resolutionId: string;
|
|
112
|
+
action: string;
|
|
113
|
+
reasonCode: string;
|
|
114
|
+
expectedRunRevision?: number;
|
|
115
|
+
hasOutput: boolean;
|
|
116
|
+
}): string;
|