@xpert-ai/plugin-sdk 3.27.0 → 3.29.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/collaboration-client.cjs.js +31 -5
- package/collaboration-client.esm.js +31 -5
- package/data-workbench.cjs.js +0 -679
- package/data-workbench.esm.js +1 -676
- package/docs/artifact-presentations.md +2 -0
- package/docs/artifact-types.md +97 -0
- package/docs/data-workbench.md +37 -0
- package/index.cjs.js +481 -49
- package/index.esm.js +469 -49
- package/model-provider.cjs.js +7 -1
- package/model-provider.esm.js +7 -2
- package/package.json +2 -2
- package/src/data-workbench.d.ts +0 -2
- package/src/index.d.ts +2 -0
- package/src/lib/agent/handoff/types.d.ts +5 -0
- package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +6 -1
- package/src/lib/agent/middleware/capabilities/execution-observability.d.ts +26 -0
- package/src/lib/agent/middleware/capabilities/index.d.ts +1 -0
- package/src/lib/agent/runtime/capability.d.ts +4 -0
- package/src/lib/agent/runtime/cli-model-profile.d.ts +1 -1
- package/src/lib/agent/runtime/execution-runner.d.ts +11 -0
- package/src/lib/agent/runtime/index.d.ts +2 -0
- package/src/lib/agent/runtime/managed.d.ts +94 -0
- package/src/lib/agent/runtime/process-supervisor.d.ts +1 -0
- package/src/lib/agent/runtime/strategy.d.ts +14 -0
- package/src/lib/agent/runtime/types.d.ts +30 -1
- package/src/lib/ai-model/native-model.d.ts +5 -1
- package/src/lib/artifact-type/definition.schema.d.ts +119 -0
- package/src/lib/artifact-type/index.d.ts +91 -0
- package/src/lib/artifact-type/registry.d.ts +25 -0
- package/src/lib/assistant-capability/index.d.ts +1 -0
- package/src/lib/assistant-capability/middleware.d.ts +10 -0
- package/src/lib/collaboration/types.d.ts +5 -0
- package/src/lib/content-resource/catalog.d.ts +88 -0
- package/src/lib/content-resource/editor-compatibility.d.ts +3 -0
- package/src/lib/content-resource/editor.d.ts +35 -3
- package/src/lib/content-resource/index.d.ts +3 -0
- package/src/lib/data/datasource/adapter.strategy.d.ts +3 -0
- package/src/lib/data/datasource/index.d.ts +0 -2
- package/src/lib/data/datasource/strategy.interface.d.ts +5 -1
- package/src/lib/data/datasource/types.d.ts +2 -2
- package/src/lib/data/datasource/workbench.d.ts +4 -3
- package/src/lib/execution-control/context.d.ts +7 -0
- package/src/lib/execution-control/index.d.ts +2 -0
- package/src/lib/managed-queue/index.d.ts +12 -0
- package/src/lib/runtime/capabilities/artifact-drafts.d.ts +10 -1
- package/src/lib/runtime/capabilities/artifact-library.d.ts +52 -0
- package/src/lib/runtime/capabilities/artifacts.d.ts +15 -0
- package/src/lib/runtime/capabilities/index.d.ts +1 -0
- package/src/lib/runtime/capabilities/mcp-client-runtime.d.ts +2 -0
- package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +12 -3
- package/src/lib/sandbox/file-edit-command.d.ts +2 -0
- package/src/lib/sandbox/file-edit-diff.d.ts +1 -0
- package/src/lib/sandbox/protocol.d.ts +13 -1
- package/src/lib/sandbox/runtime-provider.d.ts +12 -0
- package/src/lib/data/datasource/workbench-adapter.d.ts +0 -51
- package/src/lib/data/datasource/workbench-pagination.d.ts +0 -6
- package/src/lib/data/datasource/workbench-sql-lexer.d.ts +0 -11
- package/src/lib/data/datasource/workbench-sql-syntax.d.ts +0 -3
- package/src/lib/data/datasource/workbench-sql.d.ts +0 -20
|
@@ -7,6 +7,8 @@ Artifact presentations separate authenticated display from owner-only management
|
|
|
7
7
|
|
|
8
8
|
## Provider contract
|
|
9
9
|
|
|
10
|
+
Register an `ArtifactTypeProvider` with `presentation: {mode: 'authenticated'}` and create Artifacts with its explicit `type` reference. The type and presentation providers must belong to the same plugin installation. See [Artifact type plugins](./artifact-types.md). Anonymous snapshots use the separate snapshot mode and have no query operations.
|
|
11
|
+
|
|
10
12
|
Register a Nest provider with `@ArtifactPresentationProvider({pluginName, resourceType})`, implement `IArtifactPresentationProvider`, and include it in the plugin module. Registry discovery uses the explicit source pair and plugin provenance in the authorized organization.
|
|
11
13
|
|
|
12
14
|
- `getEntry()` returns `{html}` with its packaged frontend assets.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Artifact type plugins
|
|
2
|
+
|
|
3
|
+
The host owns Artifact containers, immutable versions, links, audience authorization, expiry, revocation, integrity checks and audit. A type contribution owns its content schema and additional business restrictions. Type approval never overrides platform authorization.
|
|
4
|
+
|
|
5
|
+
## Register a type
|
|
6
|
+
|
|
7
|
+
Include a decorated provider in the native plugin's Nest module:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { Injectable } from '@nestjs/common'
|
|
11
|
+
import {
|
|
12
|
+
ArtifactTypeProvider,
|
|
13
|
+
type ArtifactTypeDefinition,
|
|
14
|
+
type IArtifactTypeProvider,
|
|
15
|
+
type ArtifactTypeSource,
|
|
16
|
+
type ArtifactTypeActor,
|
|
17
|
+
type ContentOperation
|
|
18
|
+
} from '@xpert-ai/plugin-sdk'
|
|
19
|
+
import { z } from 'zod/v3'
|
|
20
|
+
|
|
21
|
+
const report = z.object({ schemaVersion: z.literal(1), title: z.string(), body: z.string() }).strict()
|
|
22
|
+
|
|
23
|
+
@Injectable()
|
|
24
|
+
@ArtifactTypeProvider('inspection-report')
|
|
25
|
+
export class InspectionReportArtifactType implements IArtifactTypeProvider {
|
|
26
|
+
readonly definition: ArtifactTypeDefinition = {
|
|
27
|
+
kinds: ['file'],
|
|
28
|
+
content: { mimeTypes: ['application/json'], maxBytes: 1024 * 1024 },
|
|
29
|
+
sharing: {
|
|
30
|
+
accessModes: ['organization_all'],
|
|
31
|
+
versionModes: ['version'],
|
|
32
|
+
maxTtlSeconds: 7 * 86400,
|
|
33
|
+
allowDownload: false,
|
|
34
|
+
mutableLinks: false,
|
|
35
|
+
descriptor: false,
|
|
36
|
+
shareKey: 'published-report'
|
|
37
|
+
},
|
|
38
|
+
presentation: { mode: 'file' }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
constructor(private readonly reports: InspectionReportsService) {}
|
|
42
|
+
|
|
43
|
+
async authorize(source: ArtifactTypeSource, actor: ArtifactTypeActor, operation: ContentOperation) {
|
|
44
|
+
// Reuse the application's governed resource API. A share is not source access.
|
|
45
|
+
if (operation === 'read') await this.reports.assertExportAvailable(source)
|
|
46
|
+
else await this.reports.authorizeExport(source, actor, operation)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
validateContent(content: Buffer) {
|
|
50
|
+
report.parse(JSON.parse(content.toString('utf8')))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`InspectionReportsService` represents the plugin's business authorization service. Both synchronous and asynchronous validators are supported and awaited. Optional `assertPublication(source, access)` and `assertLink(source, link)` impose further dynamic restrictions, such as a deployment setting.
|
|
56
|
+
|
|
57
|
+
The decorator declares only `resourceType`. The plugin loader supplies `pluginName` and installation scope. Plugins cannot claim the platform namespace or a different plugin's type. The same provider instance cannot be reused across installations.
|
|
58
|
+
|
|
59
|
+
Create with an explicit type using the existing runtime capability:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const type = { pluginName: '@company/inspection', resourceType: 'inspection-report' }
|
|
63
|
+
const artifact = await artifacts.createArtifact({
|
|
64
|
+
type,
|
|
65
|
+
source: { ...type, resourceId: reportId },
|
|
66
|
+
kind: 'file',
|
|
67
|
+
title: reportTitle
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`type` is the business type; `kind` is the platform format family and version `mimeType` describes the bytes. A custom type must match the source's plugin and resource type. Omitting `type` explicitly selects the built-in file behavior for ordinary generated files; a registered custom source cannot bypass its type by selecting file behavior. Use existing `ensureArtifactVersion`, `ensureArtifactShare`, `getArtifactShare` and revoke methods. Scope and resource IDs come from trusted execution or authenticated application context, never Agent-supplied identity fields.
|
|
72
|
+
|
|
73
|
+
The host persists `typeBinding` including the installation scope. Existing bindings cannot be retargeted. Uninstalling a required type denies reads, even if another installation provides a same-named type. Owners can still revoke links. Untyped rows are denied; this new protocol does not infer legacy types. The schema adds a nullable JSON column; new creation always writes a binding.
|
|
74
|
+
|
|
75
|
+
## Display modes
|
|
76
|
+
|
|
77
|
+
- `file`: serve the authorized immutable file through the ordinary Artifact content pipeline.
|
|
78
|
+
- `snapshot`: provide `snapshot: {kind: 'plugin', read(context), getEntry()}`. `read` returns presentation data from the already-authorized version; `getEntry` returns packaged HTML using the existing remote-component protocol. Use `requestData` to consume the data. There are no query operations. Viewer identity is an explicit anonymous/authenticated union; rendering has no ambient authenticated request identity. Public links use `/artifacts/snapshot/:slug`, including login handling for restricted links. The iframe remains opaque, no-network and script-sandboxed. The host checks access/type availability again after rendering, and the client clears expired content and periodically rechecks access.
|
|
79
|
+
- `authenticated`: register the existing `ArtifactPresentationProvider` for the same source and installation. Queries run as the current viewer. Public links do not grant access to this query surface. Declared operations, target versions and both providers are revalidated. See [Artifact presentations](./artifact-presentations.md).
|
|
80
|
+
|
|
81
|
+
All URLs are returned by the platform; plugins do not choose origins or construct share URLs. A snapshot's `data` must contain only deliberately published content. Native server plugins are trusted code; these contracts are not a process sandbox.
|
|
82
|
+
|
|
83
|
+
## Built-in conversation plugin
|
|
84
|
+
|
|
85
|
+
The host registers `ConversationArtifactPlugin` at `@xpert-ai/platform / conversation_snapshot` using this same registry. Its snapshot has `kind: 'host'`, reserved for built-ins. Application composition binds its `/s/:slug` UI, which continues to use ChatKit's read-only MessageList. Conversation entity queries, snapshot schema and public-sharing settings stay in `conversation-sharing`.
|
|
86
|
+
|
|
87
|
+
No host-internal policy interface or compatibility adapter is retained. Deploy contracts, SDK, server schema and Cloud viewer together. Previously untyped experimental rows require an authorized republish; the server does not silently reinterpret them.
|
|
88
|
+
|
|
89
|
+
## Project library integration
|
|
90
|
+
|
|
91
|
+
`ArtifactLibraryRuntimeCapability` (`platform.artifact-library`) manages a Project's pinned references independently of publishing and link creation. Its `add`, `open`, `selectVersion`, `share`, and `revoke` operations accept the authenticated actor and Project (plus Assistant when applicable). A reference is registered in Content Catalog with `presentation.kind: 'artifact'`; collections such as Spaces own only its folder placement. Opening requires both Project membership and the source Artifact's current authorization. Moving, renaming or trashing a reference never mutates the original Artifact.
|
|
92
|
+
|
|
93
|
+
Declare `definition.title` as an `I18nObject` (for example, `{ en_US: 'Shared conversation', zh_Hans: '分享会话' }`) to name the semantic type. Library responses expose the bound type identity and title through `type`; catalog snapshots include it in `presentation.type`. Collections localize this metadata for list, card and management views independently of the reference relationship and rendering kind. Older providers without a title use the generic Artifact label; consumers must not infer types from filenames or user-authored titles.
|
|
94
|
+
|
|
95
|
+
Use `ArtifactsApi.readArtifactVersion({ artifactId, artifactVersionId, purpose })` to read published bytes with source authorization, active-version checks, content validation and checksum verification. `purpose: 'copy'` additionally requires `definition.collection.allowCopy: true`. Custom types default to denying copies; the built-in file type permits them. Copying creates an independent lifecycle under the destination Project's ACL, so the collecting UI must explain and confirm this boundary. Conversation snapshots remain reference-only.
|
|
96
|
+
|
|
97
|
+
The authenticated library viewer reuses the type's file, snapshot or authenticated presentation without minting a share. Existing shares are resolved by the type's `sharing.shareKey` (or `artifact-library`) and their stored URLs can be copied repeatedly. Selecting another reference version does not update the published link. Public sharing remains an explicit, separately authorized operation.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Plugin-owned database workbench
|
|
2
|
+
|
|
3
|
+
The SDK defines `DatabaseWorkbenchAdapter`, its wire types and the existing
|
|
4
|
+
`platform.datasource.workbench` capability. Database implementations belong to
|
|
5
|
+
plugins. Adding an engine does not require a platform engine enum or dispatch branch.
|
|
6
|
+
|
|
7
|
+
A registered `IDataSourceStrategy` opts in with `workbench: { engine: '<stable-id>' }`.
|
|
8
|
+
The host lists that declaration without opening connections, selects the strategy
|
|
9
|
+
using the saved datasource type, then calls `create(savedOptions)` to obtain an
|
|
10
|
+
independent runner. `runner.getWorkbenchAdapter(location?)` creates the adapter.
|
|
11
|
+
Its engine identifier must match the strategy declaration.
|
|
12
|
+
|
|
13
|
+
The plugin interprets and validates `DatabaseLocation`, implements SQL syntax,
|
|
14
|
+
metadata discovery, parameter binding, database/schema selection and driver cleanup.
|
|
15
|
+
It must not treat location fields as credentials, identity or arbitrary driver options.
|
|
16
|
+
The host retains actor/tenant/organization checks, source authorization and revision
|
|
17
|
+
checks, write permission checks and session cleanup. Every invocation revalidates
|
|
18
|
+
host scope. The adapter and runner are closed when the saved connection changes.
|
|
19
|
+
|
|
20
|
+
Consumers resolve the existing capability by its stable string ID. Do not dispatch
|
|
21
|
+
plugin-side CQRS commands or import platform services. No new factory capability or
|
|
22
|
+
parallel plugin registry is introduced.
|
|
23
|
+
|
|
24
|
+
## Breaking migration
|
|
25
|
+
|
|
26
|
+
The SDK no longer exports its mixed-engine `SqlDatabaseWorkbenchAdapter`,
|
|
27
|
+
`WorkbenchTransport`, `splitWorkbenchSql`, `requireReadStatement`,
|
|
28
|
+
`quoteDatabaseIdentifier`, or SQL pagination/lexer implementations. Use the
|
|
29
|
+
corresponding database plugin implementation and the plugin repository's
|
|
30
|
+
`@xpert-ai/sql-workbench` helpers. MySQL/Doris, PostgreSQL and DB Studio are migrated
|
|
31
|
+
in the companion plugin change; HANA implements the same contract independently.
|
|
32
|
+
|
|
33
|
+
Strategies without an explicit workbench declaration are not exposed by this
|
|
34
|
+
runtime. Coordinate the host/SDK patch release with the migrated plugins; do not
|
|
35
|
+
upgrade a host that still relies on the removed SDK implementation exports.
|
|
36
|
+
After the SDK is published, update the plugin SDK dependency floors and lockfile
|
|
37
|
+
and validate a clean install against that actual version before release.
|