@tryvira/mcp 0.0.0-stage → 0.1.1
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 +1 -0
- package/README.md +76 -3
- package/dist/cli.js +1996 -0
- package/dist/cli.js.map +7 -0
- package/dist/domain/src/scope-composer.d.ts +138 -0
- package/dist/domain/src/vnext.d.ts +53 -0
- package/dist/index.d.ts +306 -0
- package/dist/index.js +225 -0
- package/dist/index.js.map +7 -0
- package/dist/mcp/src/index.d.ts +1 -0
- package/dist/migrations/001_vnext_foundation.sql +628 -0
- package/dist/runtime/src/mcp-gateway.d.ts +104 -0
- package/package.json +56 -6
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export declare function scopeDigest(scope: unknown): string;
|
|
2
|
+
export type ScopeLevel = 'platform' | 'organization' | 'project' | 'application' | 'workspace' | 'user' | 'session';
|
|
3
|
+
export interface HierarchicalScope {
|
|
4
|
+
level: ScopeLevel;
|
|
5
|
+
id: string;
|
|
6
|
+
parentId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ScopeDelegation {
|
|
9
|
+
id: string;
|
|
10
|
+
issuerId: string;
|
|
11
|
+
subjectId: string;
|
|
12
|
+
fromLevel: ScopeLevel;
|
|
13
|
+
toLevel: ScopeLevel;
|
|
14
|
+
permissions: readonly string[];
|
|
15
|
+
expiresAt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CanonicalOrganizationScopeInput {
|
|
18
|
+
applicationId?: string | null;
|
|
19
|
+
workspaceId?: string | null;
|
|
20
|
+
userId?: string | null;
|
|
21
|
+
sessionId?: string | null;
|
|
22
|
+
}
|
|
23
|
+
/** Canonical serializer shared by organization intelligence and Teach boundaries. */
|
|
24
|
+
export declare function canonicalOrganizationScopeKeys(input: CanonicalOrganizationScopeInput): string[];
|
|
25
|
+
export interface ReferenceScopeDelegation extends ScopeDelegation {
|
|
26
|
+
stableKey: string;
|
|
27
|
+
parentAuthorityLevel: ScopeLevel;
|
|
28
|
+
childScopeKind: ScopeLevel;
|
|
29
|
+
childScopeDigest: string;
|
|
30
|
+
parentRevisionDigest: string;
|
|
31
|
+
/** Reference programs may narrow an exception to explicit effect kinds. */
|
|
32
|
+
exceptionEffectTypes?: readonly string[];
|
|
33
|
+
when: {
|
|
34
|
+
kind: 'all';
|
|
35
|
+
expressions: readonly [];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface ScopeCompositionConflict {
|
|
39
|
+
code: 'SCOPE_CHAIN_INVALID' | 'SCOPE_DELEGATION_CONFLICT' | 'SCOPE_REVISION_LEVEL_CONFLICT' | 'TEMPORAL_INVARIANT_CONFLICT' | 'TEMPORAL_TRANSITION_CONFLICT' | 'RECOVERY_CONFLICT' | 'ACTOR_OWNERSHIP_CONFLICT' | 'DEADLINE_CONFLICT';
|
|
40
|
+
delegationIds: readonly string[];
|
|
41
|
+
hard: true;
|
|
42
|
+
}
|
|
43
|
+
export interface EffectiveRevisionBinding {
|
|
44
|
+
id: string;
|
|
45
|
+
digest: string;
|
|
46
|
+
sourceRevisionSetDigest?: string;
|
|
47
|
+
ancestorHardAuthorityDigest?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ScopeBehaviorRevision {
|
|
50
|
+
id: string;
|
|
51
|
+
digest: string;
|
|
52
|
+
level: ScopeLevel;
|
|
53
|
+
hard: boolean;
|
|
54
|
+
source: string;
|
|
55
|
+
temporalInvariantDigest?: string;
|
|
56
|
+
temporalTransitionDigest?: string;
|
|
57
|
+
recoveryDigest?: string;
|
|
58
|
+
temporalInvariantKeys?: Readonly<Record<string, string>>;
|
|
59
|
+
temporalTransitionKeys?: Readonly<Record<string, string>>;
|
|
60
|
+
recoveryKeys?: Readonly<Record<string, string>>;
|
|
61
|
+
actorOwnershipDigest?: string;
|
|
62
|
+
deadlineDigest?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ScopeCompositionExplanation {
|
|
65
|
+
revisionId: string;
|
|
66
|
+
level: ScopeLevel;
|
|
67
|
+
disposition: 'inherited' | 'overridden' | 'rejected';
|
|
68
|
+
reason: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ComposedScope {
|
|
71
|
+
chain: readonly HierarchicalScope[];
|
|
72
|
+
permissions: readonly string[];
|
|
73
|
+
delegationIds?: readonly string[];
|
|
74
|
+
compositionDigest: string;
|
|
75
|
+
conflictSetDigest: string;
|
|
76
|
+
conflictSummary: {
|
|
77
|
+
total: number;
|
|
78
|
+
hard: number;
|
|
79
|
+
soft: number;
|
|
80
|
+
byCategory: Record<string, number>;
|
|
81
|
+
};
|
|
82
|
+
conflicts: readonly ScopeCompositionConflict[];
|
|
83
|
+
serveable: boolean;
|
|
84
|
+
effectiveRevision?: EffectiveRevisionBinding;
|
|
85
|
+
sourceRevisions?: readonly ScopeBehaviorRevision[];
|
|
86
|
+
sourceRevisionSetDigest?: string;
|
|
87
|
+
ancestorHardAuthorityDigest?: string;
|
|
88
|
+
effectiveProgramDigest?: string;
|
|
89
|
+
explanations?: readonly ScopeCompositionExplanation[];
|
|
90
|
+
}
|
|
91
|
+
export declare function projectComposedScope(composed: ComposedScope): import('./vnext.ts').Scope;
|
|
92
|
+
export declare function assertComposedScopeIntegrity(composed: ComposedScope): true;
|
|
93
|
+
/** Re-seals the existing canonical scope authority with effective-program lineage. */
|
|
94
|
+
export declare function bindEffectiveProgramAuthority(composed: ComposedScope, input: {
|
|
95
|
+
effectiveProgramDigest: string;
|
|
96
|
+
sourceRevisionSetDigest: string;
|
|
97
|
+
ancestorHardAuthorityDigest: string;
|
|
98
|
+
}): ComposedScope;
|
|
99
|
+
export interface ScopeCompositionRevalidation {
|
|
100
|
+
stale: boolean;
|
|
101
|
+
sourceRevisionSetChanged: boolean;
|
|
102
|
+
ancestorHardAuthorityChanged: boolean;
|
|
103
|
+
effectiveProgramChanged: boolean;
|
|
104
|
+
effectiveRevisionChanged: boolean;
|
|
105
|
+
conflictSetChanged: boolean;
|
|
106
|
+
compatible: boolean;
|
|
107
|
+
taintRequired: boolean;
|
|
108
|
+
}
|
|
109
|
+
/** Reference-equivalent dependency check for an already materialized scope. */
|
|
110
|
+
export declare function compositionDependencyStale(previous: ComposedScope, next: ComposedScope): boolean;
|
|
111
|
+
/** Revalidation must be explicit before a changed composition can be served. */
|
|
112
|
+
export declare function revalidateScopeComposition(previous: ComposedScope, next: ComposedScope): ScopeCompositionRevalidation;
|
|
113
|
+
export declare function composeScope(input: {
|
|
114
|
+
chain: readonly HierarchicalScope[];
|
|
115
|
+
delegation?: ScopeDelegation | null;
|
|
116
|
+
now?: string;
|
|
117
|
+
availablePermissions?: readonly string[];
|
|
118
|
+
effectiveRevision?: EffectiveRevisionBinding;
|
|
119
|
+
sourceRevisions?: readonly ScopeBehaviorRevision[];
|
|
120
|
+
}): ComposedScope;
|
|
121
|
+
/** Compose all supplied delegations, rejecting duplicate ids and preserving one digest for runtime checks. */
|
|
122
|
+
export declare function composeDelegatedScope(input: {
|
|
123
|
+
chain: readonly HierarchicalScope[];
|
|
124
|
+
delegations: readonly ScopeDelegation[];
|
|
125
|
+
now?: string;
|
|
126
|
+
availablePermissions?: readonly string[];
|
|
127
|
+
effectiveRevision?: EffectiveRevisionBinding;
|
|
128
|
+
sourceRevisions?: readonly ScopeBehaviorRevision[];
|
|
129
|
+
}): ComposedScope;
|
|
130
|
+
/** Reference-shaped exception delegation: parent-authored, exact-child and digest-bound. */
|
|
131
|
+
export declare function composeReferenceDelegatedScope(input: {
|
|
132
|
+
chain: readonly HierarchicalScope[];
|
|
133
|
+
delegation: ReferenceScopeDelegation;
|
|
134
|
+
now?: string;
|
|
135
|
+
availablePermissions?: readonly string[];
|
|
136
|
+
effectiveRevision?: EffectiveRevisionBinding;
|
|
137
|
+
sourceRevisions?: readonly ScopeBehaviorRevision[];
|
|
138
|
+
}): ComposedScope;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface Scope {
|
|
2
|
+
organizationId: string;
|
|
3
|
+
projectId: string;
|
|
4
|
+
environmentId: string;
|
|
5
|
+
/** Optional hierarchy identities carried when a composed authority is in scope. */
|
|
6
|
+
applicationId?: string | null;
|
|
7
|
+
workspaceId?: string | null;
|
|
8
|
+
userId?: string | null;
|
|
9
|
+
sessionId?: string | null;
|
|
10
|
+
/** Optional composed-authority binding carried by persistence boundaries. */
|
|
11
|
+
authorityDigest?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface ScopedEntity extends Scope {
|
|
14
|
+
id: string;
|
|
15
|
+
}
|
|
16
|
+
export interface Policy extends ScopedEntity {
|
|
17
|
+
effect: 'allow' | 'deny';
|
|
18
|
+
revision: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The governed behavior boundary exposed by Vira's product model.
|
|
22
|
+
*
|
|
23
|
+
* `ControlPoint` was the pre-product name. Keep the type alias for persisted
|
|
24
|
+
* legacy adapters, but new domain code must use BehaviorPoint.
|
|
25
|
+
*/
|
|
26
|
+
export interface BehaviorPoint extends ScopedEntity {
|
|
27
|
+
}
|
|
28
|
+
/** @deprecated Use BehaviorPoint. This alias exists only at compatibility boundaries. */
|
|
29
|
+
export type ControlPoint = BehaviorPoint;
|
|
30
|
+
export interface BehaviorVariant extends ScopedEntity {
|
|
31
|
+
}
|
|
32
|
+
export interface Revision extends Scope {
|
|
33
|
+
id: string;
|
|
34
|
+
controlPointId: string;
|
|
35
|
+
variantId: string;
|
|
36
|
+
policyRevision: string;
|
|
37
|
+
immutable: true;
|
|
38
|
+
}
|
|
39
|
+
export interface ExecutionReceipt extends Scope {
|
|
40
|
+
id: string;
|
|
41
|
+
revisionId: string;
|
|
42
|
+
actorId: string;
|
|
43
|
+
idempotencyKey: string;
|
|
44
|
+
decision: string;
|
|
45
|
+
reason: string;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
semanticTaskRef?: string;
|
|
48
|
+
semanticTaskVersion?: number;
|
|
49
|
+
semanticTaskDigest?: string;
|
|
50
|
+
}
|
|
51
|
+
export declare function assertSameScope(...items: readonly Scope[]): void;
|
|
52
|
+
export declare function issueRevision(scope: Scope, behaviorPoint: BehaviorPoint, policy: Policy, variant: BehaviorVariant, id: string): Revision;
|
|
53
|
+
export declare function makeReceipt(scope: Scope, revision: Revision, actorId: string, idempotencyKey: string, decision: string, reason: string): ExecutionReceipt;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
declare module "domain/src/vnext" {
|
|
2
|
+
export interface Scope {
|
|
3
|
+
organizationId: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
environmentId: string;
|
|
6
|
+
/** Optional hierarchy identities carried when a composed authority is in scope. */
|
|
7
|
+
applicationId?: string | null;
|
|
8
|
+
workspaceId?: string | null;
|
|
9
|
+
userId?: string | null;
|
|
10
|
+
sessionId?: string | null;
|
|
11
|
+
/** Optional composed-authority binding carried by persistence boundaries. */
|
|
12
|
+
authorityDigest?: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface ScopedEntity extends Scope {
|
|
15
|
+
id: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Policy extends ScopedEntity {
|
|
18
|
+
effect: 'allow' | 'deny';
|
|
19
|
+
revision: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The governed behavior boundary exposed by Vira's product model.
|
|
23
|
+
*
|
|
24
|
+
* `ControlPoint` was the pre-product name. Keep the type alias for persisted
|
|
25
|
+
* legacy adapters, but new domain code must use BehaviorPoint.
|
|
26
|
+
*/
|
|
27
|
+
export interface BehaviorPoint extends ScopedEntity {
|
|
28
|
+
}
|
|
29
|
+
/** @deprecated Use BehaviorPoint. This alias exists only at compatibility boundaries. */
|
|
30
|
+
export type ControlPoint = BehaviorPoint;
|
|
31
|
+
export interface BehaviorVariant extends ScopedEntity {
|
|
32
|
+
}
|
|
33
|
+
export interface Revision extends Scope {
|
|
34
|
+
id: string;
|
|
35
|
+
controlPointId: string;
|
|
36
|
+
variantId: string;
|
|
37
|
+
policyRevision: string;
|
|
38
|
+
immutable: true;
|
|
39
|
+
}
|
|
40
|
+
export interface ExecutionReceipt extends Scope {
|
|
41
|
+
id: string;
|
|
42
|
+
revisionId: string;
|
|
43
|
+
actorId: string;
|
|
44
|
+
idempotencyKey: string;
|
|
45
|
+
decision: string;
|
|
46
|
+
reason: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
semanticTaskRef?: string;
|
|
49
|
+
semanticTaskVersion?: number;
|
|
50
|
+
semanticTaskDigest?: string;
|
|
51
|
+
}
|
|
52
|
+
export function assertSameScope(...items: readonly Scope[]): void;
|
|
53
|
+
export function issueRevision(scope: Scope, behaviorPoint: BehaviorPoint, policy: Policy, variant: BehaviorVariant, id: string): Revision;
|
|
54
|
+
export function makeReceipt(scope: Scope, revision: Revision, actorId: string, idempotencyKey: string, decision: string, reason: string): ExecutionReceipt;
|
|
55
|
+
}
|
|
56
|
+
declare module "domain/src/scope-composer" {
|
|
57
|
+
export function scopeDigest(scope: unknown): string;
|
|
58
|
+
export type ScopeLevel = 'platform' | 'organization' | 'project' | 'application' | 'workspace' | 'user' | 'session';
|
|
59
|
+
export interface HierarchicalScope {
|
|
60
|
+
level: ScopeLevel;
|
|
61
|
+
id: string;
|
|
62
|
+
parentId?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ScopeDelegation {
|
|
65
|
+
id: string;
|
|
66
|
+
issuerId: string;
|
|
67
|
+
subjectId: string;
|
|
68
|
+
fromLevel: ScopeLevel;
|
|
69
|
+
toLevel: ScopeLevel;
|
|
70
|
+
permissions: readonly string[];
|
|
71
|
+
expiresAt: string;
|
|
72
|
+
}
|
|
73
|
+
export interface CanonicalOrganizationScopeInput {
|
|
74
|
+
applicationId?: string | null;
|
|
75
|
+
workspaceId?: string | null;
|
|
76
|
+
userId?: string | null;
|
|
77
|
+
sessionId?: string | null;
|
|
78
|
+
}
|
|
79
|
+
/** Canonical serializer shared by organization intelligence and Teach boundaries. */
|
|
80
|
+
export function canonicalOrganizationScopeKeys(input: CanonicalOrganizationScopeInput): string[];
|
|
81
|
+
export interface ReferenceScopeDelegation extends ScopeDelegation {
|
|
82
|
+
stableKey: string;
|
|
83
|
+
parentAuthorityLevel: ScopeLevel;
|
|
84
|
+
childScopeKind: ScopeLevel;
|
|
85
|
+
childScopeDigest: string;
|
|
86
|
+
parentRevisionDigest: string;
|
|
87
|
+
/** Reference programs may narrow an exception to explicit effect kinds. */
|
|
88
|
+
exceptionEffectTypes?: readonly string[];
|
|
89
|
+
when: {
|
|
90
|
+
kind: 'all';
|
|
91
|
+
expressions: readonly [];
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export interface ScopeCompositionConflict {
|
|
95
|
+
code: 'SCOPE_CHAIN_INVALID' | 'SCOPE_DELEGATION_CONFLICT' | 'SCOPE_REVISION_LEVEL_CONFLICT' | 'TEMPORAL_INVARIANT_CONFLICT' | 'TEMPORAL_TRANSITION_CONFLICT' | 'RECOVERY_CONFLICT' | 'ACTOR_OWNERSHIP_CONFLICT' | 'DEADLINE_CONFLICT';
|
|
96
|
+
delegationIds: readonly string[];
|
|
97
|
+
hard: true;
|
|
98
|
+
}
|
|
99
|
+
export interface EffectiveRevisionBinding {
|
|
100
|
+
id: string;
|
|
101
|
+
digest: string;
|
|
102
|
+
sourceRevisionSetDigest?: string;
|
|
103
|
+
ancestorHardAuthorityDigest?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface ScopeBehaviorRevision {
|
|
106
|
+
id: string;
|
|
107
|
+
digest: string;
|
|
108
|
+
level: ScopeLevel;
|
|
109
|
+
hard: boolean;
|
|
110
|
+
source: string;
|
|
111
|
+
temporalInvariantDigest?: string;
|
|
112
|
+
temporalTransitionDigest?: string;
|
|
113
|
+
recoveryDigest?: string;
|
|
114
|
+
temporalInvariantKeys?: Readonly<Record<string, string>>;
|
|
115
|
+
temporalTransitionKeys?: Readonly<Record<string, string>>;
|
|
116
|
+
recoveryKeys?: Readonly<Record<string, string>>;
|
|
117
|
+
actorOwnershipDigest?: string;
|
|
118
|
+
deadlineDigest?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface ScopeCompositionExplanation {
|
|
121
|
+
revisionId: string;
|
|
122
|
+
level: ScopeLevel;
|
|
123
|
+
disposition: 'inherited' | 'overridden' | 'rejected';
|
|
124
|
+
reason: string;
|
|
125
|
+
}
|
|
126
|
+
export interface ComposedScope {
|
|
127
|
+
chain: readonly HierarchicalScope[];
|
|
128
|
+
permissions: readonly string[];
|
|
129
|
+
delegationIds?: readonly string[];
|
|
130
|
+
compositionDigest: string;
|
|
131
|
+
conflictSetDigest: string;
|
|
132
|
+
conflictSummary: {
|
|
133
|
+
total: number;
|
|
134
|
+
hard: number;
|
|
135
|
+
soft: number;
|
|
136
|
+
byCategory: Record<string, number>;
|
|
137
|
+
};
|
|
138
|
+
conflicts: readonly ScopeCompositionConflict[];
|
|
139
|
+
serveable: boolean;
|
|
140
|
+
effectiveRevision?: EffectiveRevisionBinding;
|
|
141
|
+
sourceRevisions?: readonly ScopeBehaviorRevision[];
|
|
142
|
+
sourceRevisionSetDigest?: string;
|
|
143
|
+
ancestorHardAuthorityDigest?: string;
|
|
144
|
+
effectiveProgramDigest?: string;
|
|
145
|
+
explanations?: readonly ScopeCompositionExplanation[];
|
|
146
|
+
}
|
|
147
|
+
export function projectComposedScope(composed: ComposedScope): import("domain/src/vnext").Scope;
|
|
148
|
+
export function assertComposedScopeIntegrity(composed: ComposedScope): true;
|
|
149
|
+
/** Re-seals the existing canonical scope authority with effective-program lineage. */
|
|
150
|
+
export function bindEffectiveProgramAuthority(composed: ComposedScope, input: {
|
|
151
|
+
effectiveProgramDigest: string;
|
|
152
|
+
sourceRevisionSetDigest: string;
|
|
153
|
+
ancestorHardAuthorityDigest: string;
|
|
154
|
+
}): ComposedScope;
|
|
155
|
+
export interface ScopeCompositionRevalidation {
|
|
156
|
+
stale: boolean;
|
|
157
|
+
sourceRevisionSetChanged: boolean;
|
|
158
|
+
ancestorHardAuthorityChanged: boolean;
|
|
159
|
+
effectiveProgramChanged: boolean;
|
|
160
|
+
effectiveRevisionChanged: boolean;
|
|
161
|
+
conflictSetChanged: boolean;
|
|
162
|
+
compatible: boolean;
|
|
163
|
+
taintRequired: boolean;
|
|
164
|
+
}
|
|
165
|
+
/** Reference-equivalent dependency check for an already materialized scope. */
|
|
166
|
+
export function compositionDependencyStale(previous: ComposedScope, next: ComposedScope): boolean;
|
|
167
|
+
/** Revalidation must be explicit before a changed composition can be served. */
|
|
168
|
+
export function revalidateScopeComposition(previous: ComposedScope, next: ComposedScope): ScopeCompositionRevalidation;
|
|
169
|
+
export function composeScope(input: {
|
|
170
|
+
chain: readonly HierarchicalScope[];
|
|
171
|
+
delegation?: ScopeDelegation | null;
|
|
172
|
+
now?: string;
|
|
173
|
+
availablePermissions?: readonly string[];
|
|
174
|
+
effectiveRevision?: EffectiveRevisionBinding;
|
|
175
|
+
sourceRevisions?: readonly ScopeBehaviorRevision[];
|
|
176
|
+
}): ComposedScope;
|
|
177
|
+
/** Compose all supplied delegations, rejecting duplicate ids and preserving one digest for runtime checks. */
|
|
178
|
+
export function composeDelegatedScope(input: {
|
|
179
|
+
chain: readonly HierarchicalScope[];
|
|
180
|
+
delegations: readonly ScopeDelegation[];
|
|
181
|
+
now?: string;
|
|
182
|
+
availablePermissions?: readonly string[];
|
|
183
|
+
effectiveRevision?: EffectiveRevisionBinding;
|
|
184
|
+
sourceRevisions?: readonly ScopeBehaviorRevision[];
|
|
185
|
+
}): ComposedScope;
|
|
186
|
+
/** Reference-shaped exception delegation: parent-authored, exact-child and digest-bound. */
|
|
187
|
+
export function composeReferenceDelegatedScope(input: {
|
|
188
|
+
chain: readonly HierarchicalScope[];
|
|
189
|
+
delegation: ReferenceScopeDelegation;
|
|
190
|
+
now?: string;
|
|
191
|
+
availablePermissions?: readonly string[];
|
|
192
|
+
effectiveRevision?: EffectiveRevisionBinding;
|
|
193
|
+
sourceRevisions?: readonly ScopeBehaviorRevision[];
|
|
194
|
+
}): ComposedScope;
|
|
195
|
+
}
|
|
196
|
+
declare module "runtime/src/mcp-gateway" {
|
|
197
|
+
export const MCP_PROTOCOL_VERSIONS: readonly ["2026-07-28", "2025-11-25", "2025-03-26"];
|
|
198
|
+
export function negotiateMcpProtocolVersion(offered: unknown): string;
|
|
199
|
+
import { type ComposedScope } from "domain/src/scope-composer";
|
|
200
|
+
import type { Scope } from "domain/src/vnext";
|
|
201
|
+
export interface McpInvocation extends Scope {
|
|
202
|
+
id: string;
|
|
203
|
+
server: string;
|
|
204
|
+
tool: string;
|
|
205
|
+
arguments: Record<string, unknown>;
|
|
206
|
+
receiptId: string;
|
|
207
|
+
idempotencyKey: string;
|
|
208
|
+
authorityDigest?: string;
|
|
209
|
+
composedScope?: ComposedScope;
|
|
210
|
+
}
|
|
211
|
+
export interface McpResult extends Scope {
|
|
212
|
+
invocationId: string;
|
|
213
|
+
ok: boolean;
|
|
214
|
+
result?: unknown;
|
|
215
|
+
error?: string;
|
|
216
|
+
provenanceDigest: string;
|
|
217
|
+
server: string;
|
|
218
|
+
tool: string;
|
|
219
|
+
receiptId: string;
|
|
220
|
+
idempotencyKey: string;
|
|
221
|
+
argumentsDigest: string;
|
|
222
|
+
authorityDecisionDigest: string;
|
|
223
|
+
authorityDigest?: string | null;
|
|
224
|
+
}
|
|
225
|
+
export interface McpTransport {
|
|
226
|
+
call(input: {
|
|
227
|
+
server: string;
|
|
228
|
+
tool: string;
|
|
229
|
+
arguments: Record<string, unknown>;
|
|
230
|
+
signal?: AbortSignal;
|
|
231
|
+
}): Promise<{
|
|
232
|
+
result?: unknown;
|
|
233
|
+
error?: string;
|
|
234
|
+
}>;
|
|
235
|
+
}
|
|
236
|
+
export interface McpToolDefinition {
|
|
237
|
+
name: string;
|
|
238
|
+
description?: string;
|
|
239
|
+
inputSchema: Record<string, unknown>;
|
|
240
|
+
effectful?: boolean;
|
|
241
|
+
}
|
|
242
|
+
export interface McpResourceDefinition {
|
|
243
|
+
uri: string;
|
|
244
|
+
name: string;
|
|
245
|
+
description?: string;
|
|
246
|
+
mimeType?: string;
|
|
247
|
+
}
|
|
248
|
+
export interface McpPromptDefinition {
|
|
249
|
+
name: string;
|
|
250
|
+
description?: string;
|
|
251
|
+
arguments?: readonly Record<string, unknown>[];
|
|
252
|
+
}
|
|
253
|
+
export interface McpAuthorityDecision {
|
|
254
|
+
allowed: boolean;
|
|
255
|
+
decisionDigest: string;
|
|
256
|
+
reason?: string;
|
|
257
|
+
}
|
|
258
|
+
export interface McpCancellationRegistry {
|
|
259
|
+
register(requestId: string): AbortSignal;
|
|
260
|
+
cancel(requestId: string): boolean;
|
|
261
|
+
unregister(requestId: string, signal?: AbortSignal): void;
|
|
262
|
+
}
|
|
263
|
+
export function canonicalMcpJson(value: unknown): string;
|
|
264
|
+
export function verifyMcpResult(result: McpResult): true;
|
|
265
|
+
export function createMcpCancellationRegistry(): McpCancellationRegistry;
|
|
266
|
+
export function parseMcpEventStream(body: string, expectedId?: string): readonly string[];
|
|
267
|
+
export function createRegisteredMcpTransport(input: {
|
|
268
|
+
endpoint: string;
|
|
269
|
+
allowedHosts: readonly string[];
|
|
270
|
+
fetcher?: typeof fetch;
|
|
271
|
+
timeoutMs?: number;
|
|
272
|
+
protocolVersion?: string;
|
|
273
|
+
headers?: Readonly<Record<string, string>>;
|
|
274
|
+
}): McpTransport;
|
|
275
|
+
export function handleMcpJsonRpc(input: {
|
|
276
|
+
request: {
|
|
277
|
+
jsonrpc: '2.0';
|
|
278
|
+
id?: string | number;
|
|
279
|
+
method: string;
|
|
280
|
+
params?: Record<string, unknown>;
|
|
281
|
+
};
|
|
282
|
+
server: string;
|
|
283
|
+
tools: readonly McpToolDefinition[];
|
|
284
|
+
resources?: readonly McpResourceDefinition[];
|
|
285
|
+
prompts?: readonly McpPromptDefinition[];
|
|
286
|
+
readResource?: (uri: string) => Promise<Record<string, unknown> | null> | Record<string, unknown> | null;
|
|
287
|
+
getPrompt?: (name: string, args: Record<string, unknown>) => Promise<Record<string, unknown> | null> | Record<string, unknown> | null;
|
|
288
|
+
invocation: Omit<McpInvocation, 'server' | 'tool' | 'arguments'>;
|
|
289
|
+
transport: McpTransport;
|
|
290
|
+
signal?: AbortSignal;
|
|
291
|
+
cancellationRegistry?: McpCancellationRegistry;
|
|
292
|
+
authorize?: (input: {
|
|
293
|
+
invocation: McpInvocation;
|
|
294
|
+
definition: McpToolDefinition;
|
|
295
|
+
}) => Promise<McpAuthorityDecision> | McpAuthorityDecision;
|
|
296
|
+
}): Promise<Record<string, unknown> | null>;
|
|
297
|
+
export function invokeMcpTool(input: {
|
|
298
|
+
invocation: McpInvocation;
|
|
299
|
+
transport: McpTransport;
|
|
300
|
+
authority?: McpAuthorityDecision;
|
|
301
|
+
signal?: AbortSignal;
|
|
302
|
+
}): Promise<McpResult>;
|
|
303
|
+
}
|
|
304
|
+
declare module "mcp/src/index" {
|
|
305
|
+
export * from "runtime/src/mcp-gateway";
|
|
306
|
+
}
|