@xpert-ai/plugin-sdk 3.18.7 → 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 (80) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/MIDDLEWARE_APPS.md +71 -0
  3. package/README.md +57 -0
  4. package/RESOURCE-CARDS-VALIDATION.md +51 -0
  5. package/RESOURCE-CARDS.md +361 -0
  6. package/TOOL-IMAGES.md +85 -0
  7. package/agent-results.cjs.default.js +1 -0
  8. package/agent-results.cjs.js +20 -0
  9. package/agent-results.cjs.mjs +2 -0
  10. package/agent-results.d.ts +1 -0
  11. package/agent-results.esm.js +4 -0
  12. package/index.cjs.js +586 -162
  13. package/index.esm.js +530 -167
  14. package/model-provider.cjs.js +5 -0
  15. package/model-provider.esm.js +5 -1
  16. package/package.json +8 -2
  17. package/results.cjs.js +50 -0
  18. package/results.esm.js +46 -0
  19. package/runtime-capabilities.md +35 -0
  20. package/src/agent-results.d.ts +2 -0
  21. package/src/index.d.ts +5 -0
  22. package/src/lib/agent/handoff/agent-chat.contract.d.ts +6 -1
  23. package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +319 -0
  24. package/src/lib/agent/handoff/index.d.ts +1 -0
  25. package/src/lib/agent/index.d.ts +2 -0
  26. package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +55 -20
  27. package/src/lib/agent/middleware/index.d.ts +1 -0
  28. package/src/lib/agent/middleware/model-requirements.d.ts +9 -0
  29. package/src/lib/agent/middleware/strategy.interface.d.ts +4 -0
  30. package/src/lib/agent/middleware/types.d.ts +20 -3
  31. package/src/lib/agent/resource-card.d.ts +3 -0
  32. package/src/lib/agent/runtime/activity.d.ts +6 -0
  33. package/src/lib/agent/runtime/capability.d.ts +37 -0
  34. package/src/lib/agent/runtime/cli-model-profile.d.ts +62 -0
  35. package/src/lib/agent/runtime/dispatch.d.ts +517 -0
  36. package/src/lib/agent/runtime/execution-runner.d.ts +66 -0
  37. package/src/lib/agent/runtime/index.d.ts +10 -0
  38. package/src/lib/agent/runtime/model-execution.d.ts +15 -0
  39. package/src/lib/agent/runtime/results.d.ts +335 -0
  40. package/src/lib/agent/runtime/strategy.d.ts +53 -0
  41. package/src/lib/agent/runtime/task-wait.d.ts +35 -0
  42. package/src/lib/agent/runtime/types.d.ts +156 -0
  43. package/src/lib/ai-model/ai-model-provider.interface.d.ts +2 -0
  44. package/src/lib/ai-model/ai-model.d.ts +2 -0
  45. package/src/lib/ai-model/index.d.ts +3 -0
  46. package/src/lib/ai-model/llm.d.ts +4 -2
  47. package/src/lib/ai-model/native-model.d.ts +22 -0
  48. package/src/lib/ai-model/realtime.d.ts +36 -0
  49. package/src/lib/ai-model/token-usage.d.ts +13 -0
  50. package/src/lib/assistant-capability/index.d.ts +42 -0
  51. package/src/lib/connector/runtime-capability.d.ts +2 -0
  52. package/src/lib/connector/strategy.interface.d.ts +8 -0
  53. package/src/lib/core/context/request-context.d.ts +6 -0
  54. package/src/lib/core/strategy-bus.d.ts +0 -3
  55. package/src/lib/evolution/runtime-capability.d.ts +2 -1
  56. package/src/lib/integration/strategy.interface.d.ts +22 -0
  57. package/src/lib/mcp/app.d.ts +14 -1
  58. package/src/lib/project-task/index.d.ts +66 -0
  59. package/src/lib/project-type/index.d.ts +71 -0
  60. package/src/lib/resource-card-provider/index.d.ts +3 -0
  61. package/src/lib/resource-card-provider/provider.decorator.d.ts +4 -0
  62. package/src/lib/resource-card-provider/provider.registry.d.ts +14 -0
  63. package/src/lib/resource-card-provider/types.d.ts +36 -0
  64. package/src/lib/resource-card.d.ts +6 -0
  65. package/src/lib/runtime/capabilities/index.d.ts +1 -0
  66. package/src/lib/runtime/capabilities/knowledge-graph.d.ts +59 -0
  67. package/src/lib/runtime/capabilities/knowledgebase-documents.d.ts +21 -0
  68. package/src/lib/runtime/capabilities/knowledgebase.d.ts +8 -3
  69. package/src/lib/runtime/capabilities/project-access.d.ts +2 -1
  70. package/src/lib/runtime/capabilities/project-provisioning.d.ts +13 -0
  71. package/src/lib/runtime/capabilities/tool-images.d.ts +24 -0
  72. package/src/lib/runtime/runtime-scope.d.ts +7 -1
  73. package/src/lib/sandbox/execution-environment.d.ts +12 -0
  74. package/src/lib/sandbox/execution.d.ts +13 -0
  75. package/src/lib/sandbox/index.d.ts +1 -0
  76. package/src/lib/sandbox/managed-service.d.ts +1 -0
  77. package/src/lib/sandbox/protocol.d.ts +2 -0
  78. package/src/lib/tool-provider/types.d.ts +6 -0
  79. package/src/lib/types.d.ts +2 -1
  80. package/src/lib/workflow/trigger/strategy.interface.d.ts +2 -1
@@ -272,6 +272,10 @@ const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project
272
272
  description: 'Resolve human Project membership for platform and plugin operations.'
273
273
  });
274
274
 
275
+ const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-images', {
276
+ description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
277
+ });
278
+
275
279
  /**
276
280
  * Shared host-runtime plumbing for built-in tools backed by a configured model provider.
277
281
  * Provider request/response semantics remain owned by each plugin.
@@ -408,6 +412,7 @@ exports.SANDBOX_JOB_ERROR_CODES = SANDBOX_JOB_ERROR_CODES;
408
412
  exports.SANDBOX_JOB_PROGRESS_PREFIX = SANDBOX_JOB_PROGRESS_PREFIX;
409
413
  exports.SandboxJobRuntimeError = SandboxJobRuntimeError;
410
414
  exports.SandboxJobsRuntimeCapability = SandboxJobsRuntimeCapability;
415
+ exports.ToolImagesRuntimeCapability = ToolImagesRuntimeCapability;
411
416
  exports.WORKSPACE_FILES_SOURCE = WORKSPACE_FILES_SOURCE;
412
417
  exports.WorkspaceFilesRuntimeCapability = WorkspaceFilesRuntimeCapability;
413
418
  exports.XPERT_RUNTIME_CAPABILITIES_TOKEN = XPERT_RUNTIME_CAPABILITIES_TOKEN;
@@ -270,6 +270,10 @@ const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project
270
270
  description: 'Resolve human Project membership for platform and plugin operations.'
271
271
  });
272
272
 
273
+ const ToolImagesRuntimeCapability = createRuntimeCapability('platform.tool-images', {
274
+ description: 'Save scoped immutable tool images and materialize verified pixels for one model request.'
275
+ });
276
+
273
277
  /**
274
278
  * Shared host-runtime plumbing for built-in tools backed by a configured model provider.
275
279
  * Provider request/response semantics remain owned by each plugin.
@@ -384,4 +388,4 @@ function normalizeWorkspaceScope(scope) {
384
388
  } : {});
385
389
  }
386
390
 
387
- export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, KnowledgeDocumentVisualAssetsRuntimeCapability as K, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability as P, RUNTIME_CAPABILITY_PROVIDER as R, SANDBOX_JOB_ERROR_CODES as S, WorkspaceFilesRuntimeCapability as W, XPERT_RUNTIME_CAPABILITIES_TOKEN as X, ActorTokenRuntimeFactoryCapability as a, ArtifactsRuntimeCapability as b, createRuntimeCapability as c, BaseTool as d, BaseToolset as e, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability as f, KnowledgeGraphRuntimeCapability as g, KnowledgebaseDocumentsRuntimeCapability as h, KnowledgebaseProvisioningRuntimeCapability as i, KnowledgebaseRuntimeCapability as j, ProjectProvisioningRuntimeCapability as k, RuntimeCapabilityProvider as l, SANDBOX_JOB_PROGRESS_PREFIX as m, SandboxJobRuntimeError as n, SandboxJobsRuntimeCapability as o, WORKSPACE_FILES_SOURCE as p, isSandboxJobRuntimeError as q };
391
+ export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, KnowledgeDocumentVisualAssetsRuntimeCapability as K, 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, ArtifactsRuntimeCapability as b, createRuntimeCapability as c, BaseTool as d, BaseToolset as e, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability as f, KnowledgeGraphRuntimeCapability as g, KnowledgebaseDocumentsRuntimeCapability as h, KnowledgebaseProvisioningRuntimeCapability as i, KnowledgebaseRuntimeCapability as j, ProjectProvisioningRuntimeCapability as k, RuntimeCapabilityProvider as l, SANDBOX_JOB_PROGRESS_PREFIX as m, SandboxJobRuntimeError as n, SandboxJobsRuntimeCapability as o, WORKSPACE_FILES_SOURCE as p, isSandboxJobRuntimeError as q };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.18.7",
3
+ "version": "3.20.0",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,6 +19,12 @@
19
19
  "import": "./index.cjs.mjs",
20
20
  "default": "./index.cjs.js"
21
21
  },
22
+ "./agent-results": {
23
+ "module": "./agent-results.esm.js",
24
+ "types": "./agent-results.d.ts",
25
+ "import": "./agent-results.cjs.mjs",
26
+ "default": "./agent-results.cjs.js"
27
+ },
22
28
  "./data-workbench": {
23
29
  "module": "./data-workbench.esm.js",
24
30
  "types": "./data-workbench.d.ts",
@@ -56,7 +62,7 @@
56
62
  },
57
63
  "dependencies": {
58
64
  "@langchain/openai": "0.6.9",
59
- "@xpert-ai/contracts": "3.18.6",
65
+ "@xpert-ai/contracts": "3.20.0",
60
66
  "express": "^4.22.1",
61
67
  "js-tiktoken": "^1.0.21"
62
68
  },
package/results.cjs.js ADDED
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ var _extends = require('./_extends.cjs.js');
4
+ var v3 = require('zod/v3');
5
+ var contracts = require('@xpert-ai/contracts');
6
+
7
+ /** Opt in to the host's authorized, on-demand result View from middleware metadata. */ const AGENT_TASK_RESULTS_FEATURE = 'agent_task_results';
8
+ const common = {
9
+ id: v3.z.string().regex(/^[a-zA-Z0-9_-]{1,80}$/),
10
+ title: v3.z.string().min(1).max(200),
11
+ summary: v3.z.string().max(16000)
12
+ };
13
+ /** Machine-readable result kind; file declarations are not committed artifacts or download grants. */ const agentResultItemSchema = v3.z.discriminatedUnion('type', [
14
+ v3.z.object(_extends._extends({}, common, {
15
+ type: v3.z.literal('analysis')
16
+ })).strict(),
17
+ v3.z.object(_extends._extends({}, common, {
18
+ type: v3.z.literal('changes'),
19
+ files: v3.z.array(v3.z.object({
20
+ path: contracts.agentResultPathSchema,
21
+ change: v3.z.enum([
22
+ 'created',
23
+ 'modified',
24
+ 'deleted'
25
+ ])
26
+ }).strict()).max(128)
27
+ })).strict(),
28
+ v3.z.object(_extends._extends({}, common, {
29
+ type: v3.z.literal('tests'),
30
+ status: v3.z.enum([
31
+ 'passed',
32
+ 'failed',
33
+ 'skipped'
34
+ ]),
35
+ command: v3.z.string().max(2000).optional()
36
+ })).strict(),
37
+ v3.z.object(_extends._extends({}, common, {
38
+ type: v3.z.literal('file'),
39
+ path: contracts.agentResultPathSchema
40
+ })).strict()
41
+ ]);
42
+ /** Explicit final response envelope shared by adapters; ordinary prose is never classified heuristically. */ const agentTaskResultSchema = v3.z.object({
43
+ version: v3.z.literal(1),
44
+ summary: v3.z.string().max(64000),
45
+ items: v3.z.array(agentResultItemSchema).max(32)
46
+ }).strict().refine((value)=>new Set(value.items.map((item)=>item.id)).size === value.items.length, 'Result item IDs must be unique');
47
+
48
+ exports.AGENT_TASK_RESULTS_FEATURE = AGENT_TASK_RESULTS_FEATURE;
49
+ exports.agentResultItemSchema = agentResultItemSchema;
50
+ exports.agentTaskResultSchema = agentTaskResultSchema;
package/results.esm.js ADDED
@@ -0,0 +1,46 @@
1
+ import { _ as _extends } from './_extends.esm.js';
2
+ import { z } from 'zod/v3';
3
+ import { agentResultPathSchema } from '@xpert-ai/contracts';
4
+
5
+ /** Opt in to the host's authorized, on-demand result View from middleware metadata. */ const AGENT_TASK_RESULTS_FEATURE = 'agent_task_results';
6
+ const common = {
7
+ id: z.string().regex(/^[a-zA-Z0-9_-]{1,80}$/),
8
+ title: z.string().min(1).max(200),
9
+ summary: z.string().max(16000)
10
+ };
11
+ /** Machine-readable result kind; file declarations are not committed artifacts or download grants. */ const agentResultItemSchema = z.discriminatedUnion('type', [
12
+ z.object(_extends({}, common, {
13
+ type: z.literal('analysis')
14
+ })).strict(),
15
+ z.object(_extends({}, common, {
16
+ type: z.literal('changes'),
17
+ files: z.array(z.object({
18
+ path: agentResultPathSchema,
19
+ change: z.enum([
20
+ 'created',
21
+ 'modified',
22
+ 'deleted'
23
+ ])
24
+ }).strict()).max(128)
25
+ })).strict(),
26
+ z.object(_extends({}, common, {
27
+ type: z.literal('tests'),
28
+ status: z.enum([
29
+ 'passed',
30
+ 'failed',
31
+ 'skipped'
32
+ ]),
33
+ command: z.string().max(2000).optional()
34
+ })).strict(),
35
+ z.object(_extends({}, common, {
36
+ type: z.literal('file'),
37
+ path: agentResultPathSchema
38
+ })).strict()
39
+ ]);
40
+ /** Explicit final response envelope shared by adapters; ordinary prose is never classified heuristically. */ const agentTaskResultSchema = z.object({
41
+ version: z.literal(1),
42
+ summary: z.string().max(64000),
43
+ items: z.array(agentResultItemSchema).max(32)
44
+ }).strict().refine((value)=>new Set(value.items.map((item)=>item.id)).size === value.items.length, 'Result item IDs must be unique');
45
+
46
+ export { AGENT_TASK_RESULTS_FEATURE as A, agentResultItemSchema as a, agentTaskResultSchema as b };
@@ -47,3 +47,38 @@ Reuse the returned API during that one operation. Create a new API for the next
47
47
  The Agent facade resolves the platform factories when initializing a scoped runtime and registers the resulting operation APIs in that runtime's child registry. This does not change the model-visible tool list inside a tool-call loop.
48
48
 
49
49
  Some child Agent identities are assigned after graph construction. Visual-assets factories accept an optional host-owned `resolveExecutionScope` callback for this case. The Agent integration supplies the LangGraph resolver; the domain factory has no LangGraph dependency. Platform callers that omit the callback use the fixed scope captured at API creation. Every image issuance and consumption still verifies the execution binding.
50
+
51
+ ## Agent invocation
52
+
53
+ Agent runtime extension contracts live under `src/lib/agent/runtime` and are
54
+ exported from `@xpert-ai/plugin-sdk`. `AgentRuntimeFactory`, strategies and the
55
+ registry describe the execution mechanism; `AgentInvocation*` types describe an
56
+ individual call. Renaming the factory does not change capability identifiers.
57
+
58
+ `AgentInvocationRuntimeCapability` is the scoped consumer API for invoking an
59
+ approved Agent binding. Resolve the binding immediately before starting a call;
60
+ provide the host tool-call/operation ID for idempotency. The API captures identity
61
+ and rechecks workspace grants, target revision and provider provenance. Tools
62
+ cannot supply user/organization identity or arbitrary runner configuration.
63
+
64
+ ```ts
65
+ const api = context.runtime.capabilities.require(AgentInvocationRuntimeCapability)
66
+ const target = await api.resolve(bindingId)
67
+ const invocation = await api.start({ target, callId: toolCallId, input: { prompt } })
68
+ // wait mode uses the host checkpoint adapter; background mode returns the ID.
69
+ const completed = await api.awaitResult(invocation.id)
70
+ ```
71
+
72
+ `inspect`, `cancel` and `respond` operate on the same invocation. A cancelling or
73
+ unknown state is not proof of termination. Caller jobs may use
74
+ `AgentRuntimeFactoryCapability` with a host-authorized identity;
75
+ never accept that identity from model arguments.
76
+
77
+ Providers implement `IAgentRuntimeStrategy` and use `@AgentRuntimeStrategy(key)`.
78
+ Persist a receipt with `context.checkpoint` before waiting for external work.
79
+ Declare checkpoint/session/no recovery accurately; reattachment must not send an
80
+ ambiguous prompt again. The strategy contract contains no graph types. The host
81
+ owns binding authorization, persistence, idempotency, waiting and audit history.
82
+ The native Xpert graph and native background Task transports are separate
83
+ strategies behind that same boundary. Providers must not call the Task facade
84
+ back from their own executor.
@@ -0,0 +1,2 @@
1
+ /** Browser-safe result contracts. Keep this entry independent of the server SDK barrel. */
2
+ export * from './lib/agent/runtime/results';
package/src/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export * from './lib/plugin';
2
2
  export * from './lib/plugin.interface';
3
3
  export * from './lib/plugin-metadata';
4
4
  export * from './lib/artifact-namespace';
5
+ export * from './lib/resource-card';
6
+ export * from './lib/resource-card-provider';
5
7
  export * from './lib/types';
6
8
  export * from './lib/logger';
7
9
  export * from './lib/integration/index';
@@ -14,6 +16,7 @@ export * from './lib/data/index';
14
16
  export * from './lib/ai-model/index';
15
17
  export * from './lib/runtime/index';
16
18
  export * from './lib/agent/index';
19
+ export * from './lib/assistant-capability/index';
17
20
  export * from './lib/channel/index';
18
21
  export * from './lib/file/index';
19
22
  export * from './lib/strategy';
@@ -27,3 +30,5 @@ export * from './lib/collaboration/index';
27
30
  export * from './lib/evolution/index';
28
31
  export * from './lib/mcp/index';
29
32
  export * from './lib/tool-provider/index';
33
+ export * from './lib/project-type/index';
34
+ export * from './lib/project-task/index';
@@ -1,4 +1,4 @@
1
- import { TChatOptions, TChatRequest, TChatRuntimePrincipal, TChatSourceAuditOptions } from '@xpert-ai/contracts';
1
+ import { TChatMessageEnvelope, TChatOptions, TChatRequest, TChatRuntimePrincipal, TChatSourceAuditOptions } from '@xpert-ai/contracts';
2
2
  export declare const AGENT_CHAT_DISPATCH_MESSAGE_TYPE: import("./message-type").StructuredHandoffMessageType;
3
3
  export declare const AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = "steer_target_not_running";
4
4
  export interface AgentChatHandoffMessageCallbackTarget {
@@ -16,11 +16,16 @@ export type AgentChatRuntimePrincipal = TChatRuntimePrincipal;
16
16
  export interface AgentChatDispatchPayload extends Record<string, unknown> {
17
17
  request: TChatRequest;
18
18
  options: TChatOptions & TChatSourceAuditOptions & {
19
+ /** Host-resolved runtime branch, independent of the conversation root. */
20
+ threadId?: string;
21
+ isDerivedThread?: boolean;
19
22
  xpertId?: string;
20
23
  isDraft?: boolean;
21
24
  from?: string;
22
25
  fromEndUserId?: string;
23
26
  runtimePrincipal?: AgentChatRuntimePrincipal;
27
+ /** Host-resolved provenance and presentation; never grants routing or execution privileges. */
28
+ messageEnvelope?: TChatMessageEnvelope;
24
29
  execution?: {
25
30
  id: string;
26
31
  };
@@ -0,0 +1,319 @@
1
+ import { z } from 'zod/v3';
2
+ import { type AgentRuntimeReplyTarget } from '../runtime/dispatch';
3
+ export declare const AGENT_RUNTIME_EVENT_MESSAGE_TYPE: import("./message-type").StructuredHandoffMessageType;
4
+ /** Host-produced references. Consumers reload and authorize the invocation and its pinned observation. */
5
+ export declare const agentRuntimeEventSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
6
+ kind: z.ZodLiteral<"progress">;
7
+ progress: z.ZodObject<{
8
+ source: z.ZodEnum<["executor", "host"]>;
9
+ observedAt: z.ZodString;
10
+ startedAt: z.ZodOptional<z.ZodString>;
11
+ phase: z.ZodOptional<z.ZodString>;
12
+ summary: z.ZodOptional<z.ZodString>;
13
+ steps: z.ZodOptional<z.ZodEffects<z.ZodObject<{
14
+ completed: z.ZodNumber;
15
+ total: z.ZodNumber;
16
+ }, "strict", z.ZodTypeAny, {
17
+ total?: number;
18
+ completed?: number;
19
+ }, {
20
+ total?: number;
21
+ completed?: number;
22
+ }>, {
23
+ total?: number;
24
+ completed?: number;
25
+ }, {
26
+ total?: number;
27
+ completed?: number;
28
+ }>>;
29
+ }, "strict", z.ZodTypeAny, {
30
+ source?: "executor" | "host";
31
+ startedAt?: string;
32
+ summary?: string;
33
+ steps?: {
34
+ total?: number;
35
+ completed?: number;
36
+ };
37
+ observedAt?: string;
38
+ phase?: string;
39
+ }, {
40
+ source?: "executor" | "host";
41
+ startedAt?: string;
42
+ summary?: string;
43
+ steps?: {
44
+ total?: number;
45
+ completed?: number;
46
+ };
47
+ observedAt?: string;
48
+ phase?: string;
49
+ }>;
50
+ version: z.ZodLiteral<1>;
51
+ invocationId: z.ZodString;
52
+ /** Revision of the persisted observation, never a queue delivery attempt. */
53
+ revision: z.ZodNumber;
54
+ projectTask: z.ZodOptional<z.ZodObject<{
55
+ projectId: z.ZodString;
56
+ projectTaskId: z.ZodString;
57
+ taskExecutionId: z.ZodString;
58
+ }, "strict", z.ZodTypeAny, {
59
+ projectId?: string;
60
+ projectTaskId?: string;
61
+ taskExecutionId?: string;
62
+ }, {
63
+ projectId?: string;
64
+ projectTaskId?: string;
65
+ taskExecutionId?: string;
66
+ }>>;
67
+ }, "strict", z.ZodTypeAny, {
68
+ version?: 1;
69
+ kind?: "progress";
70
+ projectTask?: {
71
+ projectId?: string;
72
+ projectTaskId?: string;
73
+ taskExecutionId?: string;
74
+ };
75
+ progress?: {
76
+ source?: "executor" | "host";
77
+ startedAt?: string;
78
+ summary?: string;
79
+ steps?: {
80
+ total?: number;
81
+ completed?: number;
82
+ };
83
+ observedAt?: string;
84
+ phase?: string;
85
+ };
86
+ invocationId?: string;
87
+ revision?: number;
88
+ }, {
89
+ version?: 1;
90
+ kind?: "progress";
91
+ projectTask?: {
92
+ projectId?: string;
93
+ projectTaskId?: string;
94
+ taskExecutionId?: string;
95
+ };
96
+ progress?: {
97
+ source?: "executor" | "host";
98
+ startedAt?: string;
99
+ summary?: string;
100
+ steps?: {
101
+ total?: number;
102
+ completed?: number;
103
+ };
104
+ observedAt?: string;
105
+ phase?: string;
106
+ };
107
+ invocationId?: string;
108
+ revision?: number;
109
+ }>, z.ZodObject<{
110
+ kind: z.ZodLiteral<"result">;
111
+ status: z.ZodEnum<["succeeded", "failed", "cancelled"]>;
112
+ version: z.ZodLiteral<1>;
113
+ invocationId: z.ZodString;
114
+ /** Revision of the persisted observation, never a queue delivery attempt. */
115
+ revision: z.ZodNumber;
116
+ projectTask: z.ZodOptional<z.ZodObject<{
117
+ projectId: z.ZodString;
118
+ projectTaskId: z.ZodString;
119
+ taskExecutionId: z.ZodString;
120
+ }, "strict", z.ZodTypeAny, {
121
+ projectId?: string;
122
+ projectTaskId?: string;
123
+ taskExecutionId?: string;
124
+ }, {
125
+ projectId?: string;
126
+ projectTaskId?: string;
127
+ taskExecutionId?: string;
128
+ }>>;
129
+ }, "strict", z.ZodTypeAny, {
130
+ status?: "failed" | "succeeded" | "cancelled";
131
+ version?: 1;
132
+ kind?: "result";
133
+ projectTask?: {
134
+ projectId?: string;
135
+ projectTaskId?: string;
136
+ taskExecutionId?: string;
137
+ };
138
+ invocationId?: string;
139
+ revision?: number;
140
+ }, {
141
+ status?: "failed" | "succeeded" | "cancelled";
142
+ version?: 1;
143
+ kind?: "result";
144
+ projectTask?: {
145
+ projectId?: string;
146
+ projectTaskId?: string;
147
+ taskExecutionId?: string;
148
+ };
149
+ invocationId?: string;
150
+ revision?: number;
151
+ }>, z.ZodObject<{
152
+ kind: z.ZodLiteral<"input_request">;
153
+ interactionId: z.ZodString;
154
+ version: z.ZodLiteral<1>;
155
+ invocationId: z.ZodString;
156
+ /** Revision of the persisted observation, never a queue delivery attempt. */
157
+ revision: z.ZodNumber;
158
+ projectTask: z.ZodOptional<z.ZodObject<{
159
+ projectId: z.ZodString;
160
+ projectTaskId: z.ZodString;
161
+ taskExecutionId: z.ZodString;
162
+ }, "strict", z.ZodTypeAny, {
163
+ projectId?: string;
164
+ projectTaskId?: string;
165
+ taskExecutionId?: string;
166
+ }, {
167
+ projectId?: string;
168
+ projectTaskId?: string;
169
+ taskExecutionId?: string;
170
+ }>>;
171
+ }, "strict", z.ZodTypeAny, {
172
+ version?: 1;
173
+ kind?: "input_request";
174
+ projectTask?: {
175
+ projectId?: string;
176
+ projectTaskId?: string;
177
+ taskExecutionId?: string;
178
+ };
179
+ invocationId?: string;
180
+ revision?: number;
181
+ interactionId?: string;
182
+ }, {
183
+ version?: 1;
184
+ kind?: "input_request";
185
+ projectTask?: {
186
+ projectId?: string;
187
+ projectTaskId?: string;
188
+ taskExecutionId?: string;
189
+ };
190
+ invocationId?: string;
191
+ revision?: number;
192
+ interactionId?: string;
193
+ }>]>;
194
+ export type AgentRuntimeEvent = z.output<typeof agentRuntimeEventSchema>;
195
+ /** Same observation always has the same HandoffMessage.id across retries and process restarts. */
196
+ export declare function agentRuntimeEventMessageId(event: Pick<AgentRuntimeEvent, 'invocationId' | 'revision' | 'kind'>): string;
197
+ /** Transport states are deliberately separate from Task and Invocation status. */
198
+ export declare const agentRuntimeDeliveryStateSchema: z.ZodEnum<["pending", "received", "blocked", "failed"]>;
199
+ export declare const agentRuntimeConsumptionStateSchema: z.ZodEnum<["pending", "processing", "processed", "blocked", "failed"]>;
200
+ export type AgentRuntimeDeliveryState = z.output<typeof agentRuntimeDeliveryStateSchema>;
201
+ export type AgentRuntimeConsumptionState = z.output<typeof agentRuntimeConsumptionStateSchema>;
202
+ /** Store under a unique scoped key in the same transaction as the continuation reservation. */
203
+ export declare const agentRuntimeResultClaimSchema: z.ZodObject<{
204
+ invocationId: z.ZodString;
205
+ resultRevision: z.ZodNumber;
206
+ recipient: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
207
+ type: z.ZodOptional<z.ZodLiteral<"xpert">>;
208
+ xpertId: z.ZodString;
209
+ agentKey: z.ZodString;
210
+ conversationId: z.ZodString;
211
+ threadId: z.ZodString;
212
+ }, "strict", z.ZodTypeAny, {
213
+ type?: "xpert";
214
+ threadId?: string;
215
+ conversationId?: string;
216
+ xpertId?: string;
217
+ agentKey?: string;
218
+ }, {
219
+ type?: "xpert";
220
+ threadId?: string;
221
+ conversationId?: string;
222
+ xpertId?: string;
223
+ agentKey?: string;
224
+ }>, z.ZodObject<{
225
+ type: z.ZodLiteral<"project_agent">;
226
+ projectId: z.ZodString;
227
+ agentKey: z.ZodLiteral<"general_agent">;
228
+ conversationId: z.ZodString;
229
+ threadId: z.ZodString;
230
+ }, "strict", z.ZodTypeAny, {
231
+ type?: "project_agent";
232
+ threadId?: string;
233
+ conversationId?: string;
234
+ projectId?: string;
235
+ agentKey?: "general_agent";
236
+ }, {
237
+ type?: "project_agent";
238
+ threadId?: string;
239
+ conversationId?: string;
240
+ projectId?: string;
241
+ agentKey?: "general_agent";
242
+ }>]>;
243
+ consumer: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
244
+ type: z.ZodLiteral<"follow_up">;
245
+ executionId: z.ZodString;
246
+ }, "strict", z.ZodTypeAny, {
247
+ type?: "follow_up";
248
+ executionId?: string;
249
+ }, {
250
+ type?: "follow_up";
251
+ executionId?: string;
252
+ }>, z.ZodObject<{
253
+ type: z.ZodLiteral<"wait">;
254
+ executionId: z.ZodString;
255
+ callId: z.ZodString;
256
+ }, "strict", z.ZodTypeAny, {
257
+ type?: "wait";
258
+ executionId?: string;
259
+ callId?: string;
260
+ }, {
261
+ type?: "wait";
262
+ executionId?: string;
263
+ callId?: string;
264
+ }>]>;
265
+ }, "strict", z.ZodTypeAny, {
266
+ invocationId?: string;
267
+ resultRevision?: number;
268
+ recipient?: {
269
+ type?: "xpert";
270
+ threadId?: string;
271
+ conversationId?: string;
272
+ xpertId?: string;
273
+ agentKey?: string;
274
+ } | {
275
+ type?: "project_agent";
276
+ threadId?: string;
277
+ conversationId?: string;
278
+ projectId?: string;
279
+ agentKey?: "general_agent";
280
+ };
281
+ consumer?: {
282
+ type?: "follow_up";
283
+ executionId?: string;
284
+ } | {
285
+ type?: "wait";
286
+ executionId?: string;
287
+ callId?: string;
288
+ };
289
+ }, {
290
+ invocationId?: string;
291
+ resultRevision?: number;
292
+ recipient?: {
293
+ type?: "xpert";
294
+ threadId?: string;
295
+ conversationId?: string;
296
+ xpertId?: string;
297
+ agentKey?: string;
298
+ } | {
299
+ type?: "project_agent";
300
+ threadId?: string;
301
+ conversationId?: string;
302
+ projectId?: string;
303
+ agentKey?: "general_agent";
304
+ };
305
+ consumer?: {
306
+ type?: "follow_up";
307
+ executionId?: string;
308
+ } | {
309
+ type?: "wait";
310
+ executionId?: string;
311
+ callId?: string;
312
+ };
313
+ }>;
314
+ export type AgentRuntimeResultClaim = z.output<typeof agentRuntimeResultClaimSchema>;
315
+ /**
316
+ * Wait and asynchronous reply compete for this same key, regardless of delivery revision.
317
+ * The storage key must additionally include tenant, organization and owner from trusted scope.
318
+ */
319
+ export declare function agentRuntimeResultConsumptionKey(invocationId: string, recipient: AgentRuntimeReplyTarget): string;
@@ -1,5 +1,6 @@
1
1
  export * from './message-type';
2
2
  export * from './agent-chat.contract';
3
+ export * from './agent-runtime-message.contract';
3
4
  export * from './handoff.interface';
4
5
  export * from './handoff-processor.decorator';
5
6
  export * from './handoff-processor.registry';
@@ -1,3 +1,5 @@
1
1
  export * from './skill/index';
2
2
  export * from './middleware';
3
3
  export * from './handoff';
4
+ export * from './runtime';
5
+ export * from './resource-card';