@xpert-ai/plugin-sdk 3.18.7 → 3.19.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/CHANGELOG.md +19 -0
- package/MIDDLEWARE_APPS.md +71 -0
- package/README.md +2 -0
- package/index.cjs.js +132 -56
- package/index.esm.js +120 -57
- package/package.json +2 -2
- package/runtime-capabilities.md +35 -0
- package/src/index.d.ts +3 -0
- package/src/lib/agent/index.d.ts +1 -0
- package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +55 -20
- package/src/lib/agent/middleware/types.d.ts +13 -3
- package/src/lib/agent/runtime/capability.d.ts +29 -0
- package/src/lib/agent/runtime/index.d.ts +3 -0
- package/src/lib/agent/runtime/strategy.d.ts +50 -0
- package/src/lib/agent/runtime/types.d.ts +132 -0
- package/src/lib/assistant-capability/index.d.ts +42 -0
- package/src/lib/connector/runtime-capability.d.ts +2 -0
- package/src/lib/connector/strategy.interface.d.ts +8 -0
- package/src/lib/core/context/request-context.d.ts +6 -0
- package/src/lib/core/strategy-bus.d.ts +0 -3
- package/src/lib/evolution/runtime-capability.d.ts +2 -1
- package/src/lib/integration/strategy.interface.d.ts +22 -0
- package/src/lib/mcp/app.d.ts +10 -0
- package/src/lib/project-task/index.d.ts +59 -0
- package/src/lib/project-type/index.d.ts +64 -0
- package/src/lib/runtime/capabilities/knowledge-graph.d.ts +59 -0
- package/src/lib/runtime/capabilities/knowledgebase-documents.d.ts +21 -0
- package/src/lib/runtime/capabilities/knowledgebase.d.ts +8 -3
- package/src/lib/runtime/capabilities/project-access.d.ts +2 -1
- package/src/lib/runtime/capabilities/project-provisioning.d.ts +3 -0
- package/src/lib/runtime/runtime-scope.d.ts +7 -1
- package/src/lib/sandbox/execution-environment.d.ts +10 -0
- package/src/lib/sandbox/execution.d.ts +3 -0
- package/src/lib/sandbox/index.d.ts +1 -0
- package/src/lib/sandbox/protocol.d.ts +2 -0
- package/src/lib/tool-provider/types.d.ts +6 -0
- package/src/lib/types.d.ts +2 -1
- package/src/lib/workflow/trigger/strategy.interface.d.ts +2 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import type { RuntimeCapabilityRegistry } from '../../core/runtime-capability';
|
|
3
|
+
import { BaseStrategyRegistry, type StrategySource } from '../../strategy';
|
|
4
|
+
import type { AgentInvocationInput, AgentInvocationScope, AgentJson, AgentRuntimeCapabilities, AgentRuntimeHandle, AgentRuntimeObservation, AgentTarget } from './types';
|
|
5
|
+
/** Trusted per-operation host context, independent of graph and provider transport details. */
|
|
6
|
+
export interface AgentRuntimeContext {
|
|
7
|
+
/** Durable host invocation ID used to correlate provider receipts. */
|
|
8
|
+
invocationId: string;
|
|
9
|
+
scope: Readonly<AgentInvocationScope>;
|
|
10
|
+
/** Cooperative cancellation; abort alone does not confirm remote termination. */
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
capabilities: RuntimeCapabilityRegistry;
|
|
13
|
+
/** Persist a receipt before waiting on long-running work. Await persistence and propagate failures. */
|
|
14
|
+
checkpoint(observation: AgentRuntimeObservation): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** Pinned launch/recovery input supplied after the host reserves the invocation. */
|
|
17
|
+
export interface AgentRuntimeStart {
|
|
18
|
+
target: Readonly<AgentTarget>;
|
|
19
|
+
input: Readonly<AgentInvocationInput>;
|
|
20
|
+
/** Host invocation ID for provider idempotency; distinct from the caller callId. */
|
|
21
|
+
operationId: string;
|
|
22
|
+
/** Existing receipt for recovery. Reattach instead of resending the initial task. */
|
|
23
|
+
previous?: AgentRuntimeHandle;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Extension point for native and third-party runtimes. Strategies may serve concurrent calls;
|
|
27
|
+
* keep per-invocation state isolated. The host owns authorization and persistence.
|
|
28
|
+
*/
|
|
29
|
+
export interface IAgentRuntimeStrategy {
|
|
30
|
+
/** Support flags must agree with the optional methods implemented below. */
|
|
31
|
+
readonly capabilities: AgentRuntimeCapabilities;
|
|
32
|
+
/** Launch or recover approved work; checkpoint the handle as soon as it is known. */
|
|
33
|
+
start(request: AgentRuntimeStart, context: AgentRuntimeContext): Promise<AgentRuntimeObservation>;
|
|
34
|
+
/** Reconcile existing work without relaunching it. Return unknown if its outcome cannot be established. */
|
|
35
|
+
inspect(handle: AgentRuntimeHandle, context: AgentRuntimeContext): Promise<AgentRuntimeObservation>;
|
|
36
|
+
/** Required when cancellation is supported. Return cancelled only after termination is confirmed. */
|
|
37
|
+
cancel?(handle: AgentRuntimeHandle, context: AgentRuntimeContext): Promise<AgentRuntimeObservation>;
|
|
38
|
+
/** Required when interactions are supported. Validate the response against the pending interaction. */
|
|
39
|
+
respond?(handle: AgentRuntimeHandle, interactionId: string, response: AgentJson, context: AgentRuntimeContext): Promise<AgentRuntimeObservation>;
|
|
40
|
+
}
|
|
41
|
+
/** Nest discovery metadata key for runtime strategies. */
|
|
42
|
+
export declare const AGENT_RUNTIME_STRATEGY = "AGENT_RUNTIME_STRATEGY";
|
|
43
|
+
/** Associate a stable provider key with an adapter. Also declare @Injectable() and register the provider. */
|
|
44
|
+
export declare const AgentRuntimeStrategy: (provider: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
45
|
+
/** Scoped strategy registry with pinned provider/version lookup for continuation. */
|
|
46
|
+
export declare class AgentRuntimeRegistry extends BaseStrategyRegistry<IAgentRuntimeStrategy> {
|
|
47
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
48
|
+
/** Find the exact original scope/plugin/version, without fallback. Returns undefined if unavailable. */
|
|
49
|
+
getPinned(provider: string, source: StrategySource): IAgentRuntimeStrategy | undefined;
|
|
50
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** Serializable invocation data. Use finite numbers and plain objects; exclude credentials. */
|
|
2
|
+
export type AgentJson = null | boolean | number | string | AgentJson[] | {
|
|
3
|
+
[key: string]: AgentJson;
|
|
4
|
+
};
|
|
5
|
+
/** Host-authorized ownership and execution scope; never accept identities from model input. */
|
|
6
|
+
export interface AgentInvocationScope {
|
|
7
|
+
tenantId: string;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
userId: string;
|
|
10
|
+
workspaceId?: string;
|
|
11
|
+
projectId?: string;
|
|
12
|
+
/** Platform conversation ID, distinct from a provider session ID. */
|
|
13
|
+
conversationId?: string;
|
|
14
|
+
/** Opaque parent execution identity; host Task adapters may use logical IDs. */
|
|
15
|
+
parentExecutionId: string;
|
|
16
|
+
/** Calling Agent key or host-assigned background-task entry. */
|
|
17
|
+
callerAgentKey: string;
|
|
18
|
+
callerXpertId?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Authorized, version-pinned target. Pass the resolved snapshot unchanged. */
|
|
21
|
+
export interface AgentTarget {
|
|
22
|
+
/** Opaque host binding ID; do not assume UUID format or derive the provider from it. */
|
|
23
|
+
bindingId: string;
|
|
24
|
+
/** Registered AgentRuntimeStrategy key. */
|
|
25
|
+
provider: string;
|
|
26
|
+
/** Opaque configuration version, distinct from the invocation revision. */
|
|
27
|
+
revision: string;
|
|
28
|
+
/** Provider-specific target/profile reference. */
|
|
29
|
+
reference: string;
|
|
30
|
+
/** Validated configuration; use managed secret references instead of credentials. */
|
|
31
|
+
configuration: {
|
|
32
|
+
[key: string]: AgentJson;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Provider support flags; they do not grant caller permissions. */
|
|
36
|
+
export interface AgentRuntimeCapabilities {
|
|
37
|
+
/**
|
|
38
|
+
* Recovery by host checkpoint, existing provider session, or none.
|
|
39
|
+
* Session recovery does not guarantee survival of a worker crash.
|
|
40
|
+
*/
|
|
41
|
+
recovery: 'checkpoint' | 'session' | 'none';
|
|
42
|
+
interactions: boolean;
|
|
43
|
+
/** Supports cancel requests; termination still requires provider confirmation. */
|
|
44
|
+
cancellation: boolean;
|
|
45
|
+
/** Work can continue after start() returns. */
|
|
46
|
+
background: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Only succeeded, failed and cancelled are terminal.
|
|
50
|
+
* waiting requires continuation; cancelling awaits confirmation.
|
|
51
|
+
* unknown means the outcome is uncertain: reconcile before launching new work.
|
|
52
|
+
*/
|
|
53
|
+
export type AgentInvocationStatus = 'queued' | 'running' | 'waiting' | 'cancelling' | 'succeeded' | 'failed' | 'cancelled' | 'unknown';
|
|
54
|
+
/** Provider-neutral task payload; supported structured fields depend on the adapter. */
|
|
55
|
+
export interface AgentInvocationInput {
|
|
56
|
+
prompt: string;
|
|
57
|
+
parameters?: {
|
|
58
|
+
[key: string]: AgentJson;
|
|
59
|
+
};
|
|
60
|
+
context?: {
|
|
61
|
+
[key: string]: AgentJson;
|
|
62
|
+
};
|
|
63
|
+
/** Host-managed file references, authorized and materialized by the adapter. */
|
|
64
|
+
files?: Array<{
|
|
65
|
+
id: string;
|
|
66
|
+
name?: string;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
/** Output or in-progress receipt. Check invocation status before treating it as final. */
|
|
70
|
+
export interface AgentInvocationResult {
|
|
71
|
+
text: string;
|
|
72
|
+
/** Adapter-defined structured output. */
|
|
73
|
+
data?: AgentJson;
|
|
74
|
+
/** Host-managed output references; normal artifact authorization applies. */
|
|
75
|
+
artifacts?: Array<{
|
|
76
|
+
id: string;
|
|
77
|
+
name?: string;
|
|
78
|
+
mimeType?: string;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/** Persisted provider receipt. Session/run IDs are distinct from the host invocation ID. */
|
|
82
|
+
export interface AgentRuntimeHandle {
|
|
83
|
+
sessionId: string;
|
|
84
|
+
runId: string;
|
|
85
|
+
metadata?: {
|
|
86
|
+
[key: string]: AgentJson;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Pending question or approval. Respond using its exact ID and provider-defined data schema. */
|
|
90
|
+
export interface AgentInteraction {
|
|
91
|
+
id: string;
|
|
92
|
+
kind: 'approval' | 'input';
|
|
93
|
+
prompt: string;
|
|
94
|
+
data?: AgentJson;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Partial provider observation; omitted fields may retain previously stored values.
|
|
98
|
+
* The host manages identity, revisions and persistence.
|
|
99
|
+
*/
|
|
100
|
+
export interface AgentRuntimeObservation {
|
|
101
|
+
/** succeeded requires a result, even for structured-only output. */
|
|
102
|
+
status: AgentInvocationStatus;
|
|
103
|
+
handle?: AgentRuntimeHandle;
|
|
104
|
+
result?: AgentInvocationResult;
|
|
105
|
+
interaction?: AgentInteraction;
|
|
106
|
+
/** Safe diagnostic message without credentials or raw provider payloads. */
|
|
107
|
+
error?: string;
|
|
108
|
+
}
|
|
109
|
+
/** Request pinned by the host before dispatch. */
|
|
110
|
+
export interface AgentInvocationRequest {
|
|
111
|
+
target: AgentTarget;
|
|
112
|
+
/**
|
|
113
|
+
* Idempotency key within the captured scope (max 1024 characters).
|
|
114
|
+
* Reuse for the same request; changed input or target is a conflict.
|
|
115
|
+
*/
|
|
116
|
+
callId: string;
|
|
117
|
+
input: AgentInvocationInput;
|
|
118
|
+
}
|
|
119
|
+
/** Host-owned invocation snapshot; not an update DTO. */
|
|
120
|
+
export interface AgentInvocation extends AgentRuntimeObservation {
|
|
121
|
+
/** Host invocation ID used by inspect, cancel and respond. */
|
|
122
|
+
id: string;
|
|
123
|
+
/** Host-managed concurrency revision, distinct from the target version. */
|
|
124
|
+
revision: number;
|
|
125
|
+
scope: AgentInvocationScope;
|
|
126
|
+
request: AgentInvocationRequest;
|
|
127
|
+
/** Host timestamps in ISO 8601 format. */
|
|
128
|
+
createdAt: string;
|
|
129
|
+
updatedAt: string;
|
|
130
|
+
}
|
|
131
|
+
/** Checks confirmed completion; unknown remains non-terminal. */
|
|
132
|
+
export declare function isAgentInvocationTerminal(status: AgentInvocationStatus): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import type { I18nObject, LanguagesEnum, ModelFeature, TXpertTeamDraft, TXpertTemplate } from '@xpert-ai/contracts';
|
|
3
|
+
import { BaseStrategyRegistry } from '../strategy';
|
|
4
|
+
export interface AssistantCapabilityContext {
|
|
5
|
+
template: TXpertTemplate;
|
|
6
|
+
draft: TXpertTeamDraft;
|
|
7
|
+
language: LanguagesEnum;
|
|
8
|
+
/** Provided again at installation; providers must not silently select a fallback. */
|
|
9
|
+
sandboxProviders?: {
|
|
10
|
+
type: string;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
export interface AssistantCapabilityApplyContext extends AssistantCapabilityContext {
|
|
14
|
+
loadTemplate: (id: string) => Promise<TXpertTemplate>;
|
|
15
|
+
}
|
|
16
|
+
/** Optional capabilities default to off. IDs are stable machine-readable keys. */
|
|
17
|
+
export interface IAssistantCapabilityProvider {
|
|
18
|
+
readonly key: string;
|
|
19
|
+
readonly label: string | I18nObject;
|
|
20
|
+
readonly description: string | I18nObject;
|
|
21
|
+
readonly requiredModelFeatures?: ModelFeature[];
|
|
22
|
+
/** Explicitly opt into the blank Assistant creation flow. */
|
|
23
|
+
readonly availableForBlankAssistant?: boolean;
|
|
24
|
+
/** Distribution extensions to specific templates, without changing their portable source. */
|
|
25
|
+
readonly templates?: {
|
|
26
|
+
templateId: string;
|
|
27
|
+
required: boolean;
|
|
28
|
+
}[];
|
|
29
|
+
/** Detect a capability already owned by the base workflow; it cannot be removed by a new overlay. */
|
|
30
|
+
isEnabled?(draft: TXpertTeamDraft): boolean;
|
|
31
|
+
check(context: AssistantCapabilityContext): Promise<{
|
|
32
|
+
available: boolean;
|
|
33
|
+
reason?: string;
|
|
34
|
+
}>;
|
|
35
|
+
/** Deterministic draft composition; never creates external resources. */
|
|
36
|
+
apply(context: AssistantCapabilityApplyContext): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare const ASSISTANT_CAPABILITY_PROVIDER = "ASSISTANT_CAPABILITY_PROVIDER";
|
|
39
|
+
export declare const AssistantCapabilityProvider: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
40
|
+
export declare class AssistantCapabilityProviderRegistry extends BaseStrategyRegistry<IAssistantCapabilityProvider> {
|
|
41
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
42
|
+
}
|
|
@@ -3,6 +3,8 @@ import type { ConnectorRuntimeApi } from './strategy.interface';
|
|
|
3
3
|
export declare const ConnectorRuntimeCapability: import("../core").RuntimeCapabilityKey<ConnectorRuntimeApi>;
|
|
4
4
|
/** No binding or provider grants means no connector access. */
|
|
5
5
|
export type ConnectorRuntimeScope = RuntimeIdentityScope & {
|
|
6
|
+
/** Host-validated Agent Plugin dependencies may use their workspace binding in an authorized project. */
|
|
7
|
+
allowWorkspaceBindingsInProject?: boolean;
|
|
6
8
|
/** Host-selected bindings, including IDs pinned by enabled graph Connector nodes. */
|
|
7
9
|
connectorBindingIds?: string[] | null;
|
|
8
10
|
/** Providers configured by enabled graph Connector nodes without a pinned ID. */
|
|
@@ -72,6 +72,7 @@ export type ConnectorPermissionDeclaration = {
|
|
|
72
72
|
required?: boolean;
|
|
73
73
|
};
|
|
74
74
|
export type ConnectorDefinitionBase = {
|
|
75
|
+
runtimeUsage?: 'middleware' | 'credential';
|
|
75
76
|
provider: string;
|
|
76
77
|
label: RuntimeI18nText;
|
|
77
78
|
description?: RuntimeI18nText;
|
|
@@ -139,6 +140,10 @@ export type ConnectorBindingCreateRequest = {
|
|
|
139
140
|
authorizationMode: ConnectorAuthorizationMode;
|
|
140
141
|
};
|
|
141
142
|
export type ConnectorRuntimeOption = {
|
|
143
|
+
scope?: ConnectorScope;
|
|
144
|
+
canManage?: boolean;
|
|
145
|
+
managementUrl?: string;
|
|
146
|
+
runtimeUsage?: 'middleware' | 'credential';
|
|
142
147
|
bindingId: string;
|
|
143
148
|
provider: string;
|
|
144
149
|
authorizationMode: ConnectorAuthorizationMode;
|
|
@@ -152,6 +157,9 @@ export type ConnectorRuntimeOption = {
|
|
|
152
157
|
profile?: ConnectorProfile | null;
|
|
153
158
|
};
|
|
154
159
|
export type ConnectorRuntimeOptions = {
|
|
160
|
+
workspaceScope?: ConnectorScope;
|
|
161
|
+
canManageWorkspace?: boolean;
|
|
162
|
+
managementUrl?: string;
|
|
155
163
|
scope: ConnectorScope;
|
|
156
164
|
items: ConnectorRuntimeOption[];
|
|
157
165
|
};
|
|
@@ -28,6 +28,11 @@ export declare class RequestContext {
|
|
|
28
28
|
static isTenantScope(): boolean;
|
|
29
29
|
static isOrganizationScope(): boolean;
|
|
30
30
|
static requireOrganizationScope(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Check the authenticated principal's enabled role permissions, matching the
|
|
33
|
+
* server RequestContext. Authentication guards resolve JWTs, API keys and
|
|
34
|
+
* ChatKit client secrets before this check; the bearer is not always a JWT.
|
|
35
|
+
*/
|
|
31
36
|
static hasPermissions(findPermissions: Array<PermissionsEnum | string>, throwError?: boolean): boolean;
|
|
32
37
|
static hasAnyPermission(findPermissions: PermissionsEnum[], throwError?: boolean): boolean;
|
|
33
38
|
static currentToken(throwError?: boolean): any;
|
|
@@ -46,6 +51,7 @@ export declare class RequestContext {
|
|
|
46
51
|
* @returns True if any of the required roles are found, otherwise false.
|
|
47
52
|
*/
|
|
48
53
|
static hasRoles(roles: RolesEnum[], throwError?: boolean): boolean;
|
|
54
|
+
private static currentPermissions;
|
|
49
55
|
}
|
|
50
56
|
/**
|
|
51
57
|
* One process-wide context store shared by source, built, and dynamically loaded
|
|
@@ -11,9 +11,6 @@ export type StrategyBusEvent<S = any> = {
|
|
|
11
11
|
cause?: 'refresh' | 'uninstall';
|
|
12
12
|
};
|
|
13
13
|
export declare class StrategyBus {
|
|
14
|
-
private readonly removalGuards;
|
|
15
|
-
registerRemovalGuard(guard: (scopeKey: string, pluginNames: readonly string[]) => Promise<void>): () => void;
|
|
16
|
-
assertCanRemove(scopeKey: string, pluginNames: readonly string[]): Promise<void>;
|
|
17
14
|
private readonly subject;
|
|
18
15
|
readonly events$: import("rxjs").Observable<StrategyBusEvent<any>>;
|
|
19
16
|
upsert<S>(strategyType: string, entry: StrategyEntry<S>): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { EvolutionRuntimeApi, EvolutionChangeRuntimeApi } from '@xpert-ai/contracts';
|
|
1
|
+
import type { EvolutionRuntimeApi, EvolutionChangeRuntimeApi, EvolutionBaselineRuntimeApi } from '@xpert-ai/contracts';
|
|
2
2
|
export declare const EVOLUTION_RUNTIME_SERVICE_TOKEN = "XPERT_EVOLUTION_RUNTIME_SERVICE";
|
|
3
|
+
export declare const EvolutionBaselineRuntimeCapability: import("../core").RuntimeCapabilityKey<EvolutionBaselineRuntimeApi>;
|
|
3
4
|
export declare const EvolutionRuntimeCapability: import("../core").RuntimeCapabilityKey<EvolutionRuntimeApi>;
|
|
4
5
|
export declare const EvolutionChangeRuntimeCapability: import("../core").RuntimeCapabilityKey<EvolutionChangeRuntimeApi>;
|
|
@@ -40,4 +40,26 @@ export interface IntegrationStrategy<T = unknown> {
|
|
|
40
40
|
validateConfig?(config: T, integration?: IIntegration<T>): Promise<void | IntegrationTestResult>;
|
|
41
41
|
getIdentityBootstrap?(integration: IIntegration<T>): Promise<IntegrationIdentityBootstrap>;
|
|
42
42
|
exchangeIdentity?(integration: IIntegration<T>, grant: IntegrationIdentityGrant): Promise<IntegrationExternalIdentity>;
|
|
43
|
+
beginQrAuthorization?(): Promise<IntegrationQrAuthorization>;
|
|
44
|
+
pollQrAuthorization?(deviceCode: string): Promise<IntegrationQrAuthorizationResult>;
|
|
45
|
+
/** Stable provider account identity used to reuse integrations within the same tenant and organization. */
|
|
46
|
+
getQrAuthorizationIdentity?(options: unknown): string | null;
|
|
43
47
|
}
|
|
48
|
+
/** Server-only setup contract. Never forward deviceCode or options to the browser. */
|
|
49
|
+
export interface IntegrationQrAuthorization {
|
|
50
|
+
deviceCode: string;
|
|
51
|
+
authorizationUrl: string;
|
|
52
|
+
expiresInSeconds: number;
|
|
53
|
+
intervalSeconds: number;
|
|
54
|
+
}
|
|
55
|
+
export type IntegrationQrAuthorizationResult =
|
|
56
|
+
/** Additive provider backoff, persisted by the host for the rest of the session. */
|
|
57
|
+
{
|
|
58
|
+
status: 'waiting';
|
|
59
|
+
intervalIncrementSeconds?: number;
|
|
60
|
+
} | {
|
|
61
|
+
status: 'expired' | 'denied' | 'failed';
|
|
62
|
+
} | {
|
|
63
|
+
status: 'authorized';
|
|
64
|
+
options: Record<string, unknown>;
|
|
65
|
+
};
|
package/src/lib/mcp/app.d.ts
CHANGED
|
@@ -16,4 +16,14 @@ export interface McpAppDefinition {
|
|
|
16
16
|
csp?: McpAppCsp;
|
|
17
17
|
permissions?: McpAppPermissions;
|
|
18
18
|
}
|
|
19
|
+
/** App exposure is independent of publishing a tool on an external MCP server. */
|
|
20
|
+
export interface MiddlewareMcpApps {
|
|
21
|
+
definitions: readonly McpAppDefinition[];
|
|
22
|
+
tools: Readonly<Record<string, {
|
|
23
|
+
resourceKey?: string;
|
|
24
|
+
visibility: readonly ('model' | 'app')[];
|
|
25
|
+
/** Trusted plugin policy; omitted writes use the host approval flow. */
|
|
26
|
+
approval?: 'required' | 'none';
|
|
27
|
+
}>>;
|
|
28
|
+
}
|
|
19
29
|
export declare function defineMcpApp(definition: McpAppDefinition): Readonly<McpAppDefinition>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import type { ProjectTaskGraph, ProjectTaskGraphChange, ProjectTaskExecutionTarget, TXpertProjectTaskStatus } from '@xpert-ai/contracts';
|
|
3
|
+
import { BaseStrategyRegistry } from '../strategy';
|
|
4
|
+
import type { ProjectAccessActor } from '../runtime/capabilities/project-access';
|
|
5
|
+
export interface ProjectTaskContext {
|
|
6
|
+
actor: ProjectAccessActor;
|
|
7
|
+
projectId: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ProjectTaskProjection {
|
|
10
|
+
key: string;
|
|
11
|
+
title: string;
|
|
12
|
+
status: TXpertProjectTaskStatus;
|
|
13
|
+
kind: 'task' | 'summary' | 'milestone';
|
|
14
|
+
parentKey?: string;
|
|
15
|
+
predecessorKeys: string[];
|
|
16
|
+
diagnostic?: string;
|
|
17
|
+
assigneeXpertId?: string;
|
|
18
|
+
executions: Array<{
|
|
19
|
+
key: string;
|
|
20
|
+
attempt: number;
|
|
21
|
+
agentExecutionId?: string;
|
|
22
|
+
conversationId?: string;
|
|
23
|
+
threadId?: string;
|
|
24
|
+
xpertId?: string;
|
|
25
|
+
agentKey?: string;
|
|
26
|
+
status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
27
|
+
startedAt?: string;
|
|
28
|
+
completedAt?: string;
|
|
29
|
+
error?: string;
|
|
30
|
+
outputSummary?: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
/** Domain facts remain durable in the provider; projection can be replayed after interruption. */
|
|
34
|
+
export interface ProjectTaskSnapshot {
|
|
35
|
+
revision: string;
|
|
36
|
+
tasks: ProjectTaskProjection[];
|
|
37
|
+
}
|
|
38
|
+
export interface IProjectTaskProvider {
|
|
39
|
+
readonly key: string;
|
|
40
|
+
/** Return null when the project is not owned by this provider. Always scope domain reads. */
|
|
41
|
+
snapshot(context: ProjectTaskContext): Promise<ProjectTaskSnapshot | null>;
|
|
42
|
+
/** Called after projection commits; retries must be idempotent. Never start work here. */
|
|
43
|
+
linked?(context: ProjectTaskContext, links: Array<{
|
|
44
|
+
sourceKey: string;
|
|
45
|
+
taskId: string;
|
|
46
|
+
}>): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export declare const PROJECT_TASK_PROVIDER = "PROJECT_TASK_PROVIDER";
|
|
49
|
+
export declare const ProjectTaskProvider: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
50
|
+
export declare class ProjectTaskProviderRegistry extends BaseStrategyRegistry<IProjectTaskProvider> {
|
|
51
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
52
|
+
}
|
|
53
|
+
/** ORM-independent project task management; actor values come from trusted server context. */
|
|
54
|
+
export interface ProjectTasksApi {
|
|
55
|
+
graph(context: ProjectTaskContext): Promise<ProjectTaskGraph>;
|
|
56
|
+
change(context: ProjectTaskContext, input: ProjectTaskGraphChange): Promise<ProjectTaskGraph>;
|
|
57
|
+
resolveExecution(context: ProjectTaskContext, taskExecutionId: string): Promise<ProjectTaskExecutionTarget>;
|
|
58
|
+
}
|
|
59
|
+
export declare const ProjectTasksRuntimeCapability: import("../core/runtime-capability").RuntimeCapabilityKey<ProjectTasksApi>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import type { XpertProjectTypeRef } from '@xpert-ai/contracts';
|
|
3
|
+
import { BaseStrategyRegistry } from '../strategy';
|
|
4
|
+
export interface ProjectTypeContext extends XpertProjectTypeRef {
|
|
5
|
+
tenantId: string;
|
|
6
|
+
organizationId?: string | null;
|
|
7
|
+
userId: string;
|
|
8
|
+
xpertId: string;
|
|
9
|
+
purpose: 'provision' | 'open' | 'create';
|
|
10
|
+
}
|
|
11
|
+
export interface ProjectTypeBinding {
|
|
12
|
+
/** Persisted business Assistant used when opening a Project from the global list. */
|
|
13
|
+
xpertId?: string;
|
|
14
|
+
viewKey: string;
|
|
15
|
+
selectionId?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* ORM-independent write access to the host's current creation transaction.
|
|
19
|
+
* The host owns commit/rollback; this object is valid only during the awaited
|
|
20
|
+
* creation hook. Entities must be instances of registered plugin entity classes.
|
|
21
|
+
*/
|
|
22
|
+
export interface ProjectCreationTransaction {
|
|
23
|
+
/** Save an entity and return its persisted values without committing the transaction. */
|
|
24
|
+
save<T extends object>(entity: T): Promise<T>;
|
|
25
|
+
}
|
|
26
|
+
/** Host-owned identity and transaction for an empty conversation's first send. */
|
|
27
|
+
export interface ConversationProjectCreation {
|
|
28
|
+
projectId: string;
|
|
29
|
+
conversationId: string;
|
|
30
|
+
workspaceId: string;
|
|
31
|
+
name: string;
|
|
32
|
+
/**
|
|
33
|
+
* Persist only application records through this writer. The host creates the
|
|
34
|
+
* platform Project and binds the conversation in the same transaction. Do not
|
|
35
|
+
* call provisioning, start agents, or perform external I/O from this hook.
|
|
36
|
+
*/
|
|
37
|
+
transaction: ProjectCreationTransaction;
|
|
38
|
+
}
|
|
39
|
+
/** Host calls this provider before claiming or synchronizing an entity Project. */
|
|
40
|
+
export interface IProjectTypeProvider {
|
|
41
|
+
/** Must verify the persisted domain-to-project link and actor before returning. */
|
|
42
|
+
resolve(context: ProjectTypeContext, projectId: string): Promise<ProjectTypeBinding & {
|
|
43
|
+
name: string;
|
|
44
|
+
status: 'active' | 'archived';
|
|
45
|
+
}>;
|
|
46
|
+
/** Opens the application's governed creation workflow. */
|
|
47
|
+
createEntry(context: ProjectTypeContext): Promise<ProjectTypeBinding>;
|
|
48
|
+
/**
|
|
49
|
+
* Optional opt-in to first-send creation. Persist the business entity and its
|
|
50
|
+
* link to input.projectId atomically using input.transaction, then return its entry
|
|
51
|
+
* and desired name. Exceptions roll back the whole bootstrap. The host checks
|
|
52
|
+
* permissions and serializes retries with a conversation row lock first.
|
|
53
|
+
*/
|
|
54
|
+
createForConversation?(context: ProjectTypeContext, input: ConversationProjectCreation): Promise<ProjectTypeBinding & {
|
|
55
|
+
name: string;
|
|
56
|
+
status: 'active';
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
export declare const PROJECT_TYPE_PROVIDER = "PROJECT_TYPE_PROVIDER";
|
|
60
|
+
/** Register the stable provider key used by entity-backed App project type declarations. */
|
|
61
|
+
export declare const ProjectTypeProvider: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
62
|
+
export declare class ProjectTypeProviderRegistry extends BaseStrategyRegistry<IProjectTypeProvider> {
|
|
63
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
64
|
+
}
|
|
@@ -46,6 +46,9 @@ export type KnowledgeGraphPublicationResult = {
|
|
|
46
46
|
error?: string | null;
|
|
47
47
|
};
|
|
48
48
|
export interface KnowledgeGraphApi {
|
|
49
|
+
/** Bounded, source-version-checked reads; the host verifies the current Agent's KB connection. */
|
|
50
|
+
queryEntities?(input: KnowledgeGraphEntityQuery): Promise<KnowledgeGraphReadResult>;
|
|
51
|
+
readNeighborhood?(input: KnowledgeGraphNeighborhoodQuery): Promise<KnowledgeGraphReadResult>;
|
|
49
52
|
/** Atomically accepts a complete, validated snapshot. Indexing is durable and retryable. */
|
|
50
53
|
publish(input: KnowledgeGraphPublishInput): Promise<KnowledgeGraphPublicationResult>;
|
|
51
54
|
status(input: KnowledgeGraphPublicationOwner): Promise<KnowledgeGraphPublicationResult | null>;
|
|
@@ -56,4 +59,60 @@ export interface KnowledgeGraphApi {
|
|
|
56
59
|
chunkIds: string[];
|
|
57
60
|
}): Promise<KnowledgeGraphPublicationResult>;
|
|
58
61
|
}
|
|
62
|
+
export type KnowledgeGraphReadScope = {
|
|
63
|
+
knowledgebaseId: string;
|
|
64
|
+
xpertId: string;
|
|
65
|
+
agentKey: string;
|
|
66
|
+
sources: {
|
|
67
|
+
documentId: string;
|
|
68
|
+
sourceVersion: string;
|
|
69
|
+
}[];
|
|
70
|
+
};
|
|
71
|
+
export type KnowledgeGraphEntityQuery = KnowledgeGraphReadScope & {
|
|
72
|
+
entityIds?: string[];
|
|
73
|
+
namespace?: string;
|
|
74
|
+
nodeKey?: string;
|
|
75
|
+
type?: string;
|
|
76
|
+
search?: string;
|
|
77
|
+
/** Opaque continuation bound to this query and its source versions. */
|
|
78
|
+
cursor?: string;
|
|
79
|
+
limit?: number;
|
|
80
|
+
};
|
|
81
|
+
export type KnowledgeGraphNeighborhoodQuery = KnowledgeGraphReadScope & {
|
|
82
|
+
entityIds: string[];
|
|
83
|
+
relationTypes: string[];
|
|
84
|
+
depth?: number;
|
|
85
|
+
direction?: 'incoming' | 'outgoing' | 'both';
|
|
86
|
+
/** Continuation is supported for one-hop reads only. */
|
|
87
|
+
cursor?: string;
|
|
88
|
+
limit?: number;
|
|
89
|
+
};
|
|
90
|
+
export type KnowledgeGraphReadEntity = {
|
|
91
|
+
id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
type: string;
|
|
94
|
+
properties: Record<string, JSONValue>;
|
|
95
|
+
documentId: string;
|
|
96
|
+
documentIds?: string[];
|
|
97
|
+
};
|
|
98
|
+
export type KnowledgeGraphReadRelation = {
|
|
99
|
+
id: string;
|
|
100
|
+
source: string;
|
|
101
|
+
target: string;
|
|
102
|
+
type: string;
|
|
103
|
+
properties: Record<string, JSONValue>;
|
|
104
|
+
documentId: string;
|
|
105
|
+
documentIds?: string[];
|
|
106
|
+
};
|
|
107
|
+
export type KnowledgeGraphReadResult = {
|
|
108
|
+
entities: KnowledgeGraphReadEntity[];
|
|
109
|
+
relations: KnowledgeGraphReadRelation[];
|
|
110
|
+
truncated: boolean;
|
|
111
|
+
nextCursor?: string;
|
|
112
|
+
sources: {
|
|
113
|
+
documentId: string;
|
|
114
|
+
sourceVersion: string;
|
|
115
|
+
status: KnowledgeGraphPublicationResult['status'] | 'unavailable' | 'stale';
|
|
116
|
+
}[];
|
|
117
|
+
};
|
|
59
118
|
export declare const KnowledgeGraphRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<KnowledgeGraphApi>;
|
|
@@ -219,6 +219,25 @@ export type KnowledgebaseReadTextResult = {
|
|
|
219
219
|
version: number;
|
|
220
220
|
}>;
|
|
221
221
|
};
|
|
222
|
+
/** Pre-split conversion evidence. Index chunk size and embedding models do not affect this view. */
|
|
223
|
+
export type KnowledgebaseReadSourceInput = KnowledgebaseReadTextInput & {
|
|
224
|
+
/** Pin all pages to the revision returned by the first page. */
|
|
225
|
+
revision?: string;
|
|
226
|
+
};
|
|
227
|
+
export type KnowledgebaseReadSourceResult = {
|
|
228
|
+
knowledgebaseId: string;
|
|
229
|
+
documentId: string;
|
|
230
|
+
/** Content identity of the complete parsed source, independent of index/document versions. */
|
|
231
|
+
revision: string;
|
|
232
|
+
sourceHash?: string | null;
|
|
233
|
+
total: number;
|
|
234
|
+
/** Complete converter blocks in source order, never vector fragments or overlapping windows. */
|
|
235
|
+
chunks: Array<{
|
|
236
|
+
id: string;
|
|
237
|
+
text: string;
|
|
238
|
+
page?: number;
|
|
239
|
+
}>;
|
|
240
|
+
};
|
|
222
241
|
export type KnowledgebaseProcessingOptionsInput = {
|
|
223
242
|
knowledgebaseId: string;
|
|
224
243
|
fileName: string;
|
|
@@ -249,6 +268,8 @@ export type KnowledgebaseProcessingOptionsResult = {
|
|
|
249
268
|
export interface KnowledgebaseDocumentsApi {
|
|
250
269
|
getProcessingOptions(input: KnowledgebaseProcessingOptionsInput): Promise<KnowledgebaseProcessingOptionsResult>;
|
|
251
270
|
readText(input: KnowledgebaseReadTextInput): Promise<KnowledgebaseReadTextResult>;
|
|
271
|
+
/** Missing/stale conversion snapshots fail explicitly; this never falls back to indexed chunks. */
|
|
272
|
+
readSource(input: KnowledgebaseReadSourceInput): Promise<KnowledgebaseReadSourceResult>;
|
|
252
273
|
listDocuments(input: KnowledgebaseListDocumentsInput): Promise<KnowledgebaseListDocumentsResult>;
|
|
253
274
|
createFolder(input: KnowledgebaseCreateFolderInput): Promise<KnowledgebaseCreateFolderResult>;
|
|
254
275
|
moveDocument(input: KnowledgebaseMoveDocumentInput): Promise<KnowledgebaseMoveDocumentResult>;
|
|
@@ -129,14 +129,19 @@ export type KnowledgebaseProvisioningSpec = {
|
|
|
129
129
|
score?: number;
|
|
130
130
|
metadataSchema?: KnowledgebaseProvisioningMetadataField[];
|
|
131
131
|
incrementalSyncEnabled?: boolean;
|
|
132
|
+
/** Set the graph switch without replacing existing graph retrieval or extraction settings. */
|
|
133
|
+
graphRag?: {
|
|
134
|
+
enabled: boolean;
|
|
135
|
+
};
|
|
132
136
|
};
|
|
133
137
|
export type KnowledgebaseEnsureInput = {
|
|
134
138
|
workspaceId: string;
|
|
135
139
|
namespace: string;
|
|
136
140
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
141
|
+
* Fill missing embedding bindings from the current user's available Copilot provider catalog,
|
|
142
|
+
* falling back to the most recently updated ordinary knowledgebase in this workspace.
|
|
143
|
+
* Existing bindings are preserved. No provider credentials are exposed to plugins.
|
|
144
|
+
* Provisioning fails explicitly when a missing binding cannot be resolved.
|
|
140
145
|
*/
|
|
141
146
|
inheritEmbeddingModel?: boolean;
|
|
142
147
|
knowledgebases: KnowledgebaseProvisioningSpec[];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { XpertProjectClassification } from '@xpert-ai/contracts';
|
|
1
2
|
/** Trusted server actor. View providers derive this from host context; jobs persist that actor. */
|
|
2
3
|
export interface ProjectAccessActor {
|
|
3
4
|
tenantId: string;
|
|
4
5
|
organizationId?: string | null;
|
|
5
6
|
userId: string;
|
|
6
7
|
}
|
|
7
|
-
export interface ProjectHumanAccess {
|
|
8
|
+
export interface ProjectHumanAccess extends XpertProjectClassification {
|
|
8
9
|
projectId: string;
|
|
9
10
|
role: 'owner' | 'manager' | 'editor' | 'member';
|
|
10
11
|
canManage: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { XpertProjectTypeRef } from '@xpert-ai/contracts';
|
|
1
2
|
/** Lifecycle states that plugin-managed Projects may synchronize to the platform. */
|
|
2
3
|
export type ProjectProvisioningStatus = 'active' | 'archived';
|
|
3
4
|
/** Portable identity of one required, direct External Assistant binding. */
|
|
@@ -8,6 +9,8 @@ export type ProjectExternalAssistantExpectation = {
|
|
|
8
9
|
};
|
|
9
10
|
/** Stable identity and desired state for an idempotently provisioned Chat Project. */
|
|
10
11
|
export type ProjectEnsureInput = {
|
|
12
|
+
/** Registered application type. Omission preserves legacy unclassified callers. */
|
|
13
|
+
projectType?: XpertProjectTypeRef;
|
|
11
14
|
/** Caller-generated id reused across retries to prevent duplicate Projects. */
|
|
12
15
|
projectId: string;
|
|
13
16
|
/** @deprecated Projects no longer belong to a Workspace. Accepted only for legacy callers. */
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Trusted host context for scoped service factories. Each capability validates its required fields;
|
|
3
|
+
* missing values do not grant broader access. Do not accept this scope from model input.
|
|
4
|
+
*/
|
|
2
5
|
export type RuntimeIdentityScope = {
|
|
3
6
|
tenantId?: string | null;
|
|
4
7
|
organizationId?: string | null;
|
|
@@ -8,7 +11,10 @@ export type RuntimeIdentityScope = {
|
|
|
8
11
|
xpertId?: string | null;
|
|
9
12
|
xpertName?: string | null;
|
|
10
13
|
conversationId?: string | null;
|
|
14
|
+
/** Platform checkpoint thread, distinct from a provider session ID. */
|
|
11
15
|
threadId?: string | null;
|
|
16
|
+
/** Agent entry key within the calling Assistant. */
|
|
12
17
|
agentKey?: string | null;
|
|
18
|
+
/** Current platform execution; trusted adapters may supply it lazily. */
|
|
13
19
|
executionId?: string | null;
|
|
14
20
|
};
|