@xpert-ai/plugin-sdk 3.23.0 → 3.23.1
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/_object_without_properties_loose.cjs.js +16 -0
- package/_object_without_properties_loose.esm.js +14 -0
- package/analytics-result.cjs.js +212 -0
- package/analytics-result.esm.js +201 -0
- package/analytics.cjs.default.js +1 -0
- package/analytics.cjs.js +17 -0
- package/analytics.cjs.mjs +2 -0
- package/analytics.d.ts +1 -0
- package/analytics.esm.js +2 -0
- package/artifact-document.cjs.default.js +1 -0
- package/artifact-document.cjs.js +581 -0
- package/artifact-document.cjs.mjs +2 -0
- package/artifact-document.d.ts +1 -0
- package/artifact-document.esm.js +563 -0
- package/data-workbench.cjs.js +23 -6
- package/data-workbench.esm.js +23 -6
- package/docs/analytics.md +66 -0
- package/docs/artifact-documents.md +74 -0
- package/docs/artifact-drafts.md +24 -0
- package/docs/json-encoded-schema.md +19 -0
- package/docs/workspace-dataset-pipelines.md +120 -0
- package/docs/workspace-file-tools.md +60 -0
- package/index.cjs.js +84 -19
- package/index.esm.js +127 -82
- package/model-provider-toolset.cjs.js +1 -1
- package/model-provider-toolset.esm.js +1 -1
- package/model-provider.cjs.js +37 -1
- package/model-provider.esm.js +33 -2
- package/package.json +14 -2
- package/src/analytics.d.ts +3 -0
- package/src/artifact-document.d.ts +5 -0
- package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +10 -10
- package/src/lib/artifact-document/dependencies.d.ts +101 -0
- package/src/lib/artifact-document/host.d.ts +30 -0
- package/src/lib/artifact-document/protocol.d.ts +60 -0
- package/src/lib/artifact-document/runtime.d.ts +4 -0
- package/src/lib/artifact-document/sha256.d.ts +2 -0
- package/src/lib/core/index.d.ts +1 -0
- package/src/lib/core/json-encoded-schema.d.ts +15 -0
- package/src/lib/data/analytics/analytics-provider.d.ts +74 -0
- package/src/lib/data/analytics/analytics-result.d.ts +4 -0
- package/src/lib/data/analytics/analytics.registry.d.ts +10 -0
- package/src/lib/data/analytics/analytics.schema.d.ts +206 -0
- package/src/lib/data/analytics/index.d.ts +4 -0
- package/src/lib/data/datasource/index.d.ts +1 -0
- package/src/lib/data/datasource/workbench-adapter.d.ts +11 -1
- package/src/lib/data/datasource/workbench-sql.d.ts +12 -0
- package/src/lib/runtime/capabilities/artifact-drafts.d.ts +29 -0
- package/src/lib/runtime/capabilities/artifacts.d.ts +10 -0
- package/src/lib/runtime/capabilities/index.d.ts +1 -0
- package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +36 -2
- package/src/lib/runtime/index.d.ts +2 -0
- package/src/lib/runtime/mutation-evidence.d.ts +7 -0
- package/src/lib/runtime/workspace-file-tools.d.ts +11 -0
- package/src/lib/sandbox/runtime-provider.d.ts +4 -0
package/model-provider.cjs.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var _extends = require('./_extends.cjs.js');
|
|
4
4
|
var contracts = require('@xpert-ai/contracts');
|
|
5
5
|
var common = require('@nestjs/common');
|
|
6
|
-
var tools = require('@langchain/core/tools');
|
|
7
6
|
var v3 = require('zod/v3');
|
|
7
|
+
var tools = require('@langchain/core/tools');
|
|
8
8
|
|
|
9
9
|
function createRuntimeCapability(id, options = {}) {
|
|
10
10
|
return Object.freeze({
|
|
@@ -198,6 +198,10 @@ const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts',
|
|
|
198
198
|
description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
+
const ArtifactDraftsRuntimeCapability = createRuntimeCapability('platform.artifact-drafts', {
|
|
202
|
+
description: 'Persist working copies with optimistic concurrency; atomically publish a confirmed revision as an immutable Artifact version.'
|
|
203
|
+
});
|
|
204
|
+
|
|
201
205
|
/** Stable source identifier for portable workspace file references. */ const WORKSPACE_FILES_SOURCE = 'platform.workspace.files';
|
|
202
206
|
const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.workspace.files', {
|
|
203
207
|
description: 'Upload, understand, search parsed chunks, resolve, read, and delete files in Xpert workspace volumes.'
|
|
@@ -211,6 +215,7 @@ const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.worksp
|
|
|
211
215
|
'SANDBOX_VERSION_MISMATCH',
|
|
212
216
|
'SANDBOX_CAPACITY_UNAVAILABLE',
|
|
213
217
|
'SANDBOX_START_FAILED',
|
|
218
|
+
'SANDBOX_INVOCATION_FAILED',
|
|
214
219
|
'BROWSER_LAUNCH_FAILED',
|
|
215
220
|
'EXPORT_TIMEOUT',
|
|
216
221
|
'EXPORT_OOM',
|
|
@@ -220,6 +225,12 @@ const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.worksp
|
|
|
220
225
|
'SANDBOX_CANCELLED'
|
|
221
226
|
];
|
|
222
227
|
/** Line prefix used by trusted Actions to report structured, provider-neutral progress. */ const SANDBOX_JOB_PROGRESS_PREFIX = 'XPERT_SANDBOX_PROGRESS ';
|
|
228
|
+
/**
|
|
229
|
+
* Stdout frame: prefix + JSON { id, operation, payload } + newline.
|
|
230
|
+
* Core writes { id, value } to <workspaceRoot>/invocations/<id>.json after validation.
|
|
231
|
+
* IDs are unique per attempt and restricted to 1–64 ASCII letters, digits, '_' or '-'.
|
|
232
|
+
* The bridge has no network endpoint and gives the script no host credentials.
|
|
233
|
+
*/ const SANDBOX_JOB_INVOCATION_PREFIX = 'XPERT_SANDBOX_INVOKE ';
|
|
223
234
|
/** Error carrying retry policy and Job identity across plugin queue handlers. */ class SandboxJobRuntimeError extends Error {
|
|
224
235
|
constructor(code, message, retryable, jobId){
|
|
225
236
|
super(message);
|
|
@@ -254,6 +265,26 @@ const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-image
|
|
|
254
265
|
description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
|
|
255
266
|
});
|
|
256
267
|
|
|
268
|
+
/** Portable Agent input; filesystem containment and authorization remain with the host. */ const workspaceRelativeFilePathSchema = v3.z.string().min(1).max(1024).refine((value)=>!/[\\\x00-\x1f\x7f]/.test(value) && !/^[A-Za-z]:/.test(value) && value.split('/').every((part)=>part.length > 0 && part === part.trim() && part !== '.' && part !== '..'), 'Use a workspace-relative file path with non-empty segments; no absolute paths, traversal or surrounding whitespace.');
|
|
269
|
+
/** Host-owned metadata lets plugins observe file intent without guessing tool names. */ const workspaceFileMutationMetadata = {
|
|
270
|
+
workspaceFileOperation: {
|
|
271
|
+
type: 'mutation',
|
|
272
|
+
pathArgument: 'file_path'
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
const mutationMetadata = v3.z.object({
|
|
276
|
+
workspaceFileOperation: v3.z.object({
|
|
277
|
+
type: v3.z.literal('mutation'),
|
|
278
|
+
pathArgument: v3.z.string().min(1)
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
function workspaceFileMutationPath(metadata, args) {
|
|
282
|
+
const descriptor = mutationMetadata.safeParse(metadata);
|
|
283
|
+
if (!descriptor.success) return undefined;
|
|
284
|
+
const path = workspaceRelativeFilePathSchema.safeParse(args[descriptor.data.workspaceFileOperation.pathArgument]);
|
|
285
|
+
return path.success ? path.data : undefined;
|
|
286
|
+
}
|
|
287
|
+
|
|
257
288
|
/**
|
|
258
289
|
* Shared host-runtime plumbing for built-in tools backed by a configured model provider.
|
|
259
290
|
* Provider request/response semantics remain owned by each plugin.
|
|
@@ -370,6 +401,7 @@ function normalizeWorkspaceScope(scope) {
|
|
|
370
401
|
|
|
371
402
|
exports.ActorTokenRuntimeCapability = ActorTokenRuntimeCapability;
|
|
372
403
|
exports.ActorTokenRuntimeFactoryCapability = ActorTokenRuntimeFactoryCapability;
|
|
404
|
+
exports.ArtifactDraftsRuntimeCapability = ArtifactDraftsRuntimeCapability;
|
|
373
405
|
exports.ArtifactsRuntimeCapability = ArtifactsRuntimeCapability;
|
|
374
406
|
exports.BaseTool = BaseTool;
|
|
375
407
|
exports.BaseToolset = BaseToolset;
|
|
@@ -381,6 +413,7 @@ exports.ProjectProvisioningRuntimeCapability = ProjectProvisioningRuntimeCapabil
|
|
|
381
413
|
exports.RUNTIME_CAPABILITY_PROVIDER = RUNTIME_CAPABILITY_PROVIDER;
|
|
382
414
|
exports.RuntimeCapabilityProvider = RuntimeCapabilityProvider;
|
|
383
415
|
exports.SANDBOX_JOB_ERROR_CODES = SANDBOX_JOB_ERROR_CODES;
|
|
416
|
+
exports.SANDBOX_JOB_INVOCATION_PREFIX = SANDBOX_JOB_INVOCATION_PREFIX;
|
|
384
417
|
exports.SANDBOX_JOB_PROGRESS_PREFIX = SANDBOX_JOB_PROGRESS_PREFIX;
|
|
385
418
|
exports.SandboxJobRuntimeError = SandboxJobRuntimeError;
|
|
386
419
|
exports.SandboxJobsRuntimeCapability = SandboxJobsRuntimeCapability;
|
|
@@ -390,3 +423,6 @@ exports.WorkspaceFilesRuntimeCapability = WorkspaceFilesRuntimeCapability;
|
|
|
390
423
|
exports.XPERT_RUNTIME_CAPABILITIES_TOKEN = XPERT_RUNTIME_CAPABILITIES_TOKEN;
|
|
391
424
|
exports.createRuntimeCapability = createRuntimeCapability;
|
|
392
425
|
exports.isSandboxJobRuntimeError = isSandboxJobRuntimeError;
|
|
426
|
+
exports.workspaceFileMutationMetadata = workspaceFileMutationMetadata;
|
|
427
|
+
exports.workspaceFileMutationPath = workspaceFileMutationPath;
|
|
428
|
+
exports.workspaceRelativeFilePathSchema = workspaceRelativeFilePathSchema;
|
package/model-provider.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ as _extends } from './_extends.esm.js';
|
|
2
2
|
import { AiModelTypeEnum } from '@xpert-ai/contracts';
|
|
3
3
|
import { SetMetadata, Logger } from '@nestjs/common';
|
|
4
|
-
import { BaseToolkit, StructuredTool } from '@langchain/core/tools';
|
|
5
4
|
import { z } from 'zod/v3';
|
|
5
|
+
import { BaseToolkit, StructuredTool } from '@langchain/core/tools';
|
|
6
6
|
|
|
7
7
|
function createRuntimeCapability(id, options = {}) {
|
|
8
8
|
return Object.freeze({
|
|
@@ -196,6 +196,10 @@ const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts',
|
|
|
196
196
|
description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
|
|
197
197
|
});
|
|
198
198
|
|
|
199
|
+
const ArtifactDraftsRuntimeCapability = createRuntimeCapability('platform.artifact-drafts', {
|
|
200
|
+
description: 'Persist working copies with optimistic concurrency; atomically publish a confirmed revision as an immutable Artifact version.'
|
|
201
|
+
});
|
|
202
|
+
|
|
199
203
|
/** Stable source identifier for portable workspace file references. */ const WORKSPACE_FILES_SOURCE = 'platform.workspace.files';
|
|
200
204
|
const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.workspace.files', {
|
|
201
205
|
description: 'Upload, understand, search parsed chunks, resolve, read, and delete files in Xpert workspace volumes.'
|
|
@@ -209,6 +213,7 @@ const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.worksp
|
|
|
209
213
|
'SANDBOX_VERSION_MISMATCH',
|
|
210
214
|
'SANDBOX_CAPACITY_UNAVAILABLE',
|
|
211
215
|
'SANDBOX_START_FAILED',
|
|
216
|
+
'SANDBOX_INVOCATION_FAILED',
|
|
212
217
|
'BROWSER_LAUNCH_FAILED',
|
|
213
218
|
'EXPORT_TIMEOUT',
|
|
214
219
|
'EXPORT_OOM',
|
|
@@ -218,6 +223,12 @@ const WorkspaceFilesRuntimeCapability = createRuntimeCapability('platform.worksp
|
|
|
218
223
|
'SANDBOX_CANCELLED'
|
|
219
224
|
];
|
|
220
225
|
/** Line prefix used by trusted Actions to report structured, provider-neutral progress. */ const SANDBOX_JOB_PROGRESS_PREFIX = 'XPERT_SANDBOX_PROGRESS ';
|
|
226
|
+
/**
|
|
227
|
+
* Stdout frame: prefix + JSON { id, operation, payload } + newline.
|
|
228
|
+
* Core writes { id, value } to <workspaceRoot>/invocations/<id>.json after validation.
|
|
229
|
+
* IDs are unique per attempt and restricted to 1–64 ASCII letters, digits, '_' or '-'.
|
|
230
|
+
* The bridge has no network endpoint and gives the script no host credentials.
|
|
231
|
+
*/ const SANDBOX_JOB_INVOCATION_PREFIX = 'XPERT_SANDBOX_INVOKE ';
|
|
221
232
|
/** Error carrying retry policy and Job identity across plugin queue handlers. */ class SandboxJobRuntimeError extends Error {
|
|
222
233
|
constructor(code, message, retryable, jobId){
|
|
223
234
|
super(message);
|
|
@@ -252,6 +263,26 @@ const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-image
|
|
|
252
263
|
description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
|
|
253
264
|
});
|
|
254
265
|
|
|
266
|
+
/** Portable Agent input; filesystem containment and authorization remain with the host. */ const workspaceRelativeFilePathSchema = z.string().min(1).max(1024).refine((value)=>!/[\\\x00-\x1f\x7f]/.test(value) && !/^[A-Za-z]:/.test(value) && value.split('/').every((part)=>part.length > 0 && part === part.trim() && part !== '.' && part !== '..'), 'Use a workspace-relative file path with non-empty segments; no absolute paths, traversal or surrounding whitespace.');
|
|
267
|
+
/** Host-owned metadata lets plugins observe file intent without guessing tool names. */ const workspaceFileMutationMetadata = {
|
|
268
|
+
workspaceFileOperation: {
|
|
269
|
+
type: 'mutation',
|
|
270
|
+
pathArgument: 'file_path'
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const mutationMetadata = z.object({
|
|
274
|
+
workspaceFileOperation: z.object({
|
|
275
|
+
type: z.literal('mutation'),
|
|
276
|
+
pathArgument: z.string().min(1)
|
|
277
|
+
})
|
|
278
|
+
});
|
|
279
|
+
function workspaceFileMutationPath(metadata, args) {
|
|
280
|
+
const descriptor = mutationMetadata.safeParse(metadata);
|
|
281
|
+
if (!descriptor.success) return undefined;
|
|
282
|
+
const path = workspaceRelativeFilePathSchema.safeParse(args[descriptor.data.workspaceFileOperation.pathArgument]);
|
|
283
|
+
return path.success ? path.data : undefined;
|
|
284
|
+
}
|
|
285
|
+
|
|
255
286
|
/**
|
|
256
287
|
* Shared host-runtime plumbing for built-in tools backed by a configured model provider.
|
|
257
288
|
* Provider request/response semantics remain owned by each plugin.
|
|
@@ -366,4 +397,4 @@ function normalizeWorkspaceScope(scope) {
|
|
|
366
397
|
} : {});
|
|
367
398
|
}
|
|
368
399
|
|
|
369
|
-
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, 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,
|
|
400
|
+
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, 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, ArtifactDraftsRuntimeCapability as b, createRuntimeCapability as c, ArtifactsRuntimeCapability as d, BaseTool as e, BaseToolset as f, ProjectProvisioningRuntimeCapability as g, RuntimeCapabilityProvider as h, SANDBOX_JOB_INVOCATION_PREFIX as i, SANDBOX_JOB_PROGRESS_PREFIX as j, SandboxJobRuntimeError as k, SandboxJobsRuntimeCapability as l, WORKSPACE_FILES_SOURCE as m, isSandboxJobRuntimeError as n, workspaceFileMutationPath as o, workspaceRelativeFilePathSchema as p, workspaceFileMutationMetadata as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.23.
|
|
3
|
+
"version": "3.23.1",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
"main": "./index.cjs.js",
|
|
13
13
|
"module": "./index.esm.js",
|
|
14
14
|
"exports": {
|
|
15
|
+
"./analytics": {
|
|
16
|
+
"module": "./analytics.esm.js",
|
|
17
|
+
"types": "./analytics.d.ts",
|
|
18
|
+
"import": "./analytics.cjs.mjs",
|
|
19
|
+
"default": "./analytics.cjs.js"
|
|
20
|
+
},
|
|
15
21
|
"./package.json": "./package.json",
|
|
16
22
|
".": {
|
|
17
23
|
"module": "./index.esm.js",
|
|
@@ -31,6 +37,12 @@
|
|
|
31
37
|
"import": "./data-workbench.cjs.mjs",
|
|
32
38
|
"default": "./data-workbench.cjs.js"
|
|
33
39
|
},
|
|
40
|
+
"./artifact-document": {
|
|
41
|
+
"module": "./artifact-document.esm.js",
|
|
42
|
+
"types": "./artifact-document.d.ts",
|
|
43
|
+
"import": "./artifact-document.cjs.mjs",
|
|
44
|
+
"default": "./artifact-document.cjs.js"
|
|
45
|
+
},
|
|
34
46
|
"./collaboration-client": {
|
|
35
47
|
"module": "./collaboration-client.esm.js",
|
|
36
48
|
"types": "./collaboration-client.d.ts",
|
|
@@ -62,7 +74,7 @@
|
|
|
62
74
|
},
|
|
63
75
|
"dependencies": {
|
|
64
76
|
"@langchain/openai": "0.6.9",
|
|
65
|
-
"@xpert-ai/contracts": "3.
|
|
77
|
+
"@xpert-ai/contracts": "3.23.0",
|
|
66
78
|
"express": "^4.22.1",
|
|
67
79
|
"js-tiktoken": "^1.0.21"
|
|
68
80
|
},
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Browser-safe host for untrusted HTML; no Nest, credentials or provider implementations. */
|
|
2
|
+
export * from './lib/artifact-document/protocol';
|
|
3
|
+
export * from './lib/artifact-document/runtime';
|
|
4
|
+
export * from './lib/artifact-document/host';
|
|
5
|
+
export * from './lib/artifact-document/dependencies';
|
|
@@ -67,11 +67,6 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
|
|
|
67
67
|
}, "strict", z.ZodTypeAny, {
|
|
68
68
|
version?: 1;
|
|
69
69
|
kind?: "progress";
|
|
70
|
-
projectTask?: {
|
|
71
|
-
projectId?: string;
|
|
72
|
-
projectTaskId?: string;
|
|
73
|
-
taskExecutionId?: string;
|
|
74
|
-
};
|
|
75
70
|
progress?: {
|
|
76
71
|
source?: "executor" | "host";
|
|
77
72
|
startedAt?: string;
|
|
@@ -83,16 +78,16 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
|
|
|
83
78
|
observedAt?: string;
|
|
84
79
|
phase?: string;
|
|
85
80
|
};
|
|
86
|
-
invocationId?: string;
|
|
87
|
-
revision?: number;
|
|
88
|
-
}, {
|
|
89
|
-
version?: 1;
|
|
90
|
-
kind?: "progress";
|
|
91
81
|
projectTask?: {
|
|
92
82
|
projectId?: string;
|
|
93
83
|
projectTaskId?: string;
|
|
94
84
|
taskExecutionId?: string;
|
|
95
85
|
};
|
|
86
|
+
invocationId?: string;
|
|
87
|
+
revision?: number;
|
|
88
|
+
}, {
|
|
89
|
+
version?: 1;
|
|
90
|
+
kind?: "progress";
|
|
96
91
|
progress?: {
|
|
97
92
|
source?: "executor" | "host";
|
|
98
93
|
startedAt?: string;
|
|
@@ -104,6 +99,11 @@ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z
|
|
|
104
99
|
observedAt?: string;
|
|
105
100
|
phase?: string;
|
|
106
101
|
};
|
|
102
|
+
projectTask?: {
|
|
103
|
+
projectId?: string;
|
|
104
|
+
projectTaskId?: string;
|
|
105
|
+
taskExecutionId?: string;
|
|
106
|
+
};
|
|
107
107
|
invocationId?: string;
|
|
108
108
|
revision?: number;
|
|
109
109
|
}>, z.ZodObject<{
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
export interface ArtifactDocumentDependencyLock {
|
|
3
|
+
id: string;
|
|
4
|
+
version: string;
|
|
5
|
+
format: 'classic-script';
|
|
6
|
+
global: string;
|
|
7
|
+
sha256: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ArtifactDocumentDependencyAsset extends ArtifactDocumentDependencyLock {
|
|
10
|
+
source: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const artifactDocumentDependencyLock: z.ZodEffects<z.ZodObject<{
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
version: z.ZodString;
|
|
15
|
+
format: z.ZodLiteral<"classic-script">;
|
|
16
|
+
global: z.ZodEffects<z.ZodString, string, string>;
|
|
17
|
+
sha256: z.ZodString;
|
|
18
|
+
}, "strict", z.ZodTypeAny, {
|
|
19
|
+
id?: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
format?: "classic-script";
|
|
22
|
+
global?: string;
|
|
23
|
+
sha256?: string;
|
|
24
|
+
}, {
|
|
25
|
+
id?: string;
|
|
26
|
+
version?: string;
|
|
27
|
+
format?: "classic-script";
|
|
28
|
+
global?: string;
|
|
29
|
+
sha256?: string;
|
|
30
|
+
}>, ArtifactDocumentDependencyLock, {
|
|
31
|
+
id?: string;
|
|
32
|
+
version?: string;
|
|
33
|
+
format?: "classic-script";
|
|
34
|
+
global?: string;
|
|
35
|
+
sha256?: string;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const artifactDocumentDependencyLocks: z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
version: z.ZodString;
|
|
40
|
+
format: z.ZodLiteral<"classic-script">;
|
|
41
|
+
global: z.ZodEffects<z.ZodString, string, string>;
|
|
42
|
+
sha256: z.ZodString;
|
|
43
|
+
}, "strict", z.ZodTypeAny, {
|
|
44
|
+
id?: string;
|
|
45
|
+
version?: string;
|
|
46
|
+
format?: "classic-script";
|
|
47
|
+
global?: string;
|
|
48
|
+
sha256?: string;
|
|
49
|
+
}, {
|
|
50
|
+
id?: string;
|
|
51
|
+
version?: string;
|
|
52
|
+
format?: "classic-script";
|
|
53
|
+
global?: string;
|
|
54
|
+
sha256?: string;
|
|
55
|
+
}>, ArtifactDocumentDependencyLock, {
|
|
56
|
+
id?: string;
|
|
57
|
+
version?: string;
|
|
58
|
+
format?: "classic-script";
|
|
59
|
+
global?: string;
|
|
60
|
+
sha256?: string;
|
|
61
|
+
}>, "many">, ArtifactDocumentDependencyLock[], {
|
|
62
|
+
id?: string;
|
|
63
|
+
version?: string;
|
|
64
|
+
format?: "classic-script";
|
|
65
|
+
global?: string;
|
|
66
|
+
sha256?: string;
|
|
67
|
+
}[]>;
|
|
68
|
+
export declare const artifactDocumentDependencyAssets: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
69
|
+
id: z.ZodString;
|
|
70
|
+
version: z.ZodString;
|
|
71
|
+
format: z.ZodLiteral<"classic-script">;
|
|
72
|
+
global: z.ZodEffects<z.ZodString, string, string>;
|
|
73
|
+
sha256: z.ZodString;
|
|
74
|
+
} & {
|
|
75
|
+
source: z.ZodString;
|
|
76
|
+
}, "strict", z.ZodTypeAny, {
|
|
77
|
+
id?: string;
|
|
78
|
+
version?: string;
|
|
79
|
+
format?: "classic-script";
|
|
80
|
+
global?: string;
|
|
81
|
+
sha256?: string;
|
|
82
|
+
source?: string;
|
|
83
|
+
}, {
|
|
84
|
+
id?: string;
|
|
85
|
+
version?: string;
|
|
86
|
+
format?: "classic-script";
|
|
87
|
+
global?: string;
|
|
88
|
+
sha256?: string;
|
|
89
|
+
source?: string;
|
|
90
|
+
}>, ArtifactDocumentDependencyAsset, {
|
|
91
|
+
id?: string;
|
|
92
|
+
version?: string;
|
|
93
|
+
format?: "classic-script";
|
|
94
|
+
global?: string;
|
|
95
|
+
sha256?: string;
|
|
96
|
+
source?: string;
|
|
97
|
+
}>, "many">;
|
|
98
|
+
/** Browser/server identical verification. Integrity is not authorization: the caller owns library admission. */
|
|
99
|
+
export declare function verifyArtifactDocumentDependencies(input: unknown, expected?: ArtifactDocumentDependencyLock[]): ArtifactDocumentDependencyAsset[];
|
|
100
|
+
/** Assign script.textContent to preserve exact bytes without eval or HTML parser termination hazards. */
|
|
101
|
+
export declare function renderArtifactDocumentDependencies(assets: ArtifactDocumentDependencyAsset[]): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ArtifactDocumentContext, type ArtifactDocumentQuery } from './protocol';
|
|
2
|
+
import type { ArtifactDocumentDependencyAsset } from './dependencies';
|
|
3
|
+
/** Trusted integration callbacks. T is the plugin's cloneable result shape, independent of any chart library. */
|
|
4
|
+
export interface ArtifactDocumentHostOptions<T> {
|
|
5
|
+
/** Complete untrusted HTML; scripts run only inside the isolated frame. */
|
|
6
|
+
html: string;
|
|
7
|
+
/** Exact packaged bytes pinned to this Artifact version, never URLs or library names from the document. */
|
|
8
|
+
dependencies?: ArtifactDocumentDependencyAsset[];
|
|
9
|
+
/** Public binding IDs and presentation defaults for this document generation. */
|
|
10
|
+
context: ArtifactDocumentContext;
|
|
11
|
+
/** Resolve against saved Bindings on the server with the current user's access; never execute a query definition from HTML. */
|
|
12
|
+
query(input: ArtifactDocumentQuery): Promise<T>;
|
|
13
|
+
/** Latest result for a Binding, suitable for host-owned freshness/partial-result indicators. */
|
|
14
|
+
onResult?(result: T): void;
|
|
15
|
+
/** Stable protocol/query error code; private backend error details are never sent into the document. */
|
|
16
|
+
onError?(code: string): void;
|
|
17
|
+
/** Tracks all pending host queries, including those superseded by newer filter values. */
|
|
18
|
+
onBusy?(busy: boolean): void;
|
|
19
|
+
}
|
|
20
|
+
/** Lifecycle handle for one mount; dispose before replacing the document or its trusted query scope. */
|
|
21
|
+
export interface ArtifactDocumentHost {
|
|
22
|
+
/** Requeries subscribed/previously queried bindings using their last controls. */
|
|
23
|
+
refresh(): void;
|
|
24
|
+
/** Closes the query channel and discards late results; backend cancellation remains the caller's responsibility. */
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
|
27
|
+
/** Dedicated query bridge. Requires a dedicated host document with installArtifactDocumentFramePolicy installed. */
|
|
28
|
+
export declare function mountArtifactDocument<T>(frame: HTMLIFrameElement, options: ArtifactDocumentHostOptions<T>): ArtifactDocumentHost;
|
|
29
|
+
/** Installs a document-wide policy once. Use a dedicated host: all URL-based child frames are denied; srcdoc works. */
|
|
30
|
+
export declare function installArtifactDocumentFramePolicy(hostDocument: Document): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
/** Wire namespace/version shared by the trusted host and its isolated document bootstrap. */
|
|
3
|
+
export declare const ARTIFACT_DOCUMENT_CHANNEL = "xpert.artifact-document";
|
|
4
|
+
export declare const ARTIFACT_DOCUMENT_VERSION = 1;
|
|
5
|
+
/** Portable binding/control identifier; shape validation never grants resource access. */
|
|
6
|
+
export declare const artifactDocumentId: z.ZodString;
|
|
7
|
+
export declare const artifactDocumentValue: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
8
|
+
export declare const artifactDocumentControls: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean>, Record<string, string | number | boolean>>;
|
|
9
|
+
/** The entire untrusted query envelope. Provider definitions, SQL and identity fields are forbidden. */
|
|
10
|
+
export declare const artifactDocumentQuery: z.ZodObject<{
|
|
11
|
+
type: z.ZodLiteral<"query">;
|
|
12
|
+
requestId: z.ZodString;
|
|
13
|
+
bindingId: z.ZodString;
|
|
14
|
+
controls: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean>, Record<string, string | number | boolean>>;
|
|
15
|
+
}, "strict", z.ZodTypeAny, {
|
|
16
|
+
type?: "query";
|
|
17
|
+
controls?: Record<string, string | number | boolean>;
|
|
18
|
+
requestId?: string;
|
|
19
|
+
bindingId?: string;
|
|
20
|
+
}, {
|
|
21
|
+
type?: "query";
|
|
22
|
+
controls?: Record<string, string | number | boolean>;
|
|
23
|
+
requestId?: string;
|
|
24
|
+
bindingId?: string;
|
|
25
|
+
}>;
|
|
26
|
+
/** Flat UI filter values keyed by declared control IDs; validated again by the backend Binding. */
|
|
27
|
+
export type ArtifactDocumentControls = Record<string, string | number | boolean | null>;
|
|
28
|
+
/** Correlates a document request with one host result; the host owns binding resolution and authorization. */
|
|
29
|
+
export interface ArtifactDocumentQuery {
|
|
30
|
+
type: 'query';
|
|
31
|
+
requestId: string;
|
|
32
|
+
bindingId: string;
|
|
33
|
+
controls: ArtifactDocumentControls;
|
|
34
|
+
}
|
|
35
|
+
/** Only public presentation context may cross into the untrusted frame. Never include credentials here. */
|
|
36
|
+
export declare const artifactDocumentContext: z.ZodObject<{
|
|
37
|
+
bindingIds: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
|
|
38
|
+
defaults: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean>, Record<string, string | number | boolean>>;
|
|
39
|
+
theme: z.ZodEnum<["light", "dark"]>;
|
|
40
|
+
locale: z.ZodString;
|
|
41
|
+
}, "strict", z.ZodTypeAny, {
|
|
42
|
+
bindingIds?: string[];
|
|
43
|
+
defaults?: Record<string, string | number | boolean>;
|
|
44
|
+
theme?: "light" | "dark";
|
|
45
|
+
locale?: string;
|
|
46
|
+
}, {
|
|
47
|
+
bindingIds?: string[];
|
|
48
|
+
defaults?: Record<string, string | number | boolean>;
|
|
49
|
+
theme?: "light" | "dark";
|
|
50
|
+
locale?: string;
|
|
51
|
+
}>;
|
|
52
|
+
/** A snapshot for one mount. Artifact/version/actor identity belongs in the trusted query callback closure. */
|
|
53
|
+
export interface ArtifactDocumentContext {
|
|
54
|
+
bindingIds: string[];
|
|
55
|
+
defaults: ArtifactDocumentControls;
|
|
56
|
+
theme: 'light' | 'dark';
|
|
57
|
+
locale: string;
|
|
58
|
+
}
|
|
59
|
+
/** Format/UTF-8 size gate, not a sanitizer. Isolation and server authorization enforce security. */
|
|
60
|
+
export declare const artifactDocumentHtml: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ArtifactDocumentDependencyAsset } from './dependencies';
|
|
2
|
+
export declare const ARTIFACT_DOCUMENT_CSP: string;
|
|
3
|
+
/** Host-owned prefix precedes all authored markup, including malformed/duplicate heads. */
|
|
4
|
+
export declare function renderArtifactDocument(html: string, sessionId: string, dependencies?: ArtifactDocumentDependencyAsset[]): string;
|
package/src/lib/core/index.d.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
/** Options for accepting JSON text alongside a schema's native input. */
|
|
3
|
+
export interface JsonEncodedSchemaOptions {
|
|
4
|
+
/** Maximum string length eligible for decoding, in UTF-16 code units; defaults to 200,000.
|
|
5
|
+
* Native objects and arrays must be bounded by the supplied schema.
|
|
6
|
+
*/
|
|
7
|
+
maxChars?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Decode JSON text at most once, then validate with the supplied schema.
|
|
11
|
+
* Intended for schemas whose native input excludes strings, such as objects and arrays.
|
|
12
|
+
* Failed or oversized text remains unchanged so the schema rejects it; nested strings are not decoded.
|
|
13
|
+
* Callers explicitly opt in at an input boundary; domain schemas remain unchanged.
|
|
14
|
+
*/
|
|
15
|
+
export declare function jsonEncodedSchema<T extends z.ZodTypeAny>(schema: T, { maxChars }?: JsonEncodedSchemaOptions): z.ZodEffects<T, T["_output"], unknown>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { AnalyticsBinding, AnalyticsProviderDescriptor, AnalyticsQueryRequest, AnalyticsSourceSummary, AnalyticalDataset, AnalyticsValue, JSONValue, AnalyticsDiscoveryRequest, AnalyticsDiscoveryResult } from '@xpert-ai/contracts';
|
|
2
|
+
import type { DataSourceActor } from '../datasource/workbench';
|
|
3
|
+
/** Host-created execution scope. Providers must not accept replacements from payload or controls. */
|
|
4
|
+
export interface AnalyticsProviderContext {
|
|
5
|
+
/** Current authenticated actor, not the source owner or Assistant creator. */
|
|
6
|
+
actor: DataSourceActor;
|
|
7
|
+
dataSourceId: string;
|
|
8
|
+
/** Server-only source options; treat as sensitive and never copy into bindings or datasets. */
|
|
9
|
+
options: Record<string, JSONValue>;
|
|
10
|
+
/** Forward to source I/O and stop work on cancellation; a host timeout alone cannot stop ignored I/O. */
|
|
11
|
+
signal: AbortSignal;
|
|
12
|
+
/** Maximum returned rows; report any source truncation explicitly in completeness. */
|
|
13
|
+
maxRows: number;
|
|
14
|
+
/** Remaining budget at provider entry, in milliseconds; use deadlineAt for subsequent/nested work. */
|
|
15
|
+
timeoutMs: number;
|
|
16
|
+
/** Assigned before provider invocation so source execution and audit records can correlate. */
|
|
17
|
+
executionId: string;
|
|
18
|
+
/** Absolute Unix time in milliseconds; child queries must not extend this deadline. */
|
|
19
|
+
deadlineAt: number;
|
|
20
|
+
/** Provider IDs through the current call; forward to child queries for cycle/depth checks. */
|
|
21
|
+
ancestry: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
/** Native-column result before host projection; cells already use canonical AnalyticsValue encodings. */
|
|
24
|
+
export interface AnalyticsProviderResult {
|
|
25
|
+
/** Native row keys and optional exact semantic selectors; declare columns even for zero rows. */
|
|
26
|
+
columns: Array<{
|
|
27
|
+
key: string;
|
|
28
|
+
semanticRef?: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** Keys match columns[].key; the host maps them to Binding.output.fields[].id without coercion. */
|
|
31
|
+
rows: Array<Record<string, AnalyticsValue>>;
|
|
32
|
+
/** Describe the actual result scope/counts; successful transport does not imply a complete result. */
|
|
33
|
+
completeness: AnalyticalDataset['completeness'];
|
|
34
|
+
/** Time of the actual source fetch; distinct from normalization time and business-data freshness. */
|
|
35
|
+
sourceFetchedAt: string;
|
|
36
|
+
/** Optional source snapshot/watermark time; omit rather than inventing one. */
|
|
37
|
+
dataAsOf?: string;
|
|
38
|
+
/** Opaque source or definition revision, carried into Dataset provenance. */
|
|
39
|
+
sourceVersion?: string;
|
|
40
|
+
/** Source-system execution ID, distinct from context.executionId. */
|
|
41
|
+
upstreamExecutionId?: string;
|
|
42
|
+
/** Reference to audit evidence, not embedded logs or credentials. */
|
|
43
|
+
auditRef?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Plugin extension point for SQL, ontology, file or other query formats.
|
|
47
|
+
* Implement native payload validation, source permissions and read-only execution here;
|
|
48
|
+
* the host provides scoped lookup, parameter checks, execution limits and result normalization.
|
|
49
|
+
*/
|
|
50
|
+
export interface AnalyticsQueryProvider {
|
|
51
|
+
readonly descriptor: AnalyticsProviderDescriptor;
|
|
52
|
+
/** Optional read-only metadata discovery; apply the same scope, cancellation and deadline as queries. */
|
|
53
|
+
discover?(request: JSONValue, context: AnalyticsProviderContext): Promise<AnalyticsDiscoveryResult>;
|
|
54
|
+
/** Parameters are resolved by name; binding.payload remains opaque to the host and needs provider validation. */
|
|
55
|
+
execute(binding: AnalyticsBinding, parameters: Record<string, AnalyticsValue>, context: AnalyticsProviderContext): Promise<AnalyticsProviderResult>;
|
|
56
|
+
}
|
|
57
|
+
/** Trusted parent constraints for composed queries; forward the parent context, never client JSON. */
|
|
58
|
+
export interface AnalyticsQueryExecution {
|
|
59
|
+
signal: AbortSignal;
|
|
60
|
+
/** Parent's absolute Unix deadline in milliseconds, not a fresh timeout for each child. */
|
|
61
|
+
deadlineAt: number;
|
|
62
|
+
/** Parent ancestry including its current provider; the runtime appends the child provider ID. */
|
|
63
|
+
ancestry: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
/** Host capability for in-process consumers; every actor must match the current authenticated context. */
|
|
66
|
+
export interface AnalyticsRuntimeApi {
|
|
67
|
+
/** List scoped source/provider metadata without returning connection options. */
|
|
68
|
+
list(actor: DataSourceActor): Promise<AnalyticsSourceSummary[]>;
|
|
69
|
+
/** Discover through a registered provider; discovery never substitutes for query authorization. */
|
|
70
|
+
discover(actor: DataSourceActor, request: AnalyticsDiscoveryRequest): Promise<AnalyticsDiscoveryResult>;
|
|
71
|
+
/** Execute and normalize fresh data; composed calls must propagate parent constraints via execution. */
|
|
72
|
+
query(actor: DataSourceActor, request: AnalyticsQueryRequest, execution?: AnalyticsQueryExecution): Promise<AnalyticalDataset>;
|
|
73
|
+
}
|
|
74
|
+
export declare const AnalyticsRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<AnalyticsRuntimeApi>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnalyticsBinding, AnalyticalDataset, AnalyticsValue } from '@xpert-ai/contracts';
|
|
2
|
+
import type { AnalyticsProviderResult } from './analytics-provider';
|
|
3
|
+
export declare function resolveAnalyticsParameters(binding: AnalyticsBinding, controls: Record<string, AnalyticsValue>): Record<string, AnalyticsValue>;
|
|
4
|
+
export declare function normalizeAnalyticsResult(binding: AnalyticsBinding, result: AnalyticsProviderResult, executionId: string, maxRows: number): AnalyticalDataset;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../../strategy';
|
|
3
|
+
import type { AnalyticsQueryProvider } from './analytics-provider';
|
|
4
|
+
export declare const ANALYTICS_PROVIDER = "ANALYTICS_QUERY_PROVIDER";
|
|
5
|
+
/** Mark a Nest provider registered by a plugin module; id must match its descriptor.id. */
|
|
6
|
+
export declare const AnalyticsProvider: (id: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
7
|
+
/** Uses shared plugin scoping; execution callers list providers for the current actor's organization. */
|
|
8
|
+
export declare class AnalyticsProviderRegistry extends BaseStrategyRegistry<AnalyticsQueryProvider> {
|
|
9
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
10
|
+
}
|