@agentropy/core 0.0.0-bootstrap.0 → 0.1.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.
@@ -0,0 +1,284 @@
1
+ /** Agent v1 revision 7 (docs/contracts/agent-v1.md). Types only; no I/O. */
2
+ import type { CapabilityAccess, CapabilitySelection, EffectiveCapabilitySnapshot, RuntimeRequirements } from './capability.js';
3
+ import type { ImplementationBinding } from './implementation.js';
4
+ import type { SkillAccess, SkillPin } from './skill.js';
5
+ import type { ToolPin } from './tool.js';
6
+ export type AgentId = string;
7
+ export type AgentInstanceId = string;
8
+ export type TaskId = string;
9
+ export type ExecutionId = string;
10
+ export type Version = string;
11
+ /** JSON Schema 2020-12 document. */
12
+ export type JsonSchema = Record<string, unknown> | boolean;
13
+ export type AgentProfileId = 'conversational' | 'task' | 'monitoring' | 'coordinator' | 'specialist' | 'generic' | (string & {});
14
+ export type DurabilityLevel = 'none' | 'durable-acceptance' | 'durable-execution';
15
+ export interface VersionedRef {
16
+ id: string;
17
+ version: Version;
18
+ }
19
+ export interface AgentImplementationRef {
20
+ providerId: string;
21
+ providerVersion: Version;
22
+ artifact: VersionedRef;
23
+ }
24
+ export interface SkillSelection {
25
+ id: string;
26
+ versionRange: string;
27
+ required?: boolean;
28
+ }
29
+ export interface ToolSelection {
30
+ id: string;
31
+ versionRange: string;
32
+ required?: boolean;
33
+ bindingId?: string;
34
+ }
35
+ export interface RetryPolicy {
36
+ maxAttempts: number;
37
+ backoff: {
38
+ initialMs: number;
39
+ maxMs: number;
40
+ multiplier: number;
41
+ };
42
+ }
43
+ export interface AgentDefinition {
44
+ id: AgentId;
45
+ version: Version;
46
+ displayName: string;
47
+ profile: VersionedRef;
48
+ implementation: AgentImplementationRef;
49
+ inputSchema: JsonSchema;
50
+ runtimeRequirements: RuntimeRequirements;
51
+ policyRef: VersionedRef;
52
+ description?: string;
53
+ capabilities?: CapabilitySelection[];
54
+ skills?: SkillSelection[];
55
+ tools?: ToolSelection[];
56
+ outputSchema?: JsonSchema;
57
+ modelRef?: VersionedRef;
58
+ memoryRef?: VersionedRef;
59
+ communicationRef?: VersionedRef;
60
+ retryPolicy?: RetryPolicy;
61
+ }
62
+ export interface AgentInstance {
63
+ id: AgentInstanceId;
64
+ definition: VersionedRef;
65
+ tenantId: string;
66
+ ownerId: string;
67
+ state: 'available' | 'suspended' | 'retired';
68
+ revision: number;
69
+ /** Set by drain: no new tasks are accepted; the instance retires when its last task ends (not a lifecycle state). */
70
+ draining?: boolean;
71
+ /** Principals (users or services) the owner allows to delegate to this instance; see D-08 governance rules. */
72
+ sharedWith?: string[];
73
+ /** Definition version before the last upgrade (FEAT-028.3), for an audited rollback. */
74
+ previousDefinition?: VersionedRef;
75
+ }
76
+ export interface TrustedPrincipal {
77
+ id: string;
78
+ type: 'user' | 'agent' | 'service';
79
+ tenantId: string;
80
+ delegatedAuthorityRef?: string;
81
+ }
82
+ export type WakeupCondition = {
83
+ kind: 'timer';
84
+ at: string;
85
+ } | {
86
+ kind: 'schedule';
87
+ cron: string;
88
+ timezone: string;
89
+ } | {
90
+ kind: 'event';
91
+ subscription: string;
92
+ filter?: unknown;
93
+ } | {
94
+ kind: 'human-action';
95
+ requestId: string;
96
+ } | {
97
+ kind: 'child-tasks';
98
+ taskIds: TaskId[];
99
+ mode: 'all' | 'any';
100
+ };
101
+ export interface WakeupRequest {
102
+ anyOf: WakeupCondition[];
103
+ timeoutAt?: string;
104
+ onTimeout?: 'resume' | 'fail';
105
+ }
106
+ export type WakeReason = {
107
+ kind: 'timer' | 'schedule';
108
+ firedAt: string;
109
+ } | {
110
+ kind: 'event';
111
+ subscription: string;
112
+ eventId: string;
113
+ payload: unknown;
114
+ } | {
115
+ kind: 'human-action';
116
+ requestId: string;
117
+ outcome: 'resolved' | 'expired' | 'revoked';
118
+ input?: unknown;
119
+ } | {
120
+ kind: 'child-tasks';
121
+ children: {
122
+ taskId: TaskId;
123
+ status: 'completed' | 'failed' | 'cancelled';
124
+ output?: unknown;
125
+ outcome?: {
126
+ code: string;
127
+ message: string;
128
+ };
129
+ }[];
130
+ } | {
131
+ kind: 'timeout';
132
+ };
133
+ export interface AgentInvocation<I = unknown> {
134
+ taskId: TaskId;
135
+ executionId: ExecutionId;
136
+ activation: number;
137
+ attempt: number;
138
+ input: I;
139
+ trigger: 'delegation' | 'resume' | 'retry';
140
+ checkpoint?: unknown;
141
+ wakeReason?: WakeReason;
142
+ }
143
+ export interface ProgressReporter {
144
+ report(progress: {
145
+ message: string;
146
+ percent?: number;
147
+ stepKey?: string;
148
+ }): Promise<void>;
149
+ }
150
+ export interface AgentContext {
151
+ readonly tenantId: string;
152
+ readonly agentInstanceId: AgentInstanceId;
153
+ readonly taskId: TaskId;
154
+ readonly executionId: ExecutionId;
155
+ readonly principal: TrustedPrincipal;
156
+ readonly correlationId: string;
157
+ readonly causationId?: string;
158
+ readonly deadline?: string;
159
+ readonly signal: AbortSignal;
160
+ readonly capabilities: CapabilityAccess;
161
+ readonly progress: ProgressReporter;
162
+ readonly skills: SkillAccess;
163
+ }
164
+ export type AgentDisposition<O> = {
165
+ kind: 'completed';
166
+ output: O;
167
+ } | {
168
+ kind: 'waiting';
169
+ wakeup: WakeupRequest;
170
+ checkpoint: unknown;
171
+ } | {
172
+ kind: 'failed';
173
+ code: string;
174
+ retryable: boolean;
175
+ message: string;
176
+ };
177
+ export interface Agent<I = unknown, O = unknown> {
178
+ handle(invocation: AgentInvocation<I>, context: AgentContext): Promise<AgentDisposition<O>>;
179
+ /**
180
+ * Checkpoint codec (FEAT-028.3, M3-03). Checkpoints are stored with the codec version that wrote them (default 1).
181
+ * Resuming an older checkpoint calls `upgrade`; without it, or for a checkpoint newer than this handler, the
182
+ * activation fails with `IncompatibleVersion` — never a silent reinterpretation.
183
+ */
184
+ checkpointCodec?: CheckpointCodec;
185
+ }
186
+ export interface CheckpointCodec {
187
+ /** Positive integer; increase it whenever the checkpoint shape changes. */
188
+ version: number;
189
+ /** Converts a checkpoint written by `fromVersion` (< version) to the current shape. */
190
+ upgrade?(checkpoint: unknown, fromVersion: number): unknown;
191
+ }
192
+ export interface HandlerRegistry {
193
+ register(artifact: VersionedRef, handler: Agent): void;
194
+ unregister(artifact: VersionedRef): void;
195
+ get(artifact: VersionedRef): Agent | undefined;
196
+ }
197
+ export interface DelegationRequest<I = unknown> {
198
+ target: {
199
+ definition?: VersionedRef;
200
+ instanceId?: AgentInstanceId;
201
+ /** A remotely deployed agent reached through the CommunicationRouter (A2A or a custom provider). */
202
+ remote?: {
203
+ endpoint: string;
204
+ definitionId: string;
205
+ version?: string;
206
+ };
207
+ };
208
+ input: I;
209
+ idempotencyKey: string;
210
+ correlationId: string;
211
+ parentTaskId?: TaskId;
212
+ deadline?: string;
213
+ budget?: {
214
+ maxCostUnits?: number;
215
+ maxActivations?: number;
216
+ };
217
+ }
218
+ export interface DelegateInput<I = unknown> {
219
+ target: DelegationRequest<I>['target'];
220
+ input: I;
221
+ deadline?: string;
222
+ budget?: DelegationRequest<I>['budget'];
223
+ }
224
+ export interface TaskHandle {
225
+ taskId: TaskId;
226
+ agentInstanceId: AgentInstanceId;
227
+ status: 'created' | 'assigned';
228
+ definition: VersionedRef;
229
+ durability: DurabilityLevel;
230
+ }
231
+ export interface TaskSnapshot {
232
+ taskId: TaskId;
233
+ status: 'created' | 'assigned' | 'running' | 'waiting' | 'completed' | 'failed' | 'cancelled';
234
+ revision: number;
235
+ agentInstanceId?: AgentInstanceId;
236
+ parentTaskId?: TaskId;
237
+ retryOf?: TaskId;
238
+ cancelRequestedAt?: string;
239
+ waitingOn?: WakeupRequest;
240
+ outcome?: {
241
+ code: string;
242
+ message: string;
243
+ };
244
+ authority: 'local' | 'remote';
245
+ /** The caller's correlation ID (A2A `contextId`). */
246
+ correlationId?: string;
247
+ /** When the task last changed state (A2A status timestamp). */
248
+ updatedAt?: string;
249
+ }
250
+ export interface ExecutionRecord {
251
+ executionId: ExecutionId;
252
+ taskId: TaskId;
253
+ activation: number;
254
+ attempt: number;
255
+ trigger: AgentInvocation['trigger'];
256
+ state: 'queued' | 'leased' | 'running' | 'succeeded' | 'yielded' | 'failed' | 'aborted' | 'lost';
257
+ leaseEpoch?: number;
258
+ startedAt?: string;
259
+ endedAt?: string;
260
+ }
261
+ export interface WakeupRegistration {
262
+ id: string;
263
+ taskId: TaskId;
264
+ conditions: WakeupCondition[];
265
+ timeoutAt?: string;
266
+ onTimeout: 'resume' | 'fail';
267
+ status: 'armed' | 'fired' | 'revoked';
268
+ revision: number;
269
+ }
270
+ export interface OmittedSelection {
271
+ kind: 'capability' | 'tool' | 'skill';
272
+ id: string;
273
+ code: string;
274
+ }
275
+ /** Immutable, redacted pins recorded at task acceptance (T1). */
276
+ export interface AcceptanceSnapshot extends EffectiveCapabilitySnapshot {
277
+ definition: VersionedRef;
278
+ profile: VersionedRef;
279
+ implementation: ImplementationBinding;
280
+ durability: DurabilityLevel;
281
+ tools: ToolPin[];
282
+ skills: SkillPin[];
283
+ omitted: OmittedSelection[];
284
+ }
package/dist/agent.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ /** Capability v1 revision 6 types (docs/contracts/capability-v1.md). */
2
+ import type { JsonSchema } from './agent.js';
3
+ export type CapabilityId = string;
4
+ export type CapabilityVersion = string;
5
+ export type OperationEffect = 'read' | 'internal' | 'external';
6
+ export interface OperationContract {
7
+ name: string;
8
+ inputSchema: JsonSchema;
9
+ outputSchema?: JsonSchema;
10
+ permission: string;
11
+ effect: OperationEffect;
12
+ }
13
+ export interface CapabilityRequirement {
14
+ id: CapabilityId;
15
+ versionRange: string;
16
+ }
17
+ export interface CapabilityContract {
18
+ id: CapabilityId;
19
+ version: CapabilityVersion;
20
+ kind: 'behavior' | 'guarantee';
21
+ configSchema: JsonSchema;
22
+ dependencies: CapabilityRequirement[];
23
+ conflicts?: CapabilityRequirement[];
24
+ operations: OperationContract[];
25
+ levels?: string[];
26
+ }
27
+ export interface CapabilitySelection {
28
+ id: CapabilityId;
29
+ versionRange: string;
30
+ config?: Record<string, unknown>;
31
+ providerId?: string;
32
+ level?: string;
33
+ remove?: boolean;
34
+ }
35
+ export interface CapabilityBinding {
36
+ id: CapabilityId;
37
+ version: CapabilityVersion;
38
+ providerId: string;
39
+ providerVersion: string;
40
+ config: Record<string, unknown>;
41
+ level?: string;
42
+ }
43
+ export interface AgentProfile {
44
+ id: string;
45
+ version: string;
46
+ required: CapabilitySelection[];
47
+ defaults: CapabilitySelection[];
48
+ optional: CapabilityRequirement[];
49
+ }
50
+ export interface RuntimeRequirements {
51
+ guarantees: CapabilitySelection[];
52
+ }
53
+ export interface EffectiveCapabilitySnapshot {
54
+ snapshotId: string;
55
+ bindings: CapabilityBinding[];
56
+ policyRef: {
57
+ id: string;
58
+ version: string;
59
+ };
60
+ resolvedAt: string;
61
+ }
62
+ export interface CapabilityInvocationContext {
63
+ tenantId: string;
64
+ taskId: string;
65
+ executionId: string;
66
+ principalId: string;
67
+ delegatedAuthorityRef?: string;
68
+ idempotencyKey?: string;
69
+ /** The handler's step key for this effect, when it gave one (the idempotency key is derived from it). */
70
+ stepKey?: string;
71
+ /** W3C traceparent of the capability span, for propagating trace context to child work (never authorization). */
72
+ traceparent?: string;
73
+ signal: AbortSignal;
74
+ }
75
+ export interface CapabilityProvider {
76
+ readonly id: string;
77
+ readonly version: string;
78
+ readonly contracts: {
79
+ id: CapabilityId;
80
+ version: CapabilityVersion;
81
+ level?: string;
82
+ }[];
83
+ invoke<I, O>(operation: string, input: I, context: CapabilityInvocationContext): Promise<O>;
84
+ }
85
+ export interface CapabilityAccess {
86
+ invoke<I, O>(capabilityId: CapabilityId, operation: string, input: I, options?: {
87
+ stepKey?: string;
88
+ }): Promise<O>;
89
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /** Canonical capability catalog and built-in profiles (Capability v1 revision 6). */
2
+ import type { DurabilityLevel } from './agent.js';
3
+ import type { AgentProfile, CapabilityContract } from './capability.js';
4
+ export declare const DURABILITY_LEVELS: readonly DurabilityLevel[];
5
+ export declare function durabilityRank(level: string): number;
6
+ export declare const CAPABILITY_CATALOG: readonly CapabilityContract[];
7
+ export declare const CAPABILITY_IDS: string[];
8
+ export declare const BUILTIN_PROFILES: readonly AgentProfile[];
@@ -0,0 +1,217 @@
1
+ export const DURABILITY_LEVELS = [
2
+ 'none',
3
+ 'durable-acceptance',
4
+ 'durable-execution',
5
+ ];
6
+ export function durabilityRank(level) {
7
+ return DURABILITY_LEVELS.indexOf(level);
8
+ }
9
+ const text = { type: 'string', minLength: 1 };
10
+ /**
11
+ * Input schemas of the built-in operations (Capability v1 revision 15). The runtime validates an invocation's input
12
+ * against its operation's schema before the provider runs, so malformed handler input is a non-retryable
13
+ * `SchemaViolation` instead of a `TypeError` in the provider (which would become a retried `Internal`). They state
14
+ * what the reference providers read; an operation that is absent takes any input.
15
+ */
16
+ const OPERATION_INPUTS = {
17
+ 'delegation.delegate': {
18
+ type: 'object',
19
+ required: ['target'],
20
+ properties: {
21
+ target: { type: 'object' },
22
+ deadline: { type: 'string' },
23
+ budget: { type: 'object' },
24
+ },
25
+ },
26
+ 'delegation.getTask': {
27
+ type: 'object',
28
+ required: ['taskId'],
29
+ properties: { taskId: text },
30
+ },
31
+ 'delegation.cancel': {
32
+ type: 'object',
33
+ required: ['taskId'],
34
+ properties: { taskId: text, reason: { type: 'string' } },
35
+ },
36
+ 'event-handling.subscribe': {
37
+ type: 'object',
38
+ required: ['source'],
39
+ properties: { source: text, filter: { type: 'object' } },
40
+ },
41
+ 'event-handling.unsubscribe': {
42
+ type: 'object',
43
+ required: ['subscription'],
44
+ properties: { subscription: text },
45
+ },
46
+ 'scheduling.nextOccurrence': {
47
+ type: 'object',
48
+ required: ['cron', 'timezone'],
49
+ properties: {
50
+ cron: text,
51
+ timezone: text,
52
+ after: { type: 'string' },
53
+ },
54
+ },
55
+ 'reasoning.complete': {
56
+ type: 'object',
57
+ properties: {
58
+ prompt: { type: 'string' },
59
+ system: { type: 'string' },
60
+ messages: { type: 'array', items: { type: 'object' } },
61
+ maxTokens: { type: 'integer', minimum: 1 },
62
+ temperature: { type: 'number' },
63
+ tools: { type: 'array', items: { type: 'string' } },
64
+ },
65
+ },
66
+ 'tool-use.call': {
67
+ type: 'object',
68
+ required: ['toolId'],
69
+ properties: { toolId: text },
70
+ },
71
+ 'workflow.start': {
72
+ type: 'object',
73
+ required: ['workflow'],
74
+ properties: { workflow: text },
75
+ },
76
+ 'workflow.status': {
77
+ type: 'object',
78
+ required: ['runId'],
79
+ properties: { runId: text },
80
+ },
81
+ };
82
+ const op = (capability, name, effect) => ({
83
+ name,
84
+ inputSchema: (OPERATION_INPUTS[`${capability}.${name}`] ?? true),
85
+ permission: `${capability}:${name}`,
86
+ effect,
87
+ });
88
+ const behavior = (id, ops) => ({
89
+ id,
90
+ version: '1.0.0',
91
+ kind: 'behavior',
92
+ configSchema: { type: 'object' },
93
+ dependencies: [],
94
+ operations: ops.map(([name, effect]) => op(id, name, effect)),
95
+ });
96
+ export const CAPABILITY_CATALOG = [
97
+ behavior('conversation', [
98
+ ['reply', 'internal'],
99
+ ['briefing', 'read'],
100
+ ]),
101
+ behavior('session-context', [
102
+ ['get', 'read'],
103
+ ['put', 'internal'],
104
+ ]),
105
+ behavior('delegation', [
106
+ ['delegate', 'external'],
107
+ ['getTask', 'read'],
108
+ ['cancel', 'external'],
109
+ ]),
110
+ behavior('notification', [['notify', 'external']]),
111
+ behavior('event-handling', [
112
+ ['subscribe', 'internal'],
113
+ ['unsubscribe', 'internal'],
114
+ ]),
115
+ behavior('scheduling', [['nextOccurrence', 'read']]),
116
+ behavior('human-input', [['requestAction', 'external']]),
117
+ behavior('tool-use', [
118
+ ['listTools', 'read'],
119
+ ['call', 'external'],
120
+ ]),
121
+ behavior('reasoning', [
122
+ ['complete', 'read'],
123
+ ['plan', 'read'],
124
+ ]),
125
+ behavior('memory', [
126
+ ['recall', 'read'],
127
+ ['remember', 'internal'],
128
+ ]),
129
+ behavior('workflow', [
130
+ ['start', 'external'],
131
+ ['status', 'read'],
132
+ ]),
133
+ {
134
+ id: 'durability',
135
+ version: '1.0.0',
136
+ kind: 'guarantee',
137
+ configSchema: { type: 'object' },
138
+ dependencies: [],
139
+ operations: [],
140
+ levels: [...DURABILITY_LEVELS],
141
+ },
142
+ {
143
+ // N-02: execution isolation the runtime can promise. The local runtime provides `logical` (tenant and
144
+ // app-context separation in one process); process and sandbox isolation need a provider that offers them.
145
+ id: 'isolation',
146
+ version: '1.0.0',
147
+ kind: 'guarantee',
148
+ configSchema: { type: 'object' },
149
+ dependencies: [],
150
+ operations: [],
151
+ levels: ['logical', 'process', 'sandbox'],
152
+ },
153
+ ];
154
+ export const CAPABILITY_IDS = CAPABILITY_CATALOG.map((c) => c.id);
155
+ const sel = (id, level) => ({
156
+ id,
157
+ versionRange: '^1.0.0',
158
+ ...(level ? { level } : {}),
159
+ });
160
+ const req = (id) => ({ id, versionRange: '^1.0.0' });
161
+ export const BUILTIN_PROFILES = [
162
+ {
163
+ id: 'conversational',
164
+ version: '1.0.0',
165
+ required: [sel('conversation'), sel('session-context')],
166
+ defaults: [sel('delegation'), sel('durability', 'durable-acceptance')],
167
+ optional: [req('memory'), req('tool-use'), req('reasoning')],
168
+ },
169
+ {
170
+ id: 'task',
171
+ version: '1.0.0',
172
+ required: [sel('durability', 'durable-execution')],
173
+ defaults: [sel('notification')],
174
+ optional: [
175
+ 'scheduling',
176
+ 'event-handling',
177
+ 'workflow',
178
+ 'reasoning',
179
+ 'human-input',
180
+ 'tool-use',
181
+ 'delegation',
182
+ ].map(req),
183
+ },
184
+ {
185
+ id: 'monitoring',
186
+ version: '1.0.0',
187
+ required: [sel('event-handling'), sel('durability', 'durable-execution')],
188
+ defaults: [sel('scheduling'), sel('notification')],
189
+ optional: [req('delegation'), req('reasoning')],
190
+ },
191
+ {
192
+ id: 'coordinator',
193
+ version: '1.0.0',
194
+ required: [sel('delegation'), sel('durability', 'durable-execution')],
195
+ defaults: [sel('notification')],
196
+ optional: [req('conversation'), req('workflow'), req('reasoning')],
197
+ },
198
+ {
199
+ id: 'specialist',
200
+ version: '1.0.0',
201
+ required: [],
202
+ defaults: [sel('tool-use')],
203
+ optional: [
204
+ req('reasoning'),
205
+ req('memory'),
206
+ req('conversation'),
207
+ req('durability'),
208
+ ],
209
+ },
210
+ {
211
+ id: 'generic',
212
+ version: '1.0.0',
213
+ required: [],
214
+ defaults: [],
215
+ optional: CAPABILITY_CATALOG.map((c) => req(c.id)),
216
+ },
217
+ ];
@@ -0,0 +1,101 @@
1
+ /** Communication v1 revision 4 types (docs/contracts/communication-v1.md). */
2
+ import type { DelegationRequest, DurabilityLevel, TaskSnapshot, TrustedPrincipal } from './agent.js';
3
+ export interface AgentRef {
4
+ definitionId: string;
5
+ instanceId?: string;
6
+ version?: string;
7
+ tenantId: string;
8
+ endpoint?: string;
9
+ }
10
+ export interface CallContext {
11
+ caller: TrustedPrincipal;
12
+ correlationId: string;
13
+ causationId?: string;
14
+ deadline?: string;
15
+ signal?: AbortSignal;
16
+ }
17
+ export interface RouteBinding {
18
+ providerId: string;
19
+ protocol: string;
20
+ protocolVersion: string;
21
+ target: AgentRef;
22
+ }
23
+ export interface RemoteTaskRef {
24
+ localTaskId: string;
25
+ route: RouteBinding;
26
+ remoteTaskId: string;
27
+ }
28
+ export type CommunicationOperation = 'delegate' | 'send' | 'getTask' | 'cancel' | 'subscribe';
29
+ export interface CommunicationFeatures {
30
+ operations: readonly CommunicationOperation[];
31
+ streaming: boolean;
32
+ pushNotifications: boolean;
33
+ durability: DurabilityLevel | 'provider-dependent';
34
+ protocol: string;
35
+ protocolVersion: string;
36
+ extensions?: readonly {
37
+ id: string;
38
+ version: string;
39
+ }[];
40
+ }
41
+ export interface RouteRequirements {
42
+ operations?: readonly CommunicationOperation[];
43
+ durability?: DurabilityLevel;
44
+ extensions?: readonly string[];
45
+ }
46
+ export interface AgentMessage<T = unknown> {
47
+ schemaVersion: number;
48
+ kind: 'command' | 'query' | 'event';
49
+ name: string;
50
+ messageId: string;
51
+ correlationId: string;
52
+ causationId?: string;
53
+ idempotencyKey?: string;
54
+ tenantId: string;
55
+ agentDefinitionId?: string;
56
+ agentDefinitionVersion?: string;
57
+ agentInstanceId?: string;
58
+ taskId?: string;
59
+ parentTaskId?: string;
60
+ executionId?: string;
61
+ actor: {
62
+ principalId: string;
63
+ principalType: 'user' | 'service' | 'agent';
64
+ delegatedBy?: string;
65
+ };
66
+ createdAt: string;
67
+ payload: T;
68
+ }
69
+ export interface MessageReceipt {
70
+ messageId: string;
71
+ accepted: boolean;
72
+ }
73
+ export interface AgentEvent {
74
+ eventId: string;
75
+ taskId: string;
76
+ type: string;
77
+ revision?: number;
78
+ payload: unknown;
79
+ }
80
+ export interface RemoteTaskState {
81
+ remoteState: string;
82
+ normalized: TaskSnapshot['status'] | 'unknown';
83
+ observedAt: string;
84
+ /** Result reported by the remote side once completed (data, never instructions). */
85
+ output?: unknown;
86
+ }
87
+ export interface AgentCommunicationProvider {
88
+ readonly id: string;
89
+ readonly features: CommunicationFeatures;
90
+ supports(target: AgentRef, operation: CommunicationOperation): boolean;
91
+ delegate<I>(route: RouteBinding, request: DelegationRequest<I>, ctx: CallContext): Promise<RemoteTaskRef>;
92
+ send(route: RouteBinding, message: AgentMessage, ctx: CallContext): Promise<MessageReceipt>;
93
+ getTask(ref: RemoteTaskRef, ctx: CallContext): Promise<RemoteTaskState>;
94
+ cancel(ref: RemoteTaskRef, ctx: CallContext): Promise<RemoteTaskState>;
95
+ subscribe(ref: RemoteTaskRef, ctx: CallContext): AsyncIterable<AgentEvent>;
96
+ }
97
+ export interface CommunicationRouter {
98
+ register(provider: AgentCommunicationProvider): void;
99
+ selectRoute(target: AgentRef, operation: CommunicationOperation, ctx: CallContext, requirements?: RouteRequirements): Promise<RouteBinding>;
100
+ provider(route: RouteBinding): AgentCommunicationProvider;
101
+ }