@xpert-ai/plugin-sdk 3.19.0 → 3.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +55 -0
  3. package/RESOURCE-CARDS-VALIDATION.md +51 -0
  4. package/RESOURCE-CARDS.md +361 -0
  5. package/TOOL-IMAGES.md +85 -0
  6. package/agent-results.cjs.default.js +1 -0
  7. package/agent-results.cjs.js +20 -0
  8. package/agent-results.cjs.mjs +2 -0
  9. package/agent-results.d.ts +1 -0
  10. package/agent-results.esm.js +4 -0
  11. package/index.cjs.js +455 -107
  12. package/index.esm.js +412 -112
  13. package/model-provider.cjs.js +5 -0
  14. package/model-provider.esm.js +5 -1
  15. package/package.json +8 -2
  16. package/results.cjs.js +50 -0
  17. package/results.esm.js +46 -0
  18. package/src/agent-results.d.ts +2 -0
  19. package/src/index.d.ts +2 -0
  20. package/src/lib/agent/handoff/agent-chat.contract.d.ts +6 -1
  21. package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +319 -0
  22. package/src/lib/agent/handoff/index.d.ts +1 -0
  23. package/src/lib/agent/index.d.ts +1 -0
  24. package/src/lib/agent/middleware/index.d.ts +1 -0
  25. package/src/lib/agent/middleware/model-requirements.d.ts +9 -0
  26. package/src/lib/agent/middleware/strategy.interface.d.ts +4 -0
  27. package/src/lib/agent/middleware/types.d.ts +7 -0
  28. package/src/lib/agent/resource-card.d.ts +3 -0
  29. package/src/lib/agent/runtime/activity.d.ts +6 -0
  30. package/src/lib/agent/runtime/capability.d.ts +13 -5
  31. package/src/lib/agent/runtime/cli-model-profile.d.ts +62 -0
  32. package/src/lib/agent/runtime/dispatch.d.ts +517 -0
  33. package/src/lib/agent/runtime/execution-runner.d.ts +66 -0
  34. package/src/lib/agent/runtime/index.d.ts +7 -0
  35. package/src/lib/agent/runtime/model-execution.d.ts +15 -0
  36. package/src/lib/agent/runtime/results.d.ts +335 -0
  37. package/src/lib/agent/runtime/strategy.d.ts +3 -0
  38. package/src/lib/agent/runtime/task-wait.d.ts +35 -0
  39. package/src/lib/agent/runtime/types.d.ts +35 -11
  40. package/src/lib/ai-model/ai-model-provider.interface.d.ts +2 -0
  41. package/src/lib/ai-model/ai-model.d.ts +2 -0
  42. package/src/lib/ai-model/index.d.ts +3 -0
  43. package/src/lib/ai-model/llm.d.ts +4 -2
  44. package/src/lib/ai-model/native-model.d.ts +22 -0
  45. package/src/lib/ai-model/realtime.d.ts +36 -0
  46. package/src/lib/ai-model/token-usage.d.ts +13 -0
  47. package/src/lib/mcp/app.d.ts +4 -1
  48. package/src/lib/project-task/index.d.ts +8 -1
  49. package/src/lib/project-type/index.d.ts +8 -1
  50. package/src/lib/resource-card-provider/index.d.ts +3 -0
  51. package/src/lib/resource-card-provider/provider.decorator.d.ts +4 -0
  52. package/src/lib/resource-card-provider/provider.registry.d.ts +14 -0
  53. package/src/lib/resource-card-provider/types.d.ts +36 -0
  54. package/src/lib/resource-card.d.ts +6 -0
  55. package/src/lib/runtime/capabilities/index.d.ts +1 -0
  56. package/src/lib/runtime/capabilities/project-provisioning.d.ts +10 -0
  57. package/src/lib/runtime/capabilities/tool-images.d.ts +24 -0
  58. package/src/lib/sandbox/execution-environment.d.ts +2 -0
  59. package/src/lib/sandbox/execution.d.ts +10 -0
  60. package/src/lib/sandbox/managed-service.d.ts +1 -0
@@ -0,0 +1,335 @@
1
+ import { z } from 'zod/v3';
2
+ import { type AgentOutputDelivery } from '@xpert-ai/contracts';
3
+ /** Opt in to the host's authorized, on-demand result View from middleware metadata. */
4
+ export declare const AGENT_TASK_RESULTS_FEATURE = "agent_task_results";
5
+ export { agentResultPathSchema, agentOutputDeliverySchema, type AgentOutputDelivery } from '@xpert-ai/contracts';
6
+ /** Machine-readable result kind; file declarations are not committed artifacts or download grants. */
7
+ export declare const agentResultItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
8
+ type: z.ZodLiteral<"analysis">;
9
+ id: z.ZodString;
10
+ title: z.ZodString;
11
+ summary: z.ZodString;
12
+ }, "strict", z.ZodTypeAny, {
13
+ type?: "analysis";
14
+ id?: string;
15
+ title?: string;
16
+ summary?: string;
17
+ }, {
18
+ type?: "analysis";
19
+ id?: string;
20
+ title?: string;
21
+ summary?: string;
22
+ }>, z.ZodObject<{
23
+ type: z.ZodLiteral<"changes">;
24
+ files: z.ZodArray<z.ZodObject<{
25
+ path: z.ZodEffects<z.ZodString, string, string>;
26
+ change: z.ZodEnum<["created", "modified", "deleted"]>;
27
+ }, "strict", z.ZodTypeAny, {
28
+ path?: string;
29
+ change?: "created" | "modified" | "deleted";
30
+ }, {
31
+ path?: string;
32
+ change?: "created" | "modified" | "deleted";
33
+ }>, "many">;
34
+ id: z.ZodString;
35
+ title: z.ZodString;
36
+ summary: z.ZodString;
37
+ }, "strict", z.ZodTypeAny, {
38
+ type?: "changes";
39
+ id?: string;
40
+ title?: string;
41
+ summary?: string;
42
+ files?: {
43
+ path?: string;
44
+ change?: "created" | "modified" | "deleted";
45
+ }[];
46
+ }, {
47
+ type?: "changes";
48
+ id?: string;
49
+ title?: string;
50
+ summary?: string;
51
+ files?: {
52
+ path?: string;
53
+ change?: "created" | "modified" | "deleted";
54
+ }[];
55
+ }>, z.ZodObject<{
56
+ type: z.ZodLiteral<"tests">;
57
+ status: z.ZodEnum<["passed", "failed", "skipped"]>;
58
+ command: z.ZodOptional<z.ZodString>;
59
+ id: z.ZodString;
60
+ title: z.ZodString;
61
+ summary: z.ZodString;
62
+ }, "strict", z.ZodTypeAny, {
63
+ type?: "tests";
64
+ status?: "passed" | "failed" | "skipped";
65
+ id?: string;
66
+ title?: string;
67
+ summary?: string;
68
+ command?: string;
69
+ }, {
70
+ type?: "tests";
71
+ status?: "passed" | "failed" | "skipped";
72
+ id?: string;
73
+ title?: string;
74
+ summary?: string;
75
+ command?: string;
76
+ }>, z.ZodObject<{
77
+ type: z.ZodLiteral<"file">;
78
+ path: z.ZodEffects<z.ZodString, string, string>;
79
+ id: z.ZodString;
80
+ title: z.ZodString;
81
+ summary: z.ZodString;
82
+ }, "strict", z.ZodTypeAny, {
83
+ type?: "file";
84
+ path?: string;
85
+ id?: string;
86
+ title?: string;
87
+ summary?: string;
88
+ }, {
89
+ type?: "file";
90
+ path?: string;
91
+ id?: string;
92
+ title?: string;
93
+ summary?: string;
94
+ }>]>;
95
+ export type AgentResultItem = z.output<typeof agentResultItemSchema>;
96
+ /** Explicit final response envelope shared by adapters; ordinary prose is never classified heuristically. */
97
+ export declare const agentTaskResultSchema: z.ZodEffects<z.ZodObject<{
98
+ version: z.ZodLiteral<1>;
99
+ summary: z.ZodString;
100
+ items: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
101
+ type: z.ZodLiteral<"analysis">;
102
+ id: z.ZodString;
103
+ title: z.ZodString;
104
+ summary: z.ZodString;
105
+ }, "strict", z.ZodTypeAny, {
106
+ type?: "analysis";
107
+ id?: string;
108
+ title?: string;
109
+ summary?: string;
110
+ }, {
111
+ type?: "analysis";
112
+ id?: string;
113
+ title?: string;
114
+ summary?: string;
115
+ }>, z.ZodObject<{
116
+ type: z.ZodLiteral<"changes">;
117
+ files: z.ZodArray<z.ZodObject<{
118
+ path: z.ZodEffects<z.ZodString, string, string>;
119
+ change: z.ZodEnum<["created", "modified", "deleted"]>;
120
+ }, "strict", z.ZodTypeAny, {
121
+ path?: string;
122
+ change?: "created" | "modified" | "deleted";
123
+ }, {
124
+ path?: string;
125
+ change?: "created" | "modified" | "deleted";
126
+ }>, "many">;
127
+ id: z.ZodString;
128
+ title: z.ZodString;
129
+ summary: z.ZodString;
130
+ }, "strict", z.ZodTypeAny, {
131
+ type?: "changes";
132
+ id?: string;
133
+ title?: string;
134
+ summary?: string;
135
+ files?: {
136
+ path?: string;
137
+ change?: "created" | "modified" | "deleted";
138
+ }[];
139
+ }, {
140
+ type?: "changes";
141
+ id?: string;
142
+ title?: string;
143
+ summary?: string;
144
+ files?: {
145
+ path?: string;
146
+ change?: "created" | "modified" | "deleted";
147
+ }[];
148
+ }>, z.ZodObject<{
149
+ type: z.ZodLiteral<"tests">;
150
+ status: z.ZodEnum<["passed", "failed", "skipped"]>;
151
+ command: z.ZodOptional<z.ZodString>;
152
+ id: z.ZodString;
153
+ title: z.ZodString;
154
+ summary: z.ZodString;
155
+ }, "strict", z.ZodTypeAny, {
156
+ type?: "tests";
157
+ status?: "passed" | "failed" | "skipped";
158
+ id?: string;
159
+ title?: string;
160
+ summary?: string;
161
+ command?: string;
162
+ }, {
163
+ type?: "tests";
164
+ status?: "passed" | "failed" | "skipped";
165
+ id?: string;
166
+ title?: string;
167
+ summary?: string;
168
+ command?: string;
169
+ }>, z.ZodObject<{
170
+ type: z.ZodLiteral<"file">;
171
+ path: z.ZodEffects<z.ZodString, string, string>;
172
+ id: z.ZodString;
173
+ title: z.ZodString;
174
+ summary: z.ZodString;
175
+ }, "strict", z.ZodTypeAny, {
176
+ type?: "file";
177
+ path?: string;
178
+ id?: string;
179
+ title?: string;
180
+ summary?: string;
181
+ }, {
182
+ type?: "file";
183
+ path?: string;
184
+ id?: string;
185
+ title?: string;
186
+ summary?: string;
187
+ }>]>, "many">;
188
+ }, "strict", z.ZodTypeAny, {
189
+ summary?: string;
190
+ version?: 1;
191
+ items?: ({
192
+ type?: "analysis";
193
+ id?: string;
194
+ title?: string;
195
+ summary?: string;
196
+ } | {
197
+ type?: "changes";
198
+ id?: string;
199
+ title?: string;
200
+ summary?: string;
201
+ files?: {
202
+ path?: string;
203
+ change?: "created" | "modified" | "deleted";
204
+ }[];
205
+ } | {
206
+ type?: "tests";
207
+ status?: "passed" | "failed" | "skipped";
208
+ id?: string;
209
+ title?: string;
210
+ summary?: string;
211
+ command?: string;
212
+ } | {
213
+ type?: "file";
214
+ path?: string;
215
+ id?: string;
216
+ title?: string;
217
+ summary?: string;
218
+ })[];
219
+ }, {
220
+ summary?: string;
221
+ version?: 1;
222
+ items?: ({
223
+ type?: "analysis";
224
+ id?: string;
225
+ title?: string;
226
+ summary?: string;
227
+ } | {
228
+ type?: "changes";
229
+ id?: string;
230
+ title?: string;
231
+ summary?: string;
232
+ files?: {
233
+ path?: string;
234
+ change?: "created" | "modified" | "deleted";
235
+ }[];
236
+ } | {
237
+ type?: "tests";
238
+ status?: "passed" | "failed" | "skipped";
239
+ id?: string;
240
+ title?: string;
241
+ summary?: string;
242
+ command?: string;
243
+ } | {
244
+ type?: "file";
245
+ path?: string;
246
+ id?: string;
247
+ title?: string;
248
+ summary?: string;
249
+ })[];
250
+ }>, {
251
+ summary?: string;
252
+ version?: 1;
253
+ items?: ({
254
+ type?: "analysis";
255
+ id?: string;
256
+ title?: string;
257
+ summary?: string;
258
+ } | {
259
+ type?: "changes";
260
+ id?: string;
261
+ title?: string;
262
+ summary?: string;
263
+ files?: {
264
+ path?: string;
265
+ change?: "created" | "modified" | "deleted";
266
+ }[];
267
+ } | {
268
+ type?: "tests";
269
+ status?: "passed" | "failed" | "skipped";
270
+ id?: string;
271
+ title?: string;
272
+ summary?: string;
273
+ command?: string;
274
+ } | {
275
+ type?: "file";
276
+ path?: string;
277
+ id?: string;
278
+ title?: string;
279
+ summary?: string;
280
+ })[];
281
+ }, {
282
+ summary?: string;
283
+ version?: 1;
284
+ items?: ({
285
+ type?: "analysis";
286
+ id?: string;
287
+ title?: string;
288
+ summary?: string;
289
+ } | {
290
+ type?: "changes";
291
+ id?: string;
292
+ title?: string;
293
+ summary?: string;
294
+ files?: {
295
+ path?: string;
296
+ change?: "created" | "modified" | "deleted";
297
+ }[];
298
+ } | {
299
+ type?: "tests";
300
+ status?: "passed" | "failed" | "skipped";
301
+ id?: string;
302
+ title?: string;
303
+ summary?: string;
304
+ command?: string;
305
+ } | {
306
+ type?: "file";
307
+ path?: string;
308
+ id?: string;
309
+ title?: string;
310
+ summary?: string;
311
+ })[];
312
+ }>;
313
+ export type AgentTaskResult = z.output<typeof agentTaskResultSchema>;
314
+ /** Persist only after the platform has committed the artifact; never accept an ID invented by a model. */
315
+ export interface AgentResultArtifact {
316
+ id: string;
317
+ name?: string;
318
+ mimeType?: string;
319
+ /** Required for downloads; optional only to read older task records without changing their meaning. */
320
+ versionId?: string;
321
+ /** Item paths included in this immutable artifact. */
322
+ paths?: string[];
323
+ }
324
+ export interface AgentArtifactSelection {
325
+ mode: 'files' | 'archive';
326
+ /** Exact relative files; the runner still enforces filesystem and delivery authorization. */
327
+ paths: string[];
328
+ }
329
+ /** Export outcome is independent of task success, so an export error cannot hide completed work. */
330
+ export interface AgentOutputExport {
331
+ mode: AgentOutputDelivery['mode'];
332
+ status: 'not_requested' | 'completed' | 'failed' | 'unavailable';
333
+ /** Safe diagnostic only; execution status is independent of export status. */
334
+ error?: string;
335
+ }
@@ -1,6 +1,7 @@
1
1
  import { DiscoveryService, Reflector } from '@nestjs/core';
2
2
  import type { RuntimeCapabilityRegistry } from '../../core/runtime-capability';
3
3
  import { BaseStrategyRegistry, type StrategySource } from '../../strategy';
4
+ import type { AgentActivityRecorder } from './activity';
4
5
  import type { AgentInvocationInput, AgentInvocationScope, AgentJson, AgentRuntimeCapabilities, AgentRuntimeHandle, AgentRuntimeObservation, AgentTarget } from './types';
5
6
  /** Trusted per-operation host context, independent of graph and provider transport details. */
6
7
  export interface AgentRuntimeContext {
@@ -10,6 +11,8 @@ export interface AgentRuntimeContext {
10
11
  /** Cooperative cancellation; abort alone does not confirm remote termination. */
11
12
  signal?: AbortSignal;
12
13
  capabilities: RuntimeCapabilityRegistry;
14
+ /** Available only for declared public activity; scoped by the host to this invocation. */
15
+ activity?: AgentActivityRecorder;
13
16
  /** Persist a receipt before waiting on long-running work. Await persistence and propagate failures. */
14
17
  checkpoint(observation: AgentRuntimeObservation): Promise<void>;
15
18
  }
@@ -0,0 +1,35 @@
1
+ /** Provider-neutral dependency waiting. A wait ending does not terminate its tasks. */
2
+ export type TaskWaitMode = 'any' | 'all';
3
+ /** `completed` means terminal, not necessarily successful. `timeout` is a historical durable-wait deadline. */
4
+ export type TaskWaitReason = 'completed' | 'pending' | 'attention' | 'timeout' | 'unavailable';
5
+ export interface TaskWaitRequest {
6
+ /** Stable tool-call identity, assigned by the host rather than the model. */
7
+ callId: string;
8
+ /** Distinct handles owned by the caller; the invocation adapter accepts at most 32. */
9
+ taskIds: string[];
10
+ /** Whether one terminal task or all terminal tasks satisfy this wait. */
11
+ mode: TaskWaitMode;
12
+ /** Requested observation window, bounded by host policy; expiry returns pending, not an interrupt. */
13
+ timeoutMs?: number;
14
+ }
15
+ export interface TaskWaitResult<T> {
16
+ reason: TaskWaitReason;
17
+ /** Latest observed states, including unfinished tasks when mode is `any`. */
18
+ tasks: T[];
19
+ }
20
+ /** Host policy caps the requested observation window. */
21
+ export interface TaskWaitPolicy {
22
+ /** Default initial observation window, in milliseconds. */
23
+ inlineWaitMs: number;
24
+ /** Maximum duration of a single observation call, in milliseconds. */
25
+ maxInlineWaitMs: number;
26
+ /** Interval between backend reads; each read must bound its own I/O. */
27
+ pollIntervalMs: number;
28
+ /** Historical persisted wait deadline, independent of a new status-call duration. */
29
+ maxWaitMs: number;
30
+ /** Historical grace period before an ambiguous outcome is reported unavailable. */
31
+ unknownGraceMs: number;
32
+ }
33
+ /** Domain adapters map their explicit states into these dependency states. */
34
+ export type TaskDependencyState = 'pending' | 'completed' | 'attention' | 'unknown';
35
+ export declare function taskWaitReason(states: readonly TaskDependencyState[], mode: TaskWaitMode): TaskWaitReason | undefined;
@@ -1,3 +1,8 @@
1
+ import type { AgentInvocationStatus, AgentRuntimeProgress, ModelExecutionEnvironment, ExecutionActivityCapabilities } from '@xpert-ai/contracts';
2
+ export type { AgentInvocationStatus, AgentRuntimeProgress } from '@xpert-ai/contracts';
3
+ import type { AgentInvocationDispatchContext } from './dispatch';
4
+ import type { AgentRunnerReceipt } from './execution-runner';
5
+ import type { AgentOutputDelivery, AgentOutputExport, AgentResultArtifact, AgentResultItem } from './results';
1
6
  /** Serializable invocation data. Use finite numbers and plain objects; exclude credentials. */
2
7
  export type AgentJson = null | boolean | number | string | AgentJson[] | {
3
8
  [key: string]: AgentJson;
@@ -15,6 +20,8 @@ export interface AgentInvocationScope {
15
20
  parentExecutionId: string;
16
21
  /** Calling Agent key or host-assigned background-task entry. */
17
22
  callerAgentKey: string;
23
+ /** Omitted preserves existing Assistant callers. Project general agents have no fabricated Assistant ID. */
24
+ callerType?: 'xpert' | 'project_agent';
18
25
  callerXpertId?: string;
19
26
  }
20
27
  /** Authorized, version-pinned target. Pass the resolved snapshot unchanged. */
@@ -34,6 +41,13 @@ export interface AgentTarget {
34
41
  }
35
42
  /** Provider support flags; they do not grant caller permissions. */
36
43
  export interface AgentRuntimeCapabilities {
44
+ activity?: ExecutionActivityCapabilities;
45
+ /** Explicit adapter compatibility; does not install tools or grant model/environment access. */
46
+ executionTools?: Array<{
47
+ id: string;
48
+ versions: string[];
49
+ environments: ModelExecutionEnvironment['type'][];
50
+ }>;
37
51
  /**
38
52
  * Recovery by host checkpoint, existing provider session, or none.
39
53
  * Session recovery does not guarantee survival of a worker crash.
@@ -44,16 +58,16 @@ export interface AgentRuntimeCapabilities {
44
58
  cancellation: boolean;
45
59
  /** Work can continue after start() returns. */
46
60
  background: boolean;
61
+ /** Omitted means unsupported. This declaration alone does not enable a host message API. */
62
+ runningMessages?: boolean;
63
+ /** A new invocation may reuse a prior session only through an explicitly supported adapter path. */
64
+ sessionContinuation?: boolean;
47
65
  }
48
- /**
49
- * Only succeeded, failed and cancelled are terminal.
50
- * waiting requires continuation; cancelling awaits confirmation.
51
- * unknown means the outcome is uncertain: reconcile before launching new work.
52
- */
53
- export type AgentInvocationStatus = 'queued' | 'running' | 'waiting' | 'cancelling' | 'succeeded' | 'failed' | 'cancelled' | 'unknown';
54
66
  /** Provider-neutral task payload; supported structured fields depend on the adapter. */
55
67
  export interface AgentInvocationInput {
56
68
  prompt: string;
69
+ /** No export by default; files/archive require an explicit delivery request. */
70
+ delivery?: AgentOutputDelivery;
57
71
  parameters?: {
58
72
  [key: string]: AgentJson;
59
73
  };
@@ -69,17 +83,19 @@ export interface AgentInvocationInput {
69
83
  /** Output or in-progress receipt. Check invocation status before treating it as final. */
70
84
  export interface AgentInvocationResult {
71
85
  text: string;
86
+ /** Explicit adapter-normalized findings; display kind is never inferred from prose or titles. */
87
+ items?: AgentResultItem[];
88
+ /** Separate delivery outcome; task success does not imply that files were exported. */
89
+ export?: AgentOutputExport;
72
90
  /** Adapter-defined structured output. */
73
91
  data?: AgentJson;
74
92
  /** Host-managed output references; normal artifact authorization applies. */
75
- artifacts?: Array<{
76
- id: string;
77
- name?: string;
78
- mimeType?: string;
79
- }>;
93
+ artifacts?: AgentResultArtifact[];
80
94
  }
81
95
  /** Persisted provider receipt. Session/run IDs are distinct from the host invocation ID. */
82
96
  export interface AgentRuntimeHandle {
97
+ /** Optional host-managed process receipt; direct remote runtimes need only their session/run IDs. */
98
+ runner?: AgentRunnerReceipt;
83
99
  sessionId: string;
84
100
  runId: string;
85
101
  metadata?: {
@@ -103,6 +119,8 @@ export interface AgentRuntimeObservation {
103
119
  handle?: AgentRuntimeHandle;
104
120
  result?: AgentInvocationResult;
105
121
  interaction?: AgentInteraction;
122
+ /** Reported work/activity only; it never confirms business acceptance. */
123
+ progress?: AgentRuntimeProgress;
106
124
  /** Safe diagnostic message without credentials or raw provider payloads. */
107
125
  error?: string;
108
126
  }
@@ -115,9 +133,15 @@ export interface AgentInvocationRequest {
115
133
  */
116
134
  callId: string;
117
135
  input: AgentInvocationInput;
136
+ /** Optional host-owned asynchronous reply and project association; not supplied by the execution Agent. */
137
+ dispatch?: AgentInvocationDispatchContext;
118
138
  }
119
139
  /** Host-owned invocation snapshot; not an update DTO. */
120
140
  export interface AgentInvocation extends AgentRuntimeObservation {
141
+ /** Pinned presentation contract remains readable after the runtime plugin is removed. */
142
+ activity?: ExecutionActivityCapabilities;
143
+ /** Host startup fence; intermediate receipts are not inspected until start returns or this deadline expires. */
144
+ startPendingUntil?: string;
121
145
  /** Host invocation ID used by inspect, cancel and respond. */
122
146
  id: string;
123
147
  /** Host-managed concurrency revision, distinct from the target version. */
@@ -4,7 +4,9 @@ import { Embeddings } from '@langchain/core/embeddings';
4
4
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
5
5
  import { AIGCModelClient, AsyncAIGCModelClient, IRerank } from './types';
6
6
  import { AIModel } from './ai-model';
7
+ import type { NativeModelClientFactory } from './native-model';
7
8
  export interface IAIModelProviderStrategy {
9
+ getNativeModelClient?: NativeModelClientFactory;
8
10
  /**
9
11
  * Provider metadata
10
12
  */
@@ -1,4 +1,5 @@
1
1
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
2
+ import type { RealtimeModelConnection } from './realtime';
2
3
  import { AIModelEntity, AiModelTypeEnum, ICopilotModel, ModelUsagePricingContext, ModelUsagePricingSnapshot, ParameterRule, PriceInfo, PriceType } from '@xpert-ai/contracts';
3
4
  import { Logger } from '@nestjs/common';
4
5
  import { ModelProvider } from './abstract-provider';
@@ -13,6 +14,7 @@ export declare abstract class AIModel implements IAIModel {
13
14
  private positions;
14
15
  constructor(modelProvider: ModelProvider, modelType: AiModelTypeEnum);
15
16
  abstract validateCredentials(model: string, credentials: Record<string, any>): Promise<void>;
17
+ getRealtimeModel(_copilotModel: ICopilotModel): RealtimeModelConnection;
16
18
  getChatModel(copilotModel: ICopilotModel, options?: TChatModelOptions): BaseChatModel;
17
19
  getAIGCModel(copilotModel: ICopilotModel, options?: TChatModelOptions): AIGCModelClient | AsyncAIGCModelClient;
18
20
  getPrice(model: string, credentials: Record<string, any>, priceType: PriceType, tokens: number, inputTokens?: number): PriceInfo;
@@ -12,3 +12,6 @@ export * from './openai-compatible';
12
12
  export * from './model-provider-http-client';
13
13
  export * from './utils/index';
14
14
  export * from './commands/index';
15
+ export * from './token-usage';
16
+ export * from './native-model';
17
+ export * from './realtime';
@@ -40,6 +40,8 @@ export declare abstract class LargeLanguageModel extends AIModel {
40
40
  #private;
41
41
  protected startedAt: DOMHighResTimeStamp;
42
42
  protected _commonParameterRules(model: string): ParameterRule[];
43
+ /** Price already normalized provider facts without starting another inference or writing a ledger. */
44
+ priceActualTokenUsage(model: string, tokenUsage: TTokenUsage, context?: LLMPriceContext): ILLMUsage;
43
45
  protected calcResponseUsage(model: string, credentials: Record<string, any>, promptTokens: number, completionTokens: number, startedAt?: number, tokenUsage?: TTokenUsage, pricingContext?: LLMPriceContext): ILLMUsage;
44
46
  createHandleUsageCallbacks(copilot: ICopilot, model: string, credentials: any, handleLLMTokens: TChatModelOptions['handleLLMTokens'], pricingConfiguration?: LLMUsagePricingConfiguration): {
45
47
  name: string;
@@ -90,8 +92,8 @@ export declare abstract class LargeLanguageModel extends AIModel {
90
92
  handleRetrieverError?(err: any, runId: string, parentRunId?: string, tags?: string[]): Promise<any> | any;
91
93
  handleCustomEvent?(eventName: string, data: any, runId: string, tags?: string[], metadata?: Record<string, any>): Promise<any> | any;
92
94
  }[];
93
- createHandleLLMErrorCallbacks(fields: any, logger?: Logger): {
94
- handleLLMError: (err: any) => void;
95
+ createHandleLLMErrorCallbacks(_fields: unknown, logger?: Logger): {
96
+ handleLLMError: (error: unknown) => void;
95
97
  };
96
98
  protected getCustomizableModelSchemaFromCredentials(model: string, credentials: Record<string, any>): AIModelEntity | null;
97
99
  protected createHandleVerboseCallbacks(enabled?: boolean, logger?: Logger): {
@@ -0,0 +1,22 @@
1
+ import type { ICopilotModel, ILLMUsage, LLMPriceContext, ModelExecutionProtocol, TTokenUsage } from '@xpert-ai/contracts';
2
+ export type NativeModelProtocol = Extract<ModelExecutionProtocol, 'openai_responses' | 'anthropic_messages'>;
3
+ export type NativeModelJson = null | boolean | number | string | NativeModelJson[] | {
4
+ [key: string]: NativeModelJson;
5
+ };
6
+ export type NativeModelBody = {
7
+ [key: string]: NativeModelJson;
8
+ };
9
+ /** Server-only capability. Provider credentials and configured upstream URLs never leave this closure. */
10
+ export interface NativeModelClient {
11
+ readonly protocol: NativeModelProtocol;
12
+ generate(body: NativeModelBody, headers: Readonly<Record<string, string>>, signal: AbortSignal): Promise<Response>;
13
+ priceUsage(usage: TTokenUsage, context?: LLMPriceContext): ILLMUsage;
14
+ }
15
+ export type NativeModelClientFactory = (protocol: NativeModelProtocol, model: ICopilotModel) => Promise<NativeModelClient>;
16
+ /** A single fetch is one billable attempt. No SDK retries or redirects to another credential origin. */
17
+ export declare function nativeModelTransport(input: {
18
+ protocol: NativeModelProtocol;
19
+ baseUrl: string;
20
+ authorization: string;
21
+ fetch?: typeof fetch;
22
+ }): NativeModelClient['generate'];
@@ -0,0 +1,36 @@
1
+ import type { RealtimeModelEvent, RealtimeToolResult, RealtimeTaskContext } from '@xpert-ai/contracts';
2
+ import type { JSONSchema7 } from 'json-schema';
3
+ export interface RealtimeSessionOptions {
4
+ voice: string;
5
+ instructions: string;
6
+ tools: {
7
+ name: string;
8
+ description: string;
9
+ parameters: JSONSchema7;
10
+ }[];
11
+ }
12
+ /** The host owns networking, credentials, backpressure and authorization. */
13
+ export interface RealtimeProtocolSink {
14
+ send(event: object): void;
15
+ emit(event: RealtimeModelEvent): void;
16
+ }
17
+ export interface RealtimeProtocol {
18
+ start(): void;
19
+ receive(event: unknown): void;
20
+ appendAudio(audio: Uint8Array): void;
21
+ setMuted(muted: boolean): void;
22
+ cancelResponse(): void;
23
+ submitToolResults(results: RealtimeToolResult[]): void;
24
+ /** Synchronize task facts without requesting speech or emitting a user transcript. */
25
+ updateTaskContext?(tasks: RealtimeTaskContext[]): void;
26
+ notify(text: string): boolean;
27
+ close(): void;
28
+ }
29
+ /** Server-only connection descriptor. Never serialize this object to clients. */
30
+ export interface RealtimeModelConnection {
31
+ url: string;
32
+ headers: {
33
+ [header: string]: string;
34
+ };
35
+ createProtocol(options: RealtimeSessionOptions, sink: RealtimeProtocolSink): RealtimeProtocol;
36
+ }
@@ -0,0 +1,13 @@
1
+ import type { TTokenUsage } from '@xpert-ai/contracts';
2
+ export interface ResolvedTokenUsage {
3
+ usage: TTokenUsage;
4
+ source: 'provider' | 'estimated' | 'legacy' | 'unavailable';
5
+ }
6
+ /** Select a whole candidate. Never fill missing actual counts using estimates. */
7
+ export declare function resolveTokenUsageCandidates(input: {
8
+ canonical?: Partial<TTokenUsage> | null;
9
+ actual?: Partial<TTokenUsage> | null;
10
+ estimated?: Partial<TTokenUsage> | null;
11
+ legacyTotal?: number;
12
+ }): ResolvedTokenUsage;
13
+ export declare function normalizeTokenUsage(candidate?: Partial<TTokenUsage> | null): TTokenUsage | null;
@@ -1,3 +1,4 @@
1
+ import type { I18nObject, TMcpAppRefresh } from '@xpert-ai/contracts';
1
2
  export interface McpAppCsp {
2
3
  connectDomains?: string[];
3
4
  resourceDomains?: string[];
@@ -11,8 +12,10 @@ export interface McpAppPermissions {
11
12
  export interface McpAppDefinition {
12
13
  key: string;
13
14
  entry: string;
14
- title?: string;
15
+ title?: string | I18nObject;
15
16
  description?: string;
17
+ /** Read-only tool called by the host Refresh action; never replays the entry tool. */
18
+ refresh?: TMcpAppRefresh;
16
19
  csp?: McpAppCsp;
17
20
  permissions?: McpAppPermissions;
18
21
  }
@@ -1,5 +1,5 @@
1
1
  import { DiscoveryService, Reflector } from '@nestjs/core';
2
- import type { ProjectTaskGraph, ProjectTaskGraphChange, ProjectTaskExecutionTarget, TXpertProjectTaskStatus } from '@xpert-ai/contracts';
2
+ import type { ProjectTaskGraph, ProjectTaskGraphChange, ProjectTaskExecutionTarget, ProjectTaskTypeDefinition, TXpertProjectTaskStatus } from '@xpert-ai/contracts';
3
3
  import { BaseStrategyRegistry } from '../strategy';
4
4
  import type { ProjectAccessActor } from '../runtime/capabilities/project-access';
5
5
  export interface ProjectTaskContext {
@@ -10,7 +10,11 @@ export interface ProjectTaskProjection {
10
10
  key: string;
11
11
  title: string;
12
12
  status: TXpertProjectTaskStatus;
13
+ /** Completion percentage (0–100), independent of status. Omit to preserve; null clears it. */
14
+ progress?: number | null;
13
15
  kind: 'task' | 'summary' | 'milestone';
16
+ /** Registered business type; omitted values preserve legacy persisted types. Null explicitly clears it. */
17
+ taskType?: string | null;
14
18
  parentKey?: string;
15
19
  predecessorKeys: string[];
16
20
  diagnostic?: string;
@@ -37,6 +41,8 @@ export interface ProjectTaskSnapshot {
37
41
  }
38
42
  export interface IProjectTaskProvider {
39
43
  readonly key: string;
44
+ /** Presentation declarations belong to this provider and never contain executable icon code. */
45
+ readonly taskTypes?: readonly ProjectTaskTypeDefinition[];
40
46
  /** Return null when the project is not owned by this provider. Always scope domain reads. */
41
47
  snapshot(context: ProjectTaskContext): Promise<ProjectTaskSnapshot | null>;
42
48
  /** Called after projection commits; retries must be idempotent. Never start work here. */
@@ -45,6 +51,7 @@ export interface IProjectTaskProvider {
45
51
  taskId: string;
46
52
  }>): Promise<void>;
47
53
  }
54
+ export type { ProjectTaskIconName, ProjectTaskTypeDefinition, ProjectTaskTypePresentation } from '@xpert-ai/contracts';
48
55
  export declare const PROJECT_TASK_PROVIDER = "PROJECT_TASK_PROVIDER";
49
56
  export declare const ProjectTaskProvider: (key: string) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
50
57
  export declare class ProjectTaskProviderRegistry extends BaseStrategyRegistry<IProjectTaskProvider> {