@xpert-ai/plugin-sdk 3.23.0 → 3.25.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.
Files changed (88) hide show
  1. package/_object_without_properties_loose.cjs.js +16 -0
  2. package/_object_without_properties_loose.esm.js +14 -0
  3. package/analytics-result.cjs.js +212 -0
  4. package/analytics-result.esm.js +201 -0
  5. package/analytics.cjs.default.js +1 -0
  6. package/analytics.cjs.js +17 -0
  7. package/analytics.cjs.mjs +2 -0
  8. package/analytics.d.ts +1 -0
  9. package/analytics.esm.js +2 -0
  10. package/artifact-document.cjs.default.js +1 -0
  11. package/artifact-document.cjs.js +581 -0
  12. package/artifact-document.cjs.mjs +2 -0
  13. package/artifact-document.d.ts +1 -0
  14. package/artifact-document.esm.js +563 -0
  15. package/data-workbench.cjs.js +23 -6
  16. package/data-workbench.esm.js +23 -6
  17. package/docs/README.md +8 -0
  18. package/docs/analytics.md +108 -0
  19. package/docs/artifact-documents.md +74 -0
  20. package/docs/artifact-drafts.md +24 -0
  21. package/docs/artifact-presentations.md +43 -0
  22. package/docs/json-encoded-schema.md +19 -0
  23. package/docs/mcp-client.md +63 -0
  24. package/docs/provider-credential-validation.md +34 -0
  25. package/docs/rest-client.md +24 -0
  26. package/docs/workspace-dataset-pipelines.md +120 -0
  27. package/docs/workspace-file-tools.md +66 -0
  28. package/index.cjs.js +555 -108
  29. package/index.esm.js +573 -172
  30. package/model-provider-toolset.cjs.js +1 -1
  31. package/model-provider-toolset.esm.js +1 -1
  32. package/model-provider.cjs.js +47 -1
  33. package/model-provider.esm.js +41 -2
  34. package/package.json +14 -2
  35. package/src/analytics.d.ts +3 -0
  36. package/src/artifact-document.d.ts +5 -0
  37. package/src/index.d.ts +2 -0
  38. package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +80 -80
  39. package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +36 -1
  40. package/src/lib/agent/runtime/dispatch.d.ts +284 -284
  41. package/src/lib/agent/runtime/index.d.ts +1 -0
  42. package/src/lib/agent/runtime/pipeline-scope.d.ts +110 -0
  43. package/src/lib/agent/runtime/types.d.ts +4 -2
  44. package/src/lib/ai-model/ai-model-provider.interface.d.ts +3 -1
  45. package/src/lib/ai-model/utils/limits.d.ts +4 -2
  46. package/src/lib/artifact-document/dependencies.d.ts +101 -0
  47. package/src/lib/artifact-document/host.d.ts +30 -0
  48. package/src/lib/artifact-document/protocol.d.ts +60 -0
  49. package/src/lib/artifact-document/runtime.d.ts +4 -0
  50. package/src/lib/artifact-document/sha256.d.ts +2 -0
  51. package/src/lib/artifact-presentation/index.d.ts +35 -0
  52. package/src/lib/core/index.d.ts +1 -0
  53. package/src/lib/core/json-encoded-schema.d.ts +15 -0
  54. package/src/lib/data/analytics/analytics-payload.d.ts +3 -0
  55. package/src/lib/data/analytics/analytics-provider.d.ts +74 -0
  56. package/src/lib/data/analytics/analytics-result.d.ts +4 -0
  57. package/src/lib/data/analytics/analytics.registry.d.ts +10 -0
  58. package/src/lib/data/analytics/analytics.schema.d.ts +206 -0
  59. package/src/lib/data/analytics/index.d.ts +5 -0
  60. package/src/lib/data/datasource/index.d.ts +1 -0
  61. package/src/lib/data/datasource/types.d.ts +1 -1
  62. package/src/lib/data/datasource/workbench-adapter.d.ts +11 -1
  63. package/src/lib/data/datasource/workbench-sql.d.ts +12 -0
  64. package/src/lib/project-pipeline/adapters.d.ts +87 -0
  65. package/src/lib/project-pipeline/capability.d.ts +100 -0
  66. package/src/lib/project-pipeline/index.d.ts +5 -0
  67. package/src/lib/project-pipeline/projection.d.ts +71 -0
  68. package/src/lib/project-pipeline/registry.d.ts +509 -0
  69. package/src/lib/project-pipeline/runtime-registry.d.ts +45 -0
  70. package/src/lib/project-pipeline/scoped-registry.d.ts +10 -0
  71. package/src/lib/project-task/index.d.ts +6 -0
  72. package/src/lib/project-type/index.d.ts +17 -1
  73. package/src/lib/rag/types.d.ts +1 -1
  74. package/src/lib/runtime/capabilities/artifact-drafts.d.ts +29 -0
  75. package/src/lib/runtime/capabilities/artifacts.d.ts +12 -0
  76. package/src/lib/runtime/capabilities/index.d.ts +3 -0
  77. package/src/lib/runtime/capabilities/mcp-client-runtime.d.ts +41 -0
  78. package/src/lib/runtime/capabilities/rest-client-runtime.d.ts +34 -0
  79. package/src/lib/runtime/capabilities/sandbox-jobs.d.ts +36 -2
  80. package/src/lib/runtime/index.d.ts +2 -0
  81. package/src/lib/runtime/mutation-evidence.d.ts +7 -0
  82. package/src/lib/runtime/workspace-file-tools.d.ts +11 -0
  83. package/src/lib/sandbox/file-edits.d.ts +4 -0
  84. package/src/lib/sandbox/protocol.d.ts +7 -1
  85. package/src/lib/sandbox/runtime-provider.d.ts +4 -0
  86. package/src/lib/sandbox/sandbox.d.ts +2 -8
  87. package/src/lib/tool-provider/adapters.d.ts +1 -1
  88. package/src/lib/tool-provider/types.d.ts +2 -0
@@ -8,3 +8,4 @@ export * from './results';
8
8
  export * from './execution-runner';
9
9
  export * from './dispatch';
10
10
  export * from './activity';
11
+ export * from './pipeline-scope';
@@ -0,0 +1,110 @@
1
+ import { z } from 'zod/v3';
2
+ /** Host-only provenance. This describes a saved operation; it never grants access by itself. */
3
+ export declare const projectPipelineInvocationScopeSchema: z.ZodEffects<z.ZodObject<{
4
+ tenantId: z.ZodString;
5
+ organizationId: z.ZodString;
6
+ userId: z.ZodString;
7
+ projectId: z.ZodString;
8
+ workspaceId: z.ZodString;
9
+ callerType: z.ZodLiteral<"project_pipeline">;
10
+ callerAgentKey: z.ZodLiteral<"pipeline_node">;
11
+ parentExecutionId: z.ZodString;
12
+ pipelineOrigin: z.ZodObject<{
13
+ instanceId: z.ZodString;
14
+ runId: z.ZodString;
15
+ roundId: z.ZodString;
16
+ nodeInstanceId: z.ZodString;
17
+ operationId: z.ZodString;
18
+ inputDigest: z.ZodString;
19
+ generation: z.ZodNumber;
20
+ }, "strict", z.ZodTypeAny, {
21
+ operationId: string;
22
+ instanceId: string;
23
+ runId: string;
24
+ roundId: string;
25
+ nodeInstanceId: string;
26
+ inputDigest: string;
27
+ generation: number;
28
+ }, {
29
+ operationId: string;
30
+ instanceId: string;
31
+ runId: string;
32
+ roundId: string;
33
+ nodeInstanceId: string;
34
+ inputDigest: string;
35
+ generation: number;
36
+ }>;
37
+ }, "strict", z.ZodTypeAny, {
38
+ userId?: string;
39
+ organizationId?: string;
40
+ tenantId?: string;
41
+ projectId?: string;
42
+ workspaceId?: string;
43
+ callerType?: "project_pipeline";
44
+ callerAgentKey?: "pipeline_node";
45
+ parentExecutionId?: string;
46
+ pipelineOrigin?: {
47
+ operationId: string;
48
+ instanceId: string;
49
+ runId: string;
50
+ roundId: string;
51
+ nodeInstanceId: string;
52
+ inputDigest: string;
53
+ generation: number;
54
+ };
55
+ }, {
56
+ userId?: string;
57
+ organizationId?: string;
58
+ tenantId?: string;
59
+ projectId?: string;
60
+ workspaceId?: string;
61
+ callerType?: "project_pipeline";
62
+ callerAgentKey?: "pipeline_node";
63
+ parentExecutionId?: string;
64
+ pipelineOrigin?: {
65
+ operationId: string;
66
+ instanceId: string;
67
+ runId: string;
68
+ roundId: string;
69
+ nodeInstanceId: string;
70
+ inputDigest: string;
71
+ generation: number;
72
+ };
73
+ }>, {
74
+ userId?: string;
75
+ organizationId?: string;
76
+ tenantId?: string;
77
+ projectId?: string;
78
+ workspaceId?: string;
79
+ callerType?: "project_pipeline";
80
+ callerAgentKey?: "pipeline_node";
81
+ parentExecutionId?: string;
82
+ pipelineOrigin?: {
83
+ operationId: string;
84
+ instanceId: string;
85
+ runId: string;
86
+ roundId: string;
87
+ nodeInstanceId: string;
88
+ inputDigest: string;
89
+ generation: number;
90
+ };
91
+ }, {
92
+ userId?: string;
93
+ organizationId?: string;
94
+ tenantId?: string;
95
+ projectId?: string;
96
+ workspaceId?: string;
97
+ callerType?: "project_pipeline";
98
+ callerAgentKey?: "pipeline_node";
99
+ parentExecutionId?: string;
100
+ pipelineOrigin?: {
101
+ operationId: string;
102
+ instanceId: string;
103
+ runId: string;
104
+ roundId: string;
105
+ nodeInstanceId: string;
106
+ inputDigest: string;
107
+ generation: number;
108
+ };
109
+ }>;
110
+ export type ProjectPipelineInvocationScope = z.output<typeof projectPipelineInvocationScopeSchema>;
@@ -1,4 +1,4 @@
1
- import type { AgentInvocationStatus, AgentRuntimeProgress, ModelExecutionEnvironment, ExecutionActivityCapabilities } from '@xpert-ai/contracts';
1
+ import type { AgentInvocationStatus, AgentRuntimeProgress, ModelExecutionEnvironment, ExecutionActivityCapabilities, ProjectPipelineWorkContext } from '@xpert-ai/contracts';
2
2
  export type { AgentInvocationStatus, AgentRuntimeProgress } from '@xpert-ai/contracts';
3
3
  import type { AgentInvocationDispatchContext } from './dispatch';
4
4
  import type { AgentRunnerReceipt } from './execution-runner';
@@ -21,7 +21,9 @@ export interface AgentInvocationScope {
21
21
  /** Calling Agent key or host-assigned background-task entry. */
22
22
  callerAgentKey: string;
23
23
  /** Omitted preserves existing Assistant callers. Project general agents have no fabricated Assistant ID. */
24
- callerType?: 'xpert' | 'project_agent';
24
+ callerType?: 'xpert' | 'project_agent' | 'project_pipeline';
25
+ /** Exact durable Pipeline work, reauthorized by the host before resolving or controlling a binding. */
26
+ pipelineOrigin?: ProjectPipelineWorkContext;
25
27
  callerXpertId?: string;
26
28
  }
27
29
  /** Authorized, version-pinned target. Pass the resolved snapshot unchanged. */
@@ -1,4 +1,4 @@
1
- import { AiModelTypeEnum, IAiProviderEntity, ICopilotModel, ProviderModel, AIModelEntity, DiscoveredModel } from '@xpert-ai/contracts';
1
+ import { AiModelTypeEnum, IAiProviderEntity, ICopilotModel, ProviderModel, AIModelEntity, DiscoveredModel, ProviderCredentialValidationPolicy } from '@xpert-ai/contracts';
2
2
  import { BaseLanguageModel } from '@langchain/core/language_models/base';
3
3
  import { Embeddings } from '@langchain/core/embeddings';
4
4
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
@@ -8,6 +8,8 @@ import type { NativeModelClientFactory } from './native-model';
8
8
  export interface IAIModelProviderStrategy {
9
9
  /** Fetch account-visible models without persisting them or invoking model inference. */
10
10
  discoverModels?(credentials: Record<string, unknown>): Promise<DiscoveredModel[]>;
11
+ /** Used when discovery is unavailable; never pick a fixed inference model for all credentials. */
12
+ readonly credentialValidation?: ProviderCredentialValidationPolicy;
11
13
  getNativeModelClient?: NativeModelClientFactory;
12
14
  /**
13
15
  * Provider metadata
@@ -1,4 +1,6 @@
1
- import { BaseLanguageModel } from "@langchain/core/language_models/base";
2
- import { ICopilotModel } from "@xpert-ai/contracts";
1
+ import { BaseLanguageModel } from '@langchain/core/language_models/base';
2
+ import { ICopilotModel } from '@xpert-ai/contracts';
3
3
  export declare function getModelContextSize(input: BaseLanguageModel | ICopilotModel): number | undefined;
4
+ /** Bind the effective window to the runtime configuration and client without guessing from model names. */
5
+ export declare function applyModelContextSize<T extends object>(model: T, configuration: ICopilotModel): T;
4
6
  export declare function normalizeContextSize(value: unknown): number | undefined;
@@ -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;
@@ -0,0 +1,2 @@
1
+ /** Internal one-shot digest. Callers bound asset sizes before allocating hashing buffers. */
2
+ export declare function sha256Hex(bytes: Uint8Array): string;
@@ -0,0 +1,35 @@
1
+ import { DiscoveryService, Reflector } from '@nestjs/core';
2
+ import type { ArtifactPresentationQuery } from '@xpert-ai/contracts';
3
+ import type { ArtifactRecord, ArtifactVersionRecord } from '../runtime/capabilities/artifacts';
4
+ import { BaseStrategyRegistry } from '../strategy';
5
+ export declare const ARTIFACT_PRESENTATION_PROVIDER = "ARTIFACT_PRESENTATION_PROVIDER";
6
+ export interface ArtifactPresentationSource {
7
+ pluginName: string;
8
+ resourceType: string;
9
+ }
10
+ export declare const artifactPresentationKey: (source: ArtifactPresentationSource) => string;
11
+ /** Registers a read-only renderer for an explicit Artifact source, independently of Workbench actions. */
12
+ export declare const ArtifactPresentationProvider: (source: ArtifactPresentationSource) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
13
+ export interface ArtifactPresentationContext {
14
+ /** Current authenticated viewer. Never substitute the Artifact creator. */
15
+ actor: {
16
+ tenantId: string;
17
+ organizationId: string;
18
+ userId: string;
19
+ };
20
+ artifact: ArtifactRecord;
21
+ version: ArtifactVersionRecord;
22
+ /** Platform-authorized, integrity-checked version bytes. This grants no Workspace file access. */
23
+ content: Buffer;
24
+ }
25
+ export interface IArtifactPresentationProvider {
26
+ readonly operations: readonly string[];
27
+ getEntry(): Promise<{
28
+ html: string;
29
+ }>;
30
+ read(context: ArtifactPresentationContext): Promise<object>;
31
+ query(context: ArtifactPresentationContext, request: ArtifactPresentationQuery): Promise<object>;
32
+ }
33
+ export declare class ArtifactPresentationRegistry extends BaseStrategyRegistry<IArtifactPresentationProvider> {
34
+ constructor(discovery: DiscoveryService, reflector: Reflector);
35
+ }
@@ -2,6 +2,7 @@ export * from './file-system';
2
2
  export * from './plugin-config';
3
3
  export * from './permissions';
4
4
  export * from './schema';
5
+ export * from './json-encoded-schema';
5
6
  export * from './i18n';
6
7
  export * from './utils';
7
8
  export * from './context/index';
@@ -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,3 @@
1
+ import type { JSONValue } from '@xpert-ai/contracts';
2
+ /** Structural feedback from the discovered provider contract. Never substitutes for provider authorization or validation. */
3
+ export declare function validateAnalyticsPayload(payload: JSONValue, schema: JSONValue): void;
@@ -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
+ }