@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
package/model-provider.cjs.js
CHANGED
|
@@ -272,6 +272,10 @@ const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project
|
|
|
272
272
|
description: 'Resolve human Project membership for platform and plugin operations.'
|
|
273
273
|
});
|
|
274
274
|
|
|
275
|
+
const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-images', {
|
|
276
|
+
description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
|
|
277
|
+
});
|
|
278
|
+
|
|
275
279
|
/**
|
|
276
280
|
* Shared host-runtime plumbing for built-in tools backed by a configured model provider.
|
|
277
281
|
* Provider request/response semantics remain owned by each plugin.
|
|
@@ -408,6 +412,7 @@ exports.SANDBOX_JOB_ERROR_CODES = SANDBOX_JOB_ERROR_CODES;
|
|
|
408
412
|
exports.SANDBOX_JOB_PROGRESS_PREFIX = SANDBOX_JOB_PROGRESS_PREFIX;
|
|
409
413
|
exports.SandboxJobRuntimeError = SandboxJobRuntimeError;
|
|
410
414
|
exports.SandboxJobsRuntimeCapability = SandboxJobsRuntimeCapability;
|
|
415
|
+
exports.ToolImagesRuntimeCapability = ToolImagesRuntimeCapability;
|
|
411
416
|
exports.WORKSPACE_FILES_SOURCE = WORKSPACE_FILES_SOURCE;
|
|
412
417
|
exports.WorkspaceFilesRuntimeCapability = WorkspaceFilesRuntimeCapability;
|
|
413
418
|
exports.XPERT_RUNTIME_CAPABILITIES_TOKEN = XPERT_RUNTIME_CAPABILITIES_TOKEN;
|
package/model-provider.esm.js
CHANGED
|
@@ -270,6 +270,10 @@ const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project
|
|
|
270
270
|
description: 'Resolve human Project membership for platform and plugin operations.'
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
+
const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-images', {
|
|
274
|
+
description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
|
|
275
|
+
});
|
|
276
|
+
|
|
273
277
|
/**
|
|
274
278
|
* Shared host-runtime plumbing for built-in tools backed by a configured model provider.
|
|
275
279
|
* Provider request/response semantics remain owned by each plugin.
|
|
@@ -384,4 +388,4 @@ function normalizeWorkspaceScope(scope) {
|
|
|
384
388
|
} : {});
|
|
385
389
|
}
|
|
386
390
|
|
|
387
|
-
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, KnowledgeDocumentVisualAssetsRuntimeCapability as K, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability as P, RUNTIME_CAPABILITY_PROVIDER as R, SANDBOX_JOB_ERROR_CODES as S, WorkspaceFilesRuntimeCapability as W, XPERT_RUNTIME_CAPABILITIES_TOKEN as X, ActorTokenRuntimeFactoryCapability as a, ArtifactsRuntimeCapability as b, createRuntimeCapability as c, BaseTool as d, BaseToolset as e, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability as f, KnowledgeGraphRuntimeCapability as g, KnowledgebaseDocumentsRuntimeCapability as h, KnowledgebaseProvisioningRuntimeCapability as i, KnowledgebaseRuntimeCapability as j, ProjectProvisioningRuntimeCapability as k, RuntimeCapabilityProvider as l, SANDBOX_JOB_PROGRESS_PREFIX as m, SandboxJobRuntimeError as n, SandboxJobsRuntimeCapability as o, WORKSPACE_FILES_SOURCE as p, isSandboxJobRuntimeError as q };
|
|
391
|
+
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, KnowledgeDocumentVisualAssetsRuntimeCapability as K, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability as P, RUNTIME_CAPABILITY_PROVIDER as R, SANDBOX_JOB_ERROR_CODES as S, ToolImagesRuntimeCapability as T, WorkspaceFilesRuntimeCapability as W, XPERT_RUNTIME_CAPABILITIES_TOKEN as X, ActorTokenRuntimeFactoryCapability as a, ArtifactsRuntimeCapability as b, createRuntimeCapability as c, BaseTool as d, BaseToolset as e, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability as f, KnowledgeGraphRuntimeCapability as g, KnowledgebaseDocumentsRuntimeCapability as h, KnowledgebaseProvisioningRuntimeCapability as i, KnowledgebaseRuntimeCapability as j, ProjectProvisioningRuntimeCapability as k, RuntimeCapabilityProvider as l, SANDBOX_JOB_PROGRESS_PREFIX as m, SandboxJobRuntimeError as n, SandboxJobsRuntimeCapability as o, WORKSPACE_FILES_SOURCE as p, isSandboxJobRuntimeError as q };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
"import": "./index.cjs.mjs",
|
|
20
20
|
"default": "./index.cjs.js"
|
|
21
21
|
},
|
|
22
|
+
"./agent-results": {
|
|
23
|
+
"module": "./agent-results.esm.js",
|
|
24
|
+
"types": "./agent-results.d.ts",
|
|
25
|
+
"import": "./agent-results.cjs.mjs",
|
|
26
|
+
"default": "./agent-results.cjs.js"
|
|
27
|
+
},
|
|
22
28
|
"./data-workbench": {
|
|
23
29
|
"module": "./data-workbench.esm.js",
|
|
24
30
|
"types": "./data-workbench.d.ts",
|
|
@@ -56,7 +62,7 @@
|
|
|
56
62
|
},
|
|
57
63
|
"dependencies": {
|
|
58
64
|
"@langchain/openai": "0.6.9",
|
|
59
|
-
"@xpert-ai/contracts": "3.
|
|
65
|
+
"@xpert-ai/contracts": "3.20.0",
|
|
60
66
|
"express": "^4.22.1",
|
|
61
67
|
"js-tiktoken": "^1.0.21"
|
|
62
68
|
},
|
package/results.cjs.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _extends = require('./_extends.cjs.js');
|
|
4
|
+
var v3 = require('zod/v3');
|
|
5
|
+
var contracts = require('@xpert-ai/contracts');
|
|
6
|
+
|
|
7
|
+
/** Opt in to the host's authorized, on-demand result View from middleware metadata. */ const AGENT_TASK_RESULTS_FEATURE = 'agent_task_results';
|
|
8
|
+
const common = {
|
|
9
|
+
id: v3.z.string().regex(/^[a-zA-Z0-9_-]{1,80}$/),
|
|
10
|
+
title: v3.z.string().min(1).max(200),
|
|
11
|
+
summary: v3.z.string().max(16000)
|
|
12
|
+
};
|
|
13
|
+
/** Machine-readable result kind; file declarations are not committed artifacts or download grants. */ const agentResultItemSchema = v3.z.discriminatedUnion('type', [
|
|
14
|
+
v3.z.object(_extends._extends({}, common, {
|
|
15
|
+
type: v3.z.literal('analysis')
|
|
16
|
+
})).strict(),
|
|
17
|
+
v3.z.object(_extends._extends({}, common, {
|
|
18
|
+
type: v3.z.literal('changes'),
|
|
19
|
+
files: v3.z.array(v3.z.object({
|
|
20
|
+
path: contracts.agentResultPathSchema,
|
|
21
|
+
change: v3.z.enum([
|
|
22
|
+
'created',
|
|
23
|
+
'modified',
|
|
24
|
+
'deleted'
|
|
25
|
+
])
|
|
26
|
+
}).strict()).max(128)
|
|
27
|
+
})).strict(),
|
|
28
|
+
v3.z.object(_extends._extends({}, common, {
|
|
29
|
+
type: v3.z.literal('tests'),
|
|
30
|
+
status: v3.z.enum([
|
|
31
|
+
'passed',
|
|
32
|
+
'failed',
|
|
33
|
+
'skipped'
|
|
34
|
+
]),
|
|
35
|
+
command: v3.z.string().max(2000).optional()
|
|
36
|
+
})).strict(),
|
|
37
|
+
v3.z.object(_extends._extends({}, common, {
|
|
38
|
+
type: v3.z.literal('file'),
|
|
39
|
+
path: contracts.agentResultPathSchema
|
|
40
|
+
})).strict()
|
|
41
|
+
]);
|
|
42
|
+
/** Explicit final response envelope shared by adapters; ordinary prose is never classified heuristically. */ const agentTaskResultSchema = v3.z.object({
|
|
43
|
+
version: v3.z.literal(1),
|
|
44
|
+
summary: v3.z.string().max(64000),
|
|
45
|
+
items: v3.z.array(agentResultItemSchema).max(32)
|
|
46
|
+
}).strict().refine((value)=>new Set(value.items.map((item)=>item.id)).size === value.items.length, 'Result item IDs must be unique');
|
|
47
|
+
|
|
48
|
+
exports.AGENT_TASK_RESULTS_FEATURE = AGENT_TASK_RESULTS_FEATURE;
|
|
49
|
+
exports.agentResultItemSchema = agentResultItemSchema;
|
|
50
|
+
exports.agentTaskResultSchema = agentTaskResultSchema;
|
package/results.esm.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { _ as _extends } from './_extends.esm.js';
|
|
2
|
+
import { z } from 'zod/v3';
|
|
3
|
+
import { agentResultPathSchema } from '@xpert-ai/contracts';
|
|
4
|
+
|
|
5
|
+
/** Opt in to the host's authorized, on-demand result View from middleware metadata. */ const AGENT_TASK_RESULTS_FEATURE = 'agent_task_results';
|
|
6
|
+
const common = {
|
|
7
|
+
id: z.string().regex(/^[a-zA-Z0-9_-]{1,80}$/),
|
|
8
|
+
title: z.string().min(1).max(200),
|
|
9
|
+
summary: z.string().max(16000)
|
|
10
|
+
};
|
|
11
|
+
/** Machine-readable result kind; file declarations are not committed artifacts or download grants. */ const agentResultItemSchema = z.discriminatedUnion('type', [
|
|
12
|
+
z.object(_extends({}, common, {
|
|
13
|
+
type: z.literal('analysis')
|
|
14
|
+
})).strict(),
|
|
15
|
+
z.object(_extends({}, common, {
|
|
16
|
+
type: z.literal('changes'),
|
|
17
|
+
files: z.array(z.object({
|
|
18
|
+
path: agentResultPathSchema,
|
|
19
|
+
change: z.enum([
|
|
20
|
+
'created',
|
|
21
|
+
'modified',
|
|
22
|
+
'deleted'
|
|
23
|
+
])
|
|
24
|
+
}).strict()).max(128)
|
|
25
|
+
})).strict(),
|
|
26
|
+
z.object(_extends({}, common, {
|
|
27
|
+
type: z.literal('tests'),
|
|
28
|
+
status: z.enum([
|
|
29
|
+
'passed',
|
|
30
|
+
'failed',
|
|
31
|
+
'skipped'
|
|
32
|
+
]),
|
|
33
|
+
command: z.string().max(2000).optional()
|
|
34
|
+
})).strict(),
|
|
35
|
+
z.object(_extends({}, common, {
|
|
36
|
+
type: z.literal('file'),
|
|
37
|
+
path: agentResultPathSchema
|
|
38
|
+
})).strict()
|
|
39
|
+
]);
|
|
40
|
+
/** Explicit final response envelope shared by adapters; ordinary prose is never classified heuristically. */ const agentTaskResultSchema = z.object({
|
|
41
|
+
version: z.literal(1),
|
|
42
|
+
summary: z.string().max(64000),
|
|
43
|
+
items: z.array(agentResultItemSchema).max(32)
|
|
44
|
+
}).strict().refine((value)=>new Set(value.items.map((item)=>item.id)).size === value.items.length, 'Result item IDs must be unique');
|
|
45
|
+
|
|
46
|
+
export { AGENT_TASK_RESULTS_FEATURE as A, agentResultItemSchema as a, agentTaskResultSchema as b };
|
package/src/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from './lib/plugin';
|
|
|
2
2
|
export * from './lib/plugin.interface';
|
|
3
3
|
export * from './lib/plugin-metadata';
|
|
4
4
|
export * from './lib/artifact-namespace';
|
|
5
|
+
export * from './lib/resource-card';
|
|
6
|
+
export * from './lib/resource-card-provider';
|
|
5
7
|
export * from './lib/types';
|
|
6
8
|
export * from './lib/logger';
|
|
7
9
|
export * from './lib/integration/index';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TChatOptions, TChatRequest, TChatRuntimePrincipal, TChatSourceAuditOptions } from '@xpert-ai/contracts';
|
|
1
|
+
import { TChatMessageEnvelope, TChatOptions, TChatRequest, TChatRuntimePrincipal, TChatSourceAuditOptions } from '@xpert-ai/contracts';
|
|
2
2
|
export declare const AGENT_CHAT_DISPATCH_MESSAGE_TYPE: import("./message-type").StructuredHandoffMessageType;
|
|
3
3
|
export declare const AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = "steer_target_not_running";
|
|
4
4
|
export interface AgentChatHandoffMessageCallbackTarget {
|
|
@@ -16,11 +16,16 @@ export type AgentChatRuntimePrincipal = TChatRuntimePrincipal;
|
|
|
16
16
|
export interface AgentChatDispatchPayload extends Record<string, unknown> {
|
|
17
17
|
request: TChatRequest;
|
|
18
18
|
options: TChatOptions & TChatSourceAuditOptions & {
|
|
19
|
+
/** Host-resolved runtime branch, independent of the conversation root. */
|
|
20
|
+
threadId?: string;
|
|
21
|
+
isDerivedThread?: boolean;
|
|
19
22
|
xpertId?: string;
|
|
20
23
|
isDraft?: boolean;
|
|
21
24
|
from?: string;
|
|
22
25
|
fromEndUserId?: string;
|
|
23
26
|
runtimePrincipal?: AgentChatRuntimePrincipal;
|
|
27
|
+
/** Host-resolved provenance and presentation; never grants routing or execution privileges. */
|
|
28
|
+
messageEnvelope?: TChatMessageEnvelope;
|
|
24
29
|
execution?: {
|
|
25
30
|
id: string;
|
|
26
31
|
};
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
import { type AgentRuntimeReplyTarget } from '../runtime/dispatch';
|
|
3
|
+
export declare const AGENT_RUNTIME_EVENT_MESSAGE_TYPE: import("./message-type").StructuredHandoffMessageType;
|
|
4
|
+
/** Host-produced references. Consumers reload and authorize the invocation and its pinned observation. */
|
|
5
|
+
export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
6
|
+
kind: z.ZodLiteral<"progress">;
|
|
7
|
+
progress: z.ZodObject<{
|
|
8
|
+
source: z.ZodEnum<["executor", "host"]>;
|
|
9
|
+
observedAt: z.ZodString;
|
|
10
|
+
startedAt: z.ZodOptional<z.ZodString>;
|
|
11
|
+
phase: z.ZodOptional<z.ZodString>;
|
|
12
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
13
|
+
steps: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
14
|
+
completed: z.ZodNumber;
|
|
15
|
+
total: z.ZodNumber;
|
|
16
|
+
}, "strict", z.ZodTypeAny, {
|
|
17
|
+
total?: number;
|
|
18
|
+
completed?: number;
|
|
19
|
+
}, {
|
|
20
|
+
total?: number;
|
|
21
|
+
completed?: number;
|
|
22
|
+
}>, {
|
|
23
|
+
total?: number;
|
|
24
|
+
completed?: number;
|
|
25
|
+
}, {
|
|
26
|
+
total?: number;
|
|
27
|
+
completed?: number;
|
|
28
|
+
}>>;
|
|
29
|
+
}, "strict", z.ZodTypeAny, {
|
|
30
|
+
source?: "executor" | "host";
|
|
31
|
+
startedAt?: string;
|
|
32
|
+
summary?: string;
|
|
33
|
+
steps?: {
|
|
34
|
+
total?: number;
|
|
35
|
+
completed?: number;
|
|
36
|
+
};
|
|
37
|
+
observedAt?: string;
|
|
38
|
+
phase?: string;
|
|
39
|
+
}, {
|
|
40
|
+
source?: "executor" | "host";
|
|
41
|
+
startedAt?: string;
|
|
42
|
+
summary?: string;
|
|
43
|
+
steps?: {
|
|
44
|
+
total?: number;
|
|
45
|
+
completed?: number;
|
|
46
|
+
};
|
|
47
|
+
observedAt?: string;
|
|
48
|
+
phase?: string;
|
|
49
|
+
}>;
|
|
50
|
+
version: z.ZodLiteral<1>;
|
|
51
|
+
invocationId: z.ZodString;
|
|
52
|
+
/** Revision of the persisted observation, never a queue delivery attempt. */
|
|
53
|
+
revision: z.ZodNumber;
|
|
54
|
+
projectTask: z.ZodOptional<z.ZodObject<{
|
|
55
|
+
projectId: z.ZodString;
|
|
56
|
+
projectTaskId: z.ZodString;
|
|
57
|
+
taskExecutionId: z.ZodString;
|
|
58
|
+
}, "strict", z.ZodTypeAny, {
|
|
59
|
+
projectId?: string;
|
|
60
|
+
projectTaskId?: string;
|
|
61
|
+
taskExecutionId?: string;
|
|
62
|
+
}, {
|
|
63
|
+
projectId?: string;
|
|
64
|
+
projectTaskId?: string;
|
|
65
|
+
taskExecutionId?: string;
|
|
66
|
+
}>>;
|
|
67
|
+
}, "strict", z.ZodTypeAny, {
|
|
68
|
+
version?: 1;
|
|
69
|
+
kind?: "progress";
|
|
70
|
+
projectTask?: {
|
|
71
|
+
projectId?: string;
|
|
72
|
+
projectTaskId?: string;
|
|
73
|
+
taskExecutionId?: string;
|
|
74
|
+
};
|
|
75
|
+
progress?: {
|
|
76
|
+
source?: "executor" | "host";
|
|
77
|
+
startedAt?: string;
|
|
78
|
+
summary?: string;
|
|
79
|
+
steps?: {
|
|
80
|
+
total?: number;
|
|
81
|
+
completed?: number;
|
|
82
|
+
};
|
|
83
|
+
observedAt?: string;
|
|
84
|
+
phase?: string;
|
|
85
|
+
};
|
|
86
|
+
invocationId?: string;
|
|
87
|
+
revision?: number;
|
|
88
|
+
}, {
|
|
89
|
+
version?: 1;
|
|
90
|
+
kind?: "progress";
|
|
91
|
+
projectTask?: {
|
|
92
|
+
projectId?: string;
|
|
93
|
+
projectTaskId?: string;
|
|
94
|
+
taskExecutionId?: string;
|
|
95
|
+
};
|
|
96
|
+
progress?: {
|
|
97
|
+
source?: "executor" | "host";
|
|
98
|
+
startedAt?: string;
|
|
99
|
+
summary?: string;
|
|
100
|
+
steps?: {
|
|
101
|
+
total?: number;
|
|
102
|
+
completed?: number;
|
|
103
|
+
};
|
|
104
|
+
observedAt?: string;
|
|
105
|
+
phase?: string;
|
|
106
|
+
};
|
|
107
|
+
invocationId?: string;
|
|
108
|
+
revision?: number;
|
|
109
|
+
}>, z.ZodObject<{
|
|
110
|
+
kind: z.ZodLiteral<"result">;
|
|
111
|
+
status: z.ZodEnum<["succeeded", "failed", "cancelled"]>;
|
|
112
|
+
version: z.ZodLiteral<1>;
|
|
113
|
+
invocationId: z.ZodString;
|
|
114
|
+
/** Revision of the persisted observation, never a queue delivery attempt. */
|
|
115
|
+
revision: z.ZodNumber;
|
|
116
|
+
projectTask: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
projectId: z.ZodString;
|
|
118
|
+
projectTaskId: z.ZodString;
|
|
119
|
+
taskExecutionId: z.ZodString;
|
|
120
|
+
}, "strict", z.ZodTypeAny, {
|
|
121
|
+
projectId?: string;
|
|
122
|
+
projectTaskId?: string;
|
|
123
|
+
taskExecutionId?: string;
|
|
124
|
+
}, {
|
|
125
|
+
projectId?: string;
|
|
126
|
+
projectTaskId?: string;
|
|
127
|
+
taskExecutionId?: string;
|
|
128
|
+
}>>;
|
|
129
|
+
}, "strict", z.ZodTypeAny, {
|
|
130
|
+
status?: "failed" | "succeeded" | "cancelled";
|
|
131
|
+
version?: 1;
|
|
132
|
+
kind?: "result";
|
|
133
|
+
projectTask?: {
|
|
134
|
+
projectId?: string;
|
|
135
|
+
projectTaskId?: string;
|
|
136
|
+
taskExecutionId?: string;
|
|
137
|
+
};
|
|
138
|
+
invocationId?: string;
|
|
139
|
+
revision?: number;
|
|
140
|
+
}, {
|
|
141
|
+
status?: "failed" | "succeeded" | "cancelled";
|
|
142
|
+
version?: 1;
|
|
143
|
+
kind?: "result";
|
|
144
|
+
projectTask?: {
|
|
145
|
+
projectId?: string;
|
|
146
|
+
projectTaskId?: string;
|
|
147
|
+
taskExecutionId?: string;
|
|
148
|
+
};
|
|
149
|
+
invocationId?: string;
|
|
150
|
+
revision?: number;
|
|
151
|
+
}>, z.ZodObject<{
|
|
152
|
+
kind: z.ZodLiteral<"input_request">;
|
|
153
|
+
interactionId: z.ZodString;
|
|
154
|
+
version: z.ZodLiteral<1>;
|
|
155
|
+
invocationId: z.ZodString;
|
|
156
|
+
/** Revision of the persisted observation, never a queue delivery attempt. */
|
|
157
|
+
revision: z.ZodNumber;
|
|
158
|
+
projectTask: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
projectId: z.ZodString;
|
|
160
|
+
projectTaskId: z.ZodString;
|
|
161
|
+
taskExecutionId: z.ZodString;
|
|
162
|
+
}, "strict", z.ZodTypeAny, {
|
|
163
|
+
projectId?: string;
|
|
164
|
+
projectTaskId?: string;
|
|
165
|
+
taskExecutionId?: string;
|
|
166
|
+
}, {
|
|
167
|
+
projectId?: string;
|
|
168
|
+
projectTaskId?: string;
|
|
169
|
+
taskExecutionId?: string;
|
|
170
|
+
}>>;
|
|
171
|
+
}, "strict", z.ZodTypeAny, {
|
|
172
|
+
version?: 1;
|
|
173
|
+
kind?: "input_request";
|
|
174
|
+
projectTask?: {
|
|
175
|
+
projectId?: string;
|
|
176
|
+
projectTaskId?: string;
|
|
177
|
+
taskExecutionId?: string;
|
|
178
|
+
};
|
|
179
|
+
invocationId?: string;
|
|
180
|
+
revision?: number;
|
|
181
|
+
interactionId?: string;
|
|
182
|
+
}, {
|
|
183
|
+
version?: 1;
|
|
184
|
+
kind?: "input_request";
|
|
185
|
+
projectTask?: {
|
|
186
|
+
projectId?: string;
|
|
187
|
+
projectTaskId?: string;
|
|
188
|
+
taskExecutionId?: string;
|
|
189
|
+
};
|
|
190
|
+
invocationId?: string;
|
|
191
|
+
revision?: number;
|
|
192
|
+
interactionId?: string;
|
|
193
|
+
}>]>;
|
|
194
|
+
export type AgentRuntimeEvent = z.output<typeof agentRuntimeEventSchema>;
|
|
195
|
+
/** Same observation always has the same HandoffMessage.id across retries and process restarts. */
|
|
196
|
+
export declare function agentRuntimeEventMessageId(event: Pick<AgentRuntimeEvent, 'invocationId' | 'revision' | 'kind'>): string;
|
|
197
|
+
/** Transport states are deliberately separate from Task and Invocation status. */
|
|
198
|
+
export declare const agentRuntimeDeliveryStateSchema: z.ZodEnum<["pending", "received", "blocked", "failed"]>;
|
|
199
|
+
export declare const agentRuntimeConsumptionStateSchema: z.ZodEnum<["pending", "processing", "processed", "blocked", "failed"]>;
|
|
200
|
+
export type AgentRuntimeDeliveryState = z.output<typeof agentRuntimeDeliveryStateSchema>;
|
|
201
|
+
export type AgentRuntimeConsumptionState = z.output<typeof agentRuntimeConsumptionStateSchema>;
|
|
202
|
+
/** Store under a unique scoped key in the same transaction as the continuation reservation. */
|
|
203
|
+
export declare const agentRuntimeResultClaimSchema: z.ZodObject<{
|
|
204
|
+
invocationId: z.ZodString;
|
|
205
|
+
resultRevision: z.ZodNumber;
|
|
206
|
+
recipient: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
207
|
+
type: z.ZodOptional<z.ZodLiteral<"xpert">>;
|
|
208
|
+
xpertId: z.ZodString;
|
|
209
|
+
agentKey: z.ZodString;
|
|
210
|
+
conversationId: z.ZodString;
|
|
211
|
+
threadId: z.ZodString;
|
|
212
|
+
}, "strict", z.ZodTypeAny, {
|
|
213
|
+
type?: "xpert";
|
|
214
|
+
threadId?: string;
|
|
215
|
+
conversationId?: string;
|
|
216
|
+
xpertId?: string;
|
|
217
|
+
agentKey?: string;
|
|
218
|
+
}, {
|
|
219
|
+
type?: "xpert";
|
|
220
|
+
threadId?: string;
|
|
221
|
+
conversationId?: string;
|
|
222
|
+
xpertId?: string;
|
|
223
|
+
agentKey?: string;
|
|
224
|
+
}>, z.ZodObject<{
|
|
225
|
+
type: z.ZodLiteral<"project_agent">;
|
|
226
|
+
projectId: z.ZodString;
|
|
227
|
+
agentKey: z.ZodLiteral<"general_agent">;
|
|
228
|
+
conversationId: z.ZodString;
|
|
229
|
+
threadId: z.ZodString;
|
|
230
|
+
}, "strict", z.ZodTypeAny, {
|
|
231
|
+
type?: "project_agent";
|
|
232
|
+
threadId?: string;
|
|
233
|
+
conversationId?: string;
|
|
234
|
+
projectId?: string;
|
|
235
|
+
agentKey?: "general_agent";
|
|
236
|
+
}, {
|
|
237
|
+
type?: "project_agent";
|
|
238
|
+
threadId?: string;
|
|
239
|
+
conversationId?: string;
|
|
240
|
+
projectId?: string;
|
|
241
|
+
agentKey?: "general_agent";
|
|
242
|
+
}>]>;
|
|
243
|
+
consumer: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
244
|
+
type: z.ZodLiteral<"follow_up">;
|
|
245
|
+
executionId: z.ZodString;
|
|
246
|
+
}, "strict", z.ZodTypeAny, {
|
|
247
|
+
type?: "follow_up";
|
|
248
|
+
executionId?: string;
|
|
249
|
+
}, {
|
|
250
|
+
type?: "follow_up";
|
|
251
|
+
executionId?: string;
|
|
252
|
+
}>, z.ZodObject<{
|
|
253
|
+
type: z.ZodLiteral<"wait">;
|
|
254
|
+
executionId: z.ZodString;
|
|
255
|
+
callId: z.ZodString;
|
|
256
|
+
}, "strict", z.ZodTypeAny, {
|
|
257
|
+
type?: "wait";
|
|
258
|
+
executionId?: string;
|
|
259
|
+
callId?: string;
|
|
260
|
+
}, {
|
|
261
|
+
type?: "wait";
|
|
262
|
+
executionId?: string;
|
|
263
|
+
callId?: string;
|
|
264
|
+
}>]>;
|
|
265
|
+
}, "strict", z.ZodTypeAny, {
|
|
266
|
+
invocationId?: string;
|
|
267
|
+
resultRevision?: number;
|
|
268
|
+
recipient?: {
|
|
269
|
+
type?: "xpert";
|
|
270
|
+
threadId?: string;
|
|
271
|
+
conversationId?: string;
|
|
272
|
+
xpertId?: string;
|
|
273
|
+
agentKey?: string;
|
|
274
|
+
} | {
|
|
275
|
+
type?: "project_agent";
|
|
276
|
+
threadId?: string;
|
|
277
|
+
conversationId?: string;
|
|
278
|
+
projectId?: string;
|
|
279
|
+
agentKey?: "general_agent";
|
|
280
|
+
};
|
|
281
|
+
consumer?: {
|
|
282
|
+
type?: "follow_up";
|
|
283
|
+
executionId?: string;
|
|
284
|
+
} | {
|
|
285
|
+
type?: "wait";
|
|
286
|
+
executionId?: string;
|
|
287
|
+
callId?: string;
|
|
288
|
+
};
|
|
289
|
+
}, {
|
|
290
|
+
invocationId?: string;
|
|
291
|
+
resultRevision?: number;
|
|
292
|
+
recipient?: {
|
|
293
|
+
type?: "xpert";
|
|
294
|
+
threadId?: string;
|
|
295
|
+
conversationId?: string;
|
|
296
|
+
xpertId?: string;
|
|
297
|
+
agentKey?: string;
|
|
298
|
+
} | {
|
|
299
|
+
type?: "project_agent";
|
|
300
|
+
threadId?: string;
|
|
301
|
+
conversationId?: string;
|
|
302
|
+
projectId?: string;
|
|
303
|
+
agentKey?: "general_agent";
|
|
304
|
+
};
|
|
305
|
+
consumer?: {
|
|
306
|
+
type?: "follow_up";
|
|
307
|
+
executionId?: string;
|
|
308
|
+
} | {
|
|
309
|
+
type?: "wait";
|
|
310
|
+
executionId?: string;
|
|
311
|
+
callId?: string;
|
|
312
|
+
};
|
|
313
|
+
}>;
|
|
314
|
+
export type AgentRuntimeResultClaim = z.output<typeof agentRuntimeResultClaimSchema>;
|
|
315
|
+
/**
|
|
316
|
+
* Wait and asynchronous reply compete for this same key, regardless of delivery revision.
|
|
317
|
+
* The storage key must additionally include tenant, organization and owner from trusted scope.
|
|
318
|
+
*/
|
|
319
|
+
export declare function agentRuntimeResultConsumptionKey(invocationId: string, recipient: AgentRuntimeReplyTarget): string;
|
package/src/lib/agent/index.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ModelFeature } from '@xpert-ai/contracts';
|
|
2
|
+
/** Expand only when the host can validate the feature at every model invocation. */
|
|
3
|
+
export type ModelRequirementFeature = ModelFeature.VISION;
|
|
4
|
+
/** Hard requirements for one model call, including retries and fallbacks. */
|
|
5
|
+
export interface ModelRequirements {
|
|
6
|
+
readonly features?: readonly ModelRequirementFeature[];
|
|
7
|
+
}
|
|
8
|
+
/** Combine middleware contributions without mutating or weakening existing requirements. */
|
|
9
|
+
export declare function mergeModelRequirements(...requirements: readonly (ModelRequirements | undefined)[]): ModelRequirements | undefined;
|
|
@@ -5,6 +5,7 @@ import { BaseStore } from '@langchain/langgraph';
|
|
|
5
5
|
import { AgentMiddleware } from './types';
|
|
6
6
|
import { PromiseOrValue } from '../../types';
|
|
7
7
|
import { AgentMiddlewareRuntimeApi } from './runtime';
|
|
8
|
+
import type { AgentInvocationScope } from '../runtime/types';
|
|
8
9
|
export interface IAgentMiddlewareContext {
|
|
9
10
|
tenantId: string;
|
|
10
11
|
organizationId?: string | null;
|
|
@@ -12,6 +13,9 @@ export interface IAgentMiddlewareContext {
|
|
|
12
13
|
workspaceId?: string;
|
|
13
14
|
projectId?: string;
|
|
14
15
|
conversationId?: string;
|
|
16
|
+
executionId?: string;
|
|
17
|
+
/** Omitted for legacy Assistant hosts. Project general agents must explicitly use project_agent. */
|
|
18
|
+
callerType?: AgentInvocationScope['callerType'];
|
|
15
19
|
threadId?: string;
|
|
16
20
|
xpertId?: string;
|
|
17
21
|
workspaceDataScope?: XpertWorkspaceDataScope | null;
|
|
@@ -8,6 +8,7 @@ import { Command } from '@langchain/langgraph';
|
|
|
8
8
|
import type { JsonSchemaObjectType } from '@xpert-ai/contracts';
|
|
9
9
|
import { AgentBuiltInState, Runtime } from './runtime';
|
|
10
10
|
import { PromiseOrValue } from '../../types';
|
|
11
|
+
import type { ModelRequirements } from './model-requirements';
|
|
11
12
|
export type ServerTool = Record<string, unknown>;
|
|
12
13
|
export type ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;
|
|
13
14
|
export type NormalizedSchemaInput<TSchema extends InteropZodObject | undefined | never = any> = [TSchema] extends [
|
|
@@ -117,6 +118,12 @@ export interface ModelRequest<TState extends Record<string, unknown> = Record<st
|
|
|
117
118
|
* The messages to send to the model.
|
|
118
119
|
*/
|
|
119
120
|
messages: BaseMessage[];
|
|
121
|
+
/**
|
|
122
|
+
* Hard capability requirements for this call. The host unions middleware
|
|
123
|
+
* contributions and checks every selected model, including fallbacks.
|
|
124
|
+
* Required capabilities cannot be silently dropped or replaced by a static response.
|
|
125
|
+
*/
|
|
126
|
+
requirements?: ModelRequirements;
|
|
120
127
|
systemMessage?: SystemMessage;
|
|
121
128
|
/**
|
|
122
129
|
* Portable tool choice configuration, applied by the host after selection.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutionActivityBatch, ExecutionActivityCheckpoint } from '@xpert-ai/contracts';
|
|
2
|
+
/** Optional, invocation-bound public activity sink. Does not alter execution or business status. */
|
|
3
|
+
export interface AgentActivityRecorder {
|
|
4
|
+
readCheckpoint(): Promise<ExecutionActivityCheckpoint>;
|
|
5
|
+
append(batch: ExecutionActivityBatch): Promise<ExecutionActivityCheckpoint>;
|
|
6
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { AgentInvocation, AgentInvocationRequest, AgentJson, AgentTarget } from './types';
|
|
2
2
|
import type { RuntimeIdentityScope } from '../../runtime/runtime-scope';
|
|
3
|
+
import type { TaskWaitRequest, TaskWaitResult } from './task-wait';
|
|
4
|
+
import type { ConversationResourceCard } from '@xpert-ai/contracts';
|
|
3
5
|
/** Invocation API bound to one authorized caller/execution. Each operation revalidates access. */
|
|
4
6
|
export interface AgentInvocationApi {
|
|
7
|
+
/** Create a host-owned presentation receipt after a successful dispatch, without inspecting the runtime. */
|
|
8
|
+
getResourceCard?(invocationId: string): Promise<ConversationResourceCard | null>;
|
|
5
9
|
/** Resolve a binding to a pinned target. Optional on hosts with pre-resolved native targets. */
|
|
6
10
|
resolve?(bindingId: string): Promise<AgentTarget>;
|
|
7
11
|
/** Start or recover an idempotent request. The returned snapshot may still be running. */
|
|
@@ -12,11 +16,15 @@ export interface AgentInvocationApi {
|
|
|
12
16
|
cancel(invocationId: string): Promise<AgentInvocation>;
|
|
13
17
|
/** Answer the current interaction using its exact ID and provider-defined response schema. */
|
|
14
18
|
respond(invocationId: string, interactionId: string, response: AgentJson): Promise<AgentInvocation>;
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
/** Bounded observation; may return a running task. Only human interactions may suspend the graph. */
|
|
20
|
+
awaitResult?(invocationId: string, options?: {
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}): Promise<AgentInvocation>;
|
|
24
|
+
/** Wait for dependencies within a bounded window. The Agent may wait again when the result is pending. */
|
|
25
|
+
waitForTasks?(request: TaskWaitRequest, options?: {
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
}): Promise<TaskWaitResult<AgentInvocation>>;
|
|
20
28
|
}
|
|
21
29
|
/** Caller-scoped API obtained through runtime.capabilities.require(...). */
|
|
22
30
|
export declare const AgentInvocationRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<AgentInvocationApi>;
|