@xpert-ai/plugin-sdk 3.19.0 → 3.20.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 +104 -0
- package/README.md +55 -0
- package/RESOURCE-CARDS-VALIDATION.md +51 -0
- package/RESOURCE-CARDS.md +361 -0
- package/TOOL-IMAGES.md +85 -0
- package/agent-results.cjs.default.js +1 -0
- package/agent-results.cjs.js +20 -0
- package/agent-results.cjs.mjs +2 -0
- package/agent-results.d.ts +1 -0
- package/agent-results.esm.js +4 -0
- package/index.cjs.js +455 -107
- package/index.esm.js +412 -112
- package/model-provider.cjs.js +5 -0
- package/model-provider.esm.js +5 -1
- package/package.json +8 -2
- package/results.cjs.js +50 -0
- package/results.esm.js +46 -0
- package/src/agent-results.d.ts +2 -0
- package/src/index.d.ts +2 -0
- package/src/lib/agent/handoff/agent-chat.contract.d.ts +6 -1
- package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +319 -0
- package/src/lib/agent/handoff/index.d.ts +1 -0
- package/src/lib/agent/index.d.ts +1 -0
- package/src/lib/agent/middleware/index.d.ts +1 -0
- package/src/lib/agent/middleware/model-requirements.d.ts +9 -0
- package/src/lib/agent/middleware/strategy.interface.d.ts +4 -0
- package/src/lib/agent/middleware/types.d.ts +7 -0
- package/src/lib/agent/resource-card.d.ts +3 -0
- package/src/lib/agent/runtime/activity.d.ts +6 -0
- package/src/lib/agent/runtime/capability.d.ts +13 -5
- package/src/lib/agent/runtime/cli-model-profile.d.ts +62 -0
- package/src/lib/agent/runtime/dispatch.d.ts +517 -0
- package/src/lib/agent/runtime/execution-runner.d.ts +66 -0
- package/src/lib/agent/runtime/index.d.ts +7 -0
- package/src/lib/agent/runtime/model-execution.d.ts +15 -0
- package/src/lib/agent/runtime/results.d.ts +335 -0
- package/src/lib/agent/runtime/strategy.d.ts +3 -0
- package/src/lib/agent/runtime/task-wait.d.ts +35 -0
- package/src/lib/agent/runtime/types.d.ts +35 -11
- package/src/lib/ai-model/ai-model-provider.interface.d.ts +2 -0
- package/src/lib/ai-model/ai-model.d.ts +2 -0
- package/src/lib/ai-model/index.d.ts +3 -0
- package/src/lib/ai-model/llm.d.ts +4 -2
- package/src/lib/ai-model/native-model.d.ts +22 -0
- package/src/lib/ai-model/realtime.d.ts +36 -0
- package/src/lib/ai-model/token-usage.d.ts +13 -0
- package/src/lib/mcp/app.d.ts +4 -1
- package/src/lib/project-task/index.d.ts +8 -1
- package/src/lib/project-type/index.d.ts +8 -1
- package/src/lib/resource-card-provider/index.d.ts +3 -0
- package/src/lib/resource-card-provider/provider.decorator.d.ts +4 -0
- package/src/lib/resource-card-provider/provider.registry.d.ts +14 -0
- package/src/lib/resource-card-provider/types.d.ts +36 -0
- package/src/lib/resource-card.d.ts +6 -0
- package/src/lib/runtime/capabilities/index.d.ts +1 -0
- package/src/lib/runtime/capabilities/project-provisioning.d.ts +10 -0
- package/src/lib/runtime/capabilities/tool-images.d.ts +24 -0
- package/src/lib/sandbox/execution-environment.d.ts +2 -0
- package/src/lib/sandbox/execution.d.ts +10 -0
- package/src/lib/sandbox/managed-service.d.ts +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
-
import type { XpertProjectTypeRef } from '@xpert-ai/contracts';
|
|
2
|
+
import type { XpertProjectTypeRef, ConversationResourceCard } from '@xpert-ai/contracts';
|
|
3
3
|
import { BaseStrategyRegistry } from '../strategy';
|
|
4
|
+
export type { XpertProjectTypeRef, ConversationResourceCard };
|
|
4
5
|
export interface ProjectTypeContext extends XpertProjectTypeRef {
|
|
5
6
|
tenantId: string;
|
|
6
7
|
organizationId?: string | null;
|
|
@@ -29,6 +30,11 @@ export interface ConversationProjectCreation {
|
|
|
29
30
|
conversationId: string;
|
|
30
31
|
workspaceId: string;
|
|
31
32
|
name: string;
|
|
33
|
+
/** Present only for a human-confirmed setup; the application validates its own configuration. */
|
|
34
|
+
confirmation?: {
|
|
35
|
+
id: string;
|
|
36
|
+
configuration: object;
|
|
37
|
+
};
|
|
32
38
|
/**
|
|
33
39
|
* Persist only application records through this writer. The host creates the
|
|
34
40
|
* platform Project and binds the conversation in the same transaction. Do not
|
|
@@ -54,6 +60,7 @@ export interface IProjectTypeProvider {
|
|
|
54
60
|
createForConversation?(context: ProjectTypeContext, input: ConversationProjectCreation): Promise<ProjectTypeBinding & {
|
|
55
61
|
name: string;
|
|
56
62
|
status: 'active';
|
|
63
|
+
resourceCards?: ConversationResourceCard[];
|
|
57
64
|
}>;
|
|
58
65
|
}
|
|
59
66
|
export declare const PROJECT_TYPE_PROVIDER = "PROJECT_TYPE_PROVIDER";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResourceCardType } from './types';
|
|
2
|
+
export declare const RESOURCE_CARD_PROVIDER = "RESOURCE_CARD_PROVIDER";
|
|
3
|
+
/** Register exact resource types whose message cards opt in to live refresh. */
|
|
4
|
+
export declare const ResourceCardProvider: (...resources: ResourceCardType[]) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
3
|
+
import { BaseStrategyRegistry } from '../strategy';
|
|
4
|
+
import type { IResourceCardProvider, ResourceCardType } from './types';
|
|
5
|
+
export declare class ResourceCardProviderRegistry extends BaseStrategyRegistry<IResourceCardProvider> implements OnModuleDestroy {
|
|
6
|
+
private readonly resourceLogger;
|
|
7
|
+
private subscription?;
|
|
8
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
9
|
+
onModuleInit(): void;
|
|
10
|
+
onModuleDestroy(): void;
|
|
11
|
+
remove(scopeKey: string, pluginName: string): void;
|
|
12
|
+
upsert(instance: unknown): void;
|
|
13
|
+
find(resource: ResourceCardType, organizationId?: string): IResourceCardProvider | undefined;
|
|
14
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ConversationResourceCard } from '@xpert-ai/contracts';
|
|
2
|
+
export interface ResourceCardType {
|
|
3
|
+
namespace: string;
|
|
4
|
+
type: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ResourceCardContext {
|
|
7
|
+
tenantId: string;
|
|
8
|
+
organizationId?: string | null;
|
|
9
|
+
userId: string;
|
|
10
|
+
conversationId: string;
|
|
11
|
+
threadId: string;
|
|
12
|
+
projectId?: string | null;
|
|
13
|
+
/** Stop external reads when the host's observation deadline expires. */
|
|
14
|
+
signal: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
export interface ResourceCardReadRequest {
|
|
17
|
+
/** Opaque correlation key. Echo it; never choose another message binding. */
|
|
18
|
+
key: string;
|
|
19
|
+
card: ConversationResourceCard;
|
|
20
|
+
messageId: string;
|
|
21
|
+
executionId?: string;
|
|
22
|
+
}
|
|
23
|
+
export type ResourceCardResolution = {
|
|
24
|
+
key: string;
|
|
25
|
+
} & ({
|
|
26
|
+
status: 'resolved';
|
|
27
|
+
card: ConversationResourceCard;
|
|
28
|
+
} | {
|
|
29
|
+
status: 'unavailable';
|
|
30
|
+
reason: 'forbidden' | 'not_found';
|
|
31
|
+
});
|
|
32
|
+
/** Optional live presentation of committed resources; never starts work or changes business state. */
|
|
33
|
+
export interface IResourceCardProvider {
|
|
34
|
+
/** Recheck resource access for the host-supplied actor and return one result per request. */
|
|
35
|
+
resolveMany(context: ResourceCardContext, requests: readonly ResourceCardReadRequest[]): Promise<readonly ResourceCardResolution[]>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
2
|
+
import { type ConversationResourceCard } from '@xpert-ai/contracts';
|
|
3
|
+
export { createResourceCardContent, parseResourceCard, resourceCardId } from '@xpert-ai/contracts';
|
|
4
|
+
export type { ConversationResourceCard, ResourceCardContent, ResourceCardField, ResourceCardFile, ResourceCardFileReference, ResourceCardImage, ResourceCardOpenTarget, ResourceCardScalar, TMessageContentResourceCard } from '@xpert-ai/contracts';
|
|
5
|
+
/** Call after the business mutation commits. A display failure must not retry that mutation. */
|
|
6
|
+
export declare function emitResourceCard(card: ConversationResourceCard, config?: RunnableConfig): Promise<void>;
|
|
@@ -38,6 +38,16 @@ export type ProjectEnsureResult = {
|
|
|
38
38
|
};
|
|
39
39
|
/** Host API exposed to plugins that own one-to-one business Project mappings. */
|
|
40
40
|
export interface ProjectProvisioningApi {
|
|
41
|
+
/** App-only confirmation of a pending conversation's first Project; never moves an existing binding. */
|
|
42
|
+
confirmConversation?(input: {
|
|
43
|
+
conversationId: string;
|
|
44
|
+
xpertId: string;
|
|
45
|
+
confirmationId: string;
|
|
46
|
+
name: string;
|
|
47
|
+
configuration: object;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
projectId: string;
|
|
50
|
+
}>;
|
|
41
51
|
/** Create or reconcile a Chat Project without changing its caller-supplied id. */
|
|
42
52
|
ensure(input: ProjectEnsureInput): Promise<ProjectEnsureResult>;
|
|
43
53
|
/** Owner-only physical deletion of an archived plugin-bound Project and its workspace. */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { ToolOutputImageAttachment, ToolOutputPresentation } from '@xpert-ai/chatkit-types';
|
|
3
|
+
import type { ModelRequirements } from '../../agent/middleware/model-requirements';
|
|
4
|
+
export type { ToolOutputImageAttachment, ToolOutputPresentation } from '@xpert-ai/chatkit-types';
|
|
5
|
+
export type ToolImageModelInput = {
|
|
6
|
+
messages: BaseMessage[];
|
|
7
|
+
requirements?: ModelRequirements;
|
|
8
|
+
};
|
|
9
|
+
/** Images stay in immutable Artifacts; tool results and graph checkpoints contain references only. */
|
|
10
|
+
export interface ToolImagesApi {
|
|
11
|
+
/** Host identity, conversation and Workspace scope are bound to the current execution. */
|
|
12
|
+
save(input: {
|
|
13
|
+
buffer: Buffer;
|
|
14
|
+
mimeType: ToolOutputImageAttachment['mimeType'];
|
|
15
|
+
title: string;
|
|
16
|
+
}): Promise<ToolOutputPresentation>;
|
|
17
|
+
/**
|
|
18
|
+
* Project the current complete tool round into one outbound model request. Names identify tools
|
|
19
|
+
* whose successful result must contain an image presentation; error results remain text.
|
|
20
|
+
* Never persist the returned messages. Merge requirements into the request with mergeModelRequirements.
|
|
21
|
+
*/
|
|
22
|
+
prepareModelInput(messages: BaseMessage[], toolNames: readonly string[]): Promise<ToolImageModelInput>;
|
|
23
|
+
}
|
|
24
|
+
export declare const ToolImagesRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ToolImagesApi>;
|
|
@@ -6,5 +6,7 @@ export interface SandboxExecutionEnvironment {
|
|
|
6
6
|
readonly shellState?: 'per-command' | 'persistent';
|
|
7
7
|
readonly persistentDirectories?: readonly string[];
|
|
8
8
|
readonly canInstallSystemPackages?: boolean;
|
|
9
|
+
/** Explicit opt-in capabilities implemented by this execution backend. */
|
|
10
|
+
readonly capabilities?: readonly string[];
|
|
9
11
|
readonly desktop?: boolean;
|
|
10
12
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export interface SandboxExecutionOptions {
|
|
2
|
+
/** Trusted host correlation/capabilities, never part of the model-visible command schema. */
|
|
3
|
+
executionScope?: SandboxExecutionScope;
|
|
2
4
|
timeoutMs?: number;
|
|
3
5
|
maxOutputBytes?: number;
|
|
4
6
|
/** Request cancellation; the backend must implement guest process termination. */
|
|
5
7
|
signal?: AbortSignal;
|
|
6
8
|
}
|
|
7
9
|
export interface ResolvedSandboxExecutionOptions {
|
|
10
|
+
executionScope?: SandboxExecutionScope;
|
|
8
11
|
timeoutMs: number;
|
|
9
12
|
maxOutputBytes: number;
|
|
10
13
|
signal?: AbortSignal;
|
|
@@ -28,3 +31,10 @@ export declare function formatSandboxTimeout(timeoutMs: number): string;
|
|
|
28
31
|
export declare function buildSandboxTimeoutMessage(subject: string, timeoutMs: number): string;
|
|
29
32
|
export declare function appendSandboxMessage(output: string, message: string): string;
|
|
30
33
|
export declare function resolveSandboxExecutionOptions(options?: SandboxExecutionOptions, defaults?: SandboxExecutionOptions): ResolvedSandboxExecutionOptions;
|
|
34
|
+
export interface SandboxExecutionScope {
|
|
35
|
+
parentExecutionId: string;
|
|
36
|
+
conversationId: string;
|
|
37
|
+
toolCallId: string;
|
|
38
|
+
/** Environment capabilities selected by the Assistant's middleware configuration. */
|
|
39
|
+
capabilities: readonly string[];
|
|
40
|
+
}
|
|
@@ -50,6 +50,7 @@ export type SandboxManagedServiceRestartOptions = {
|
|
|
50
50
|
export type SandboxManagedServiceStartResult = SandboxManagedServiceStateChange;
|
|
51
51
|
export interface SandboxManagedServiceAdapter {
|
|
52
52
|
getServiceLogs(options: SandboxManagedServiceLogsOptions): MaybePromise<TSandboxManagedServiceLogs>;
|
|
53
|
+
/** Inspect existing services only; do not create or recover a runtime during discovery. */
|
|
53
54
|
listServices(options: SandboxManagedServiceListOptions): MaybePromise<SandboxManagedServiceListResult>;
|
|
54
55
|
restartService(options: SandboxManagedServiceRestartOptions): MaybePromise<SandboxManagedServiceStartResult>;
|
|
55
56
|
startService(options: SandboxManagedServiceStartOptions): MaybePromise<SandboxManagedServiceStartResult>;
|