@xpert-ai/plugin-sdk 3.19.0 → 3.21.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 +124 -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 +494 -115
- package/index.esm.js +444 -114
- package/model-provider.cjs.js +45 -68
- package/model-provider.esm.js +46 -64
- 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 +3 -0
- package/src/lib/agent/handoff/agent-chat.contract.d.ts +10 -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/agent-plugin/import-default-agent-plugins.command.d.ts +6 -0
- 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/core/context/request-context.d.ts +1 -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/rag/capability/index.d.ts +5 -0
- package/src/lib/{runtime/capabilities → rag/capability}/knowledge-document-visual-assets.d.ts +2 -2
- package/src/lib/rag/capability/knowledge-upload-sessions.d.ts +71 -0
- package/src/lib/{runtime/capabilities → rag/capability}/knowledgebase-documents.d.ts +9 -1
- package/src/lib/{runtime/capabilities → rag/capability}/knowledgebase.d.ts +4 -0
- package/src/lib/rag/index.d.ts +1 -0
- 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 -4
- 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/runtime/capabilities/workspace-files.d.ts +8 -2
- 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/src/lib/{runtime/capabilities → rag/capability}/knowledge-graph.d.ts +0 -0
package/TOOL-IMAGES.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Tool images with immutable references
|
|
2
|
+
|
|
3
|
+
For the API responsibilities, image lifecycle, validation limits and server-only
|
|
4
|
+
text-result policy, see the [tool images feature guide](../../docs/tool-images.md).
|
|
5
|
+
|
|
6
|
+
Use `ToolImagesRuntimeCapability` inside an Agent middleware when a tool returns
|
|
7
|
+
an image for visual inspection. The host stores validated image bytes in
|
|
8
|
+
Workspace Files and an immutable Artifact version. The tool returns only a small
|
|
9
|
+
summary and `ToolOutputPresentation`; do not put a Base64 data URL, file path,
|
|
10
|
+
signed URL or image buffer in tool content, business state or checkpoints.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { tool } from '@langchain/core/tools'
|
|
14
|
+
import { z } from 'zod'
|
|
15
|
+
import { ToolImagesRuntimeCapability, mergeModelRequirements, type AgentMiddleware } from '@xpert-ai/plugin-sdk'
|
|
16
|
+
|
|
17
|
+
// Inside createMiddleware(context), this facade resolves each actual invocation's
|
|
18
|
+
// host scope, including child executions whose conversation was assigned later.
|
|
19
|
+
const images = context.runtime.capabilities!.require(ToolImagesRuntimeCapability)
|
|
20
|
+
const inspectName = 'inspect_process_image'
|
|
21
|
+
const inspectImage = tool(
|
|
22
|
+
async ({ candidateId }) => {
|
|
23
|
+
// Business authorization and candidate selection remain in the owning plugin.
|
|
24
|
+
const prepared = await loadAuthorizedCandidate(candidateId)
|
|
25
|
+
const presentation = await images.save({
|
|
26
|
+
buffer: prepared.buffer,
|
|
27
|
+
mimeType: prepared.mimeType, // image/png, image/jpeg or image/webp
|
|
28
|
+
title: prepared.title
|
|
29
|
+
})
|
|
30
|
+
return [JSON.stringify({ candidateId, sha256: prepared.sha256 }), presentation]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: inspectName,
|
|
34
|
+
description: 'Inspect an authorized construction image candidate.',
|
|
35
|
+
schema: z.object({ candidateId: z.string() }),
|
|
36
|
+
responseFormat: 'content_and_artifact'
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const middleware: AgentMiddleware = {
|
|
41
|
+
name: 'construction-image-inspection',
|
|
42
|
+
tools: [inspectImage],
|
|
43
|
+
wrapModelCall: async (request, handler) => {
|
|
44
|
+
const projected = await images.prepareModelInput(request.messages, [inspectName])
|
|
45
|
+
return handler({
|
|
46
|
+
...request,
|
|
47
|
+
...projected,
|
|
48
|
+
requirements: mergeModelRequirements(request.requirements, projected.requirements)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`loadAuthorizedCandidate` is application-specific: validate its business scope and
|
|
55
|
+
resolve trusted bytes before saving them. Do not accept scope or arbitrary paths
|
|
56
|
+
from model input. Record a successful business “viewed” receipt only after `save`
|
|
57
|
+
succeeds, and require the actual visual review before accepting the asset.
|
|
58
|
+
|
|
59
|
+
`prepareModelInput` is a pure outbound projection over persisted references. It
|
|
60
|
+
hydrates only the current complete tool round, preserves the tool-call ID and
|
|
61
|
+
summary mapping, and validates Artifact ownership, conversation, immutable
|
|
62
|
+
version, MIME type, dimensions, byte length and SHA-256. There are at most three
|
|
63
|
+
images per model request. Names passed to this method identify tools whose
|
|
64
|
+
successful results must contain valid image presentations. Ordinary error
|
|
65
|
+
ToolMessages remain textual so the model can select another candidate.
|
|
66
|
+
|
|
67
|
+
The returned temporary HumanMessage **must never be written to a message channel,
|
|
68
|
+
database or checkpoint**. Merge the returned `requirements` into the request with
|
|
69
|
+
`mergeModelRequirements`. Image input adds `features: [ModelFeature.VISION]`;
|
|
70
|
+
the host preserves the union across middleware and checks both the main model
|
|
71
|
+
and every fallback for registered image-input support. Requirements apply only
|
|
72
|
+
to this invocation and are not Agent state or user-supplied tool arguments.
|
|
73
|
+
Only VISION requirements are currently supported; unsupported features and
|
|
74
|
+
unknown requirement fields fail explicitly. An unknown or text-only model cannot silently discard the pixels.
|
|
75
|
+
|
|
76
|
+
Historical references are not hydrated again. Legacy inline image bytes are
|
|
77
|
+
removed only from outbound clones; a current legacy image result without a valid
|
|
78
|
+
reference must be recreated through the image tool. A fresh middleware can resume
|
|
79
|
+
from saved references in the same conversation, without an in-memory allow-list.
|
|
80
|
+
The public API has no identity or storage path fields: the host binds tenant,
|
|
81
|
+
organization, authenticated user, conversation and Workspace scope. Missing scope,
|
|
82
|
+
foreign references, revoked assets and checksum changes fail explicitly.
|
|
83
|
+
|
|
84
|
+
Deploy compatible ChatKit types, SDK and host runtime before adopting this API.
|
|
85
|
+
This source contract does not imply that a matching SDK version has been published.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./agent-results.cjs.js').default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var results = require('./results.cjs.js');
|
|
4
|
+
var contracts = require('@xpert-ai/contracts');
|
|
5
|
+
require('./_extends.cjs.js');
|
|
6
|
+
require('zod/v3');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.AGENT_TASK_RESULTS_FEATURE = results.AGENT_TASK_RESULTS_FEATURE;
|
|
11
|
+
exports.agentResultItemSchema = results.agentResultItemSchema;
|
|
12
|
+
exports.agentTaskResultSchema = results.agentTaskResultSchema;
|
|
13
|
+
Object.defineProperty(exports, "agentOutputDeliverySchema", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return contracts.agentOutputDeliverySchema; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "agentResultPathSchema", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return contracts.agentResultPathSchema; }
|
|
20
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/agent-results";
|