@hosty-sdk/app 0.47.0 → 0.48.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,522 @@
1
+ import type { ConversationRef, NativeSessionRef, ProviderRef, Revision, RunRef } from "./agent-sessions.js";
2
+ /** Public execution identities never reveal a native SDK thread, filesystem path or process ID. */
3
+ export type AgentProviderRef = ProviderRef;
4
+ export type AgentSessionRef = NativeSessionRef;
5
+ export type AgentRunRef = RunRef;
6
+ export declare const AGENT_API_VERSION: 1;
7
+ export declare const AGENT_EVENT_VERSION: "agent-event.1";
8
+ export declare const AGENT_CAPABILITIES: {
9
+ readonly resume: "session.resume";
10
+ readonly configuration: "configuration.resume-compatible";
11
+ readonly images: "input.images";
12
+ readonly noNativeTools: "native-tools.none";
13
+ readonly skills: "skills.catalog";
14
+ readonly exclusiveSkills: "skills.exclusive-selection";
15
+ readonly coreMcp: "mcp.core";
16
+ readonly externalMcp: "mcp.external";
17
+ readonly modelChange: "model.change-on-resume";
18
+ readonly nextTurnDecisions: "decisions.next-turn";
19
+ readonly nativeSubagents: "subagents.native";
20
+ readonly park: "runs.park";
21
+ readonly barrier: "runs.barrier";
22
+ readonly reconcile: "runs.reconcile";
23
+ readonly liveConfigure: "runs.live-configure";
24
+ readonly predictions: "predictions";
25
+ readonly connectionUsage: "connections.usage";
26
+ readonly approvalMode: "configuration.approval-mode";
27
+ readonly mcpPolicy: "mcp.policy-update";
28
+ readonly consumerWorkflow: "workflow.consumer";
29
+ };
30
+ export type AgentCapability = typeof AGENT_CAPABILITIES[keyof typeof AGENT_CAPABILITIES] | (string & {});
31
+ export type AgentLimits = {
32
+ maxCommandBytes: number;
33
+ maxEventBytes: number;
34
+ maxSnapshotBytes: number;
35
+ maxReplayBytes: number;
36
+ replayRetentionMs: number;
37
+ maxControls: number;
38
+ maxPageSize: number;
39
+ maxDurationMs?: number;
40
+ maxSkillSnapshotBytes?: number;
41
+ maxSkillSnapshotFiles?: number;
42
+ };
43
+ export type AgentCapabilities = {
44
+ version: 1;
45
+ eventVersions: string[];
46
+ capabilities: AgentCapability[];
47
+ limits: AgentLimits;
48
+ configuration: {
49
+ resumeCompatible: string[];
50
+ };
51
+ nativeTools?: {
52
+ default: "none" | "provider_default";
53
+ none: boolean;
54
+ };
55
+ subagents?: {
56
+ defaultEnabled: boolean;
57
+ policy: "enforceable" | "observed" | "unavailable";
58
+ observation: "full" | "partial" | "summary" | "unavailable";
59
+ };
60
+ };
61
+ export type AgentConnection = {
62
+ id: string;
63
+ revision: Revision;
64
+ name: string;
65
+ ready: boolean;
66
+ reason?: string;
67
+ capabilities?: AgentCapability[];
68
+ };
69
+ export type AgentConnectionPage = {
70
+ connections: AgentConnection[];
71
+ nextCursor: string | null;
72
+ };
73
+ export type AgentModel = {
74
+ id: string;
75
+ name?: string;
76
+ reasoningEfforts: Array<string | null>;
77
+ defaultReasoningEffort?: string | null;
78
+ capabilities?: AgentCapability[];
79
+ unavailableReason?: string;
80
+ };
81
+ /** Catalog revisions are opaque content identities, independent of session/control counters. */
82
+ export type AgentModelCatalog = {
83
+ revision: string;
84
+ models: AgentModel[];
85
+ defaultModel: string | null;
86
+ nextCursor?: string | null;
87
+ };
88
+ export type AgentConnectionUsage = {
89
+ observedAt: string;
90
+ available: boolean;
91
+ data?: Record<string, unknown>;
92
+ };
93
+ export type AgentInstruction = {
94
+ id: string;
95
+ text: string;
96
+ };
97
+ export type AgentSkillSelection = {
98
+ skillId: string;
99
+ expectedDigest?: string;
100
+ };
101
+ export type AgentMcpTarget = {
102
+ kind: "core";
103
+ } | {
104
+ kind: "app";
105
+ appId: string;
106
+ installationId: string;
107
+ key: string;
108
+ };
109
+ export type AgentMcpPolicy = {
110
+ default: "ask" | "run";
111
+ autoAllowReadOnly?: boolean;
112
+ tools?: Record<string, {
113
+ mode: "ask" | "run" | "disabled";
114
+ definition?: string;
115
+ }>;
116
+ };
117
+ export type AgentMcpSelection = {
118
+ targets?: Array<{
119
+ target: AgentMcpTarget;
120
+ tools?: string[];
121
+ policy?: AgentMcpPolicy;
122
+ }>;
123
+ connections?: Array<{
124
+ id: string;
125
+ revision: Revision;
126
+ }>;
127
+ };
128
+ export type AgentConfiguration = {
129
+ connection: {
130
+ id: string;
131
+ revision: Revision;
132
+ };
133
+ instructions?: AgentInstruction[];
134
+ systemPrompt?: {
135
+ mode: "append";
136
+ text: string;
137
+ };
138
+ skills?: AgentSkillSelection[];
139
+ nativeTools?: "provider_default" | "none";
140
+ approvalMode?: "normal" | "autonomous";
141
+ predictions?: {
142
+ enabled: boolean;
143
+ };
144
+ subagents?: {
145
+ enabled: boolean;
146
+ maxConcurrency?: number;
147
+ };
148
+ };
149
+ export type AgentSessionCreate = {
150
+ configuration: AgentConfiguration;
151
+ requiredCapabilities?: AgentCapability[];
152
+ correlation?: {
153
+ conversation?: ConversationRef;
154
+ task?: {
155
+ provider: ProviderRef;
156
+ id: string;
157
+ };
158
+ };
159
+ };
160
+ export type AgentConfigurationCreate = {
161
+ requestId: string;
162
+ expectedSessionRevision: Revision;
163
+ configuration: AgentConfiguration;
164
+ requiredCapabilities?: AgentCapability[];
165
+ };
166
+ export type AgentSession = {
167
+ ref: AgentSessionRef;
168
+ revision: Revision;
169
+ configurationRevision: Revision;
170
+ configurationDigest: string;
171
+ nativeState: "not_created" | "available" | "missing" | "unavailable" | "unknown";
172
+ activeRun: AgentRunRef | null;
173
+ resolvedSkills: Array<{
174
+ skillId: string;
175
+ digest: string;
176
+ }>;
177
+ configuration?: AgentConfiguration;
178
+ correlation?: AgentSessionCreate["correlation"];
179
+ };
180
+ export type AgentSessionPage = {
181
+ sessions: AgentSession[];
182
+ nextCursor: string | null;
183
+ };
184
+ export type AgentAttachment = {
185
+ owner: ProviderRef;
186
+ id: string;
187
+ digest: string;
188
+ sizeBytes: number;
189
+ mediaType: string;
190
+ name?: string;
191
+ };
192
+ export type AgentAttachmentChunk = {
193
+ digest: string;
194
+ sizeBytes: number;
195
+ mediaType: string;
196
+ name?: string;
197
+ count: number;
198
+ data: string;
199
+ };
200
+ export type AgentAttachmentChunkReceipt = {
201
+ attachment: AgentAttachment | null;
202
+ received: number[];
203
+ };
204
+ export type AgentResource = {
205
+ kind: string;
206
+ id: string;
207
+ revision: string;
208
+ provider?: ProviderRef;
209
+ };
210
+ export type AgentRunInput = {
211
+ expectedSessionRevision: Revision;
212
+ configurationRevision: Revision;
213
+ continuation: "start" | "resume";
214
+ input: {
215
+ text: string;
216
+ attachments?: AgentAttachment[];
217
+ } | {
218
+ decisionResponseRef: {
219
+ runId: string;
220
+ requestId: string;
221
+ };
222
+ };
223
+ context?: AgentInstruction[];
224
+ selection?: {
225
+ model: string | null;
226
+ reasoningEffort: string | null;
227
+ };
228
+ resources?: AgentResource[];
229
+ mcp?: AgentMcpSelection;
230
+ requiredCapabilities?: AgentCapability[];
231
+ limits?: {
232
+ maxDurationMs?: number;
233
+ maxOutputTokens?: number;
234
+ maxToolCalls?: number;
235
+ };
236
+ };
237
+ export type AgentRunState = "queued" | "running" | "waiting_for_input" | "succeeded" | "failed" | "cancelled" | "unknown";
238
+ export type AgentRunPhase = "preparing" | "executing" | "waiting" | "finalizing" | "cancelling" | "parked" | "interrupted" | "terminal";
239
+ export type AgentSource = {
240
+ agentId: string;
241
+ parentAgentId?: string;
242
+ parentToolCallId?: string;
243
+ };
244
+ export type AgentPendingDecision = {
245
+ id: string;
246
+ revision: Revision;
247
+ kind: "approval" | "question";
248
+ delivery: "continue_run" | "next_turn";
249
+ source?: AgentSource;
250
+ title?: string;
251
+ toolCallId?: string;
252
+ toolName?: string;
253
+ input?: unknown;
254
+ questions?: Array<{
255
+ id: string;
256
+ text: string;
257
+ header?: string;
258
+ allowText?: boolean;
259
+ options?: Array<{
260
+ id: string;
261
+ label: string;
262
+ description?: string;
263
+ preview?: string;
264
+ }>;
265
+ multiple?: boolean;
266
+ required?: boolean;
267
+ }>;
268
+ };
269
+ export type AgentMessageBlock = {
270
+ id: string;
271
+ source?: AgentSource;
272
+ role: "assistant" | "user" | "system";
273
+ text: string;
274
+ state: "streaming" | "complete" | "interrupted";
275
+ };
276
+ export type AgentToolBlock = {
277
+ id: string;
278
+ source?: AgentSource;
279
+ name: string;
280
+ input?: unknown;
281
+ output?: string;
282
+ state: "running" | "completed" | "failed" | "cancelled" | "unknown";
283
+ truncated?: boolean;
284
+ command?: {
285
+ status: "completed" | "failed" | "cancelled" | "unknown";
286
+ exitCode?: number;
287
+ durationMs?: number;
288
+ summary?: string;
289
+ };
290
+ };
291
+ export type AgentResult = {
292
+ status: "succeeded" | "failed" | "cancelled";
293
+ messageId?: string;
294
+ text?: string;
295
+ value?: unknown;
296
+ schemaValid?: boolean;
297
+ error?: AgentErrorDetail;
298
+ };
299
+ export type AgentRunSnapshot = {
300
+ ref: AgentRunRef;
301
+ sessionId: string;
302
+ generation: string;
303
+ revision: Revision;
304
+ state: AgentRunState;
305
+ phase: AgentRunPhase;
306
+ stopConfirmed: boolean;
307
+ freshness: "current" | "last_known" | "unavailable";
308
+ observedAt: string;
309
+ configurationRevision: Revision;
310
+ lastSequence: Revision;
311
+ cursor: string;
312
+ pending: AgentPendingDecision[];
313
+ effects: {
314
+ certainty: "known" | "unknown";
315
+ unresolvedCallIds: string[];
316
+ };
317
+ result?: AgentResult;
318
+ messages?: AgentMessageBlock[];
319
+ tools?: AgentToolBlock[];
320
+ agents?: Array<AgentSource & {
321
+ state: AgentRunState;
322
+ stopConfirmed?: boolean;
323
+ }>;
324
+ selection?: {
325
+ requested: {
326
+ model: string | null;
327
+ reasoningEffort: string | null;
328
+ };
329
+ effective: {
330
+ model: string | null;
331
+ reasoningEffort: string | null;
332
+ };
333
+ };
334
+ admissionRef?: string;
335
+ coverage?: {
336
+ messages: "complete" | "truncated";
337
+ tools: "complete" | "truncated";
338
+ decisions?: "complete" | "truncated";
339
+ };
340
+ executionUsage?: {
341
+ sequence: Revision;
342
+ activeMs: number;
343
+ unknown: boolean;
344
+ };
345
+ /** Latest root context.updated observation; null usage explicitly clears it. */
346
+ latestContext?: {
347
+ sequence: Revision;
348
+ usage: Record<string, unknown> | null;
349
+ };
350
+ decisions?: Array<{
351
+ decision: AgentPendingDecision;
352
+ state: "pending" | "resolved" | "superseded" | "unknown";
353
+ response?: AgentApprovalResponse | AgentQuestionResponse;
354
+ }>;
355
+ pendingContinuations?: Array<{
356
+ requestId: string;
357
+ run: AgentRunRef;
358
+ state: "pending" | "awaiting_authorization" | "admitted" | "superseded";
359
+ }>;
360
+ };
361
+ export type AgentApprovalResponse = {
362
+ kind: "approval";
363
+ decision: "allow" | "deny";
364
+ message?: string;
365
+ };
366
+ export type AgentQuestionResponse = {
367
+ kind: "question";
368
+ answers: Record<string, string | string[]>;
369
+ };
370
+ export type AgentResponseInput = {
371
+ requestId: string;
372
+ expectedGeneration: string;
373
+ expectedRevision: Revision;
374
+ decisionId: string;
375
+ decisionRevision: Revision;
376
+ response: AgentApprovalResponse | AgentQuestionResponse;
377
+ };
378
+ export type AgentCancelInput = {
379
+ requestId: string;
380
+ } & ({
381
+ expectedGeneration: string;
382
+ expectedRevision: Revision;
383
+ fenceIfNotAdmitted?: never;
384
+ } | {
385
+ fenceIfNotAdmitted: {
386
+ sessionId: string;
387
+ startDigest: string;
388
+ };
389
+ expectedGeneration?: never;
390
+ expectedRevision?: never;
391
+ });
392
+ /** Optional execution controls share the same durable public control journal. */
393
+ export type AgentRunControlInput = {
394
+ requestId: string;
395
+ expectedGeneration: string;
396
+ expectedRevision: Revision;
397
+ } & ({
398
+ command: "park";
399
+ decisionId: string;
400
+ decisionRevision: Revision;
401
+ reason?: string;
402
+ } | {
403
+ command: "barrier";
404
+ barrierId: string;
405
+ kind: "task_adoption" | "child_wait" | "source_rebind" | "limits" | "human_input";
406
+ generation: Revision;
407
+ acknowledgedSequence: Revision;
408
+ snapshot?: string;
409
+ } | {
410
+ command: "reconcile";
411
+ stopped: true;
412
+ evidence?: string;
413
+ } | {
414
+ command: "liveConfigure";
415
+ mcp: AgentMcpSelection;
416
+ } | {
417
+ command: "mcpPolicy";
418
+ mcp: AgentMcpSelection;
419
+ } | {
420
+ command: "predictions";
421
+ enabled: boolean;
422
+ });
423
+ export type AgentControlReceipt = {
424
+ requestId: string;
425
+ state: "accepted" | "applied" | "rejected" | "superseded" | "unknown";
426
+ run: AgentRunRef;
427
+ revision: Revision;
428
+ generation?: string;
429
+ error?: AgentErrorDetail;
430
+ continuation?: {
431
+ run: AgentRunRef;
432
+ state: "pending" | "awaiting_authorization" | "admitted" | "superseded";
433
+ };
434
+ };
435
+ export type AgentEventType = "run.updated" | "session.bound" | "selection.updated" | "message.started" | "message.delta" | "message.completed" | "tool.started" | "tool.output" | "tool.completed" | "decision.requested" | "decision.updated" | "decision.resolved" | "control.updated" | "result.available" | "usage.updated" | "context.updated" | "agent.updated" | "warning" | "extension";
436
+ export type AgentEvent = {
437
+ schemaVersion: typeof AGENT_EVENT_VERSION;
438
+ runId: string;
439
+ generation: string;
440
+ sequence: Revision;
441
+ revision: Revision;
442
+ occurredAt: string;
443
+ type: AgentEventType;
444
+ source: AgentSource;
445
+ data: Record<string, unknown>;
446
+ };
447
+ export type AgentWatchItem = {
448
+ kind: "snapshot";
449
+ snapshot: AgentRunSnapshot;
450
+ } | {
451
+ kind: "event";
452
+ event: AgentEvent;
453
+ cursor: string;
454
+ };
455
+ export type AgentErrorDetail = {
456
+ code: string;
457
+ message: string;
458
+ retryable: boolean;
459
+ requestId?: string;
460
+ details?: Record<string, unknown>;
461
+ };
462
+ export declare class AgentApiError extends Error {
463
+ readonly code: string;
464
+ readonly status: number;
465
+ readonly retryable: boolean;
466
+ readonly details?: Record<string, unknown> | undefined;
467
+ readonly requestId?: string | undefined;
468
+ constructor(code: string, message: string, status: number, retryable?: boolean, details?: Record<string, unknown> | undefined, requestId?: string | undefined);
469
+ }
470
+ export type AgentOperation = "capabilities" | "connections.list" | "connections.models" | "connections.usage" | "attachments.write" | "sessions.create" | "sessions.configure" | "sessions.read" | "sessions.list" | "runs.start" | "runs.read" | "runs.events" | "runs.respond" | "runs.cancel" | "runs.control" | "runs.controls.read";
471
+ /** Core transport names for the optional consumer-bound task workflow, without general Core tools. */
472
+ export declare const AGENT_SESSION_WORKFLOW_TOOLS: readonly ["task_executor_options", "task_options", "task_list", "task_get", "task_create", "task_edit", "task_action", "task_result", "task_fail", "task_request_input", "task_adopt", "task_prepare_executor", "task_delegate", "task_wait", "task_plan", "task_bind_workspace", "task_execution_get"];
473
+ /** Optional business workflow owned by the invoking consumer, separate from native execution. */
474
+ export type AgentSessionWorkflowTool = typeof AGENT_SESSION_WORKFLOW_TOOLS[number];
475
+ export type AgentSessionWorkflowBinding = {
476
+ executor: ProviderRef;
477
+ sessionId: string;
478
+ tools?: AgentSessionWorkflowTool[];
479
+ policy?: AgentMcpPolicy;
480
+ };
481
+ /** Public provider identities carried by exact Core mediation; never native engine IDs. */
482
+ export type AgentExecutionReference = {
483
+ provider: AgentProviderRef;
484
+ sessionId: string;
485
+ runId: string;
486
+ };
487
+ export type AgentSessionWorkflowRequest = {
488
+ action: string;
489
+ input: Record<string, unknown>;
490
+ agent: AgentExecutionReference;
491
+ source?: ProviderRef;
492
+ };
493
+ export type AgentAuthorizationRequest = {
494
+ operation: AgentOperation;
495
+ method: "GET" | "PUT" | "POST";
496
+ path: string;
497
+ bodyHash: string;
498
+ resources?: AgentResource[];
499
+ sessionId?: string;
500
+ runId?: string;
501
+ configurationDigest?: string;
502
+ ceiling?: {
503
+ mcp?: AgentMcpSelection;
504
+ resources?: AgentResource[];
505
+ deadline?: string;
506
+ configurationRevision?: Revision;
507
+ workflow?: AgentSessionWorkflowBinding;
508
+ };
509
+ };
510
+ export type AgentOperationAuthorization = {
511
+ provider: AgentProviderRef;
512
+ baseUrl: string;
513
+ token: string;
514
+ expiresAt: string;
515
+ admissionRef?: string;
516
+ };
517
+ export type AgentAuthorizer = (request: AgentAuthorizationRequest, signal?: AbortSignal) => Promise<AgentOperationAuthorization>;
518
+ /** Persist this value before a mutation; body is the exact UTF-8 JSON string used on every retry. */
519
+ export type AgentPreparedRequest<T = unknown> = AgentAuthorizationRequest & {
520
+ body: string;
521
+ readonly __result?: T;
522
+ };
package/dist/agent.js ADDED
@@ -0,0 +1,34 @@
1
+ export const AGENT_API_VERSION = 1;
2
+ export const AGENT_EVENT_VERSION = "agent-event.1";
3
+ export const AGENT_CAPABILITIES = {
4
+ resume: "session.resume", configuration: "configuration.resume-compatible", images: "input.images",
5
+ noNativeTools: "native-tools.none", skills: "skills.catalog", exclusiveSkills: "skills.exclusive-selection",
6
+ coreMcp: "mcp.core", externalMcp: "mcp.external", modelChange: "model.change-on-resume",
7
+ nextTurnDecisions: "decisions.next-turn", nativeSubagents: "subagents.native", park: "runs.park",
8
+ barrier: "runs.barrier", reconcile: "runs.reconcile", liveConfigure: "runs.live-configure",
9
+ predictions: "predictions", connectionUsage: "connections.usage",
10
+ approvalMode: "configuration.approval-mode",
11
+ mcpPolicy: "mcp.policy-update", consumerWorkflow: "workflow.consumer",
12
+ };
13
+ export class AgentApiError extends Error {
14
+ code;
15
+ status;
16
+ retryable;
17
+ details;
18
+ requestId;
19
+ constructor(code, message, status, retryable = false, details, requestId) {
20
+ super(message);
21
+ this.code = code;
22
+ this.status = status;
23
+ this.retryable = retryable;
24
+ this.details = details;
25
+ this.requestId = requestId;
26
+ this.name = "AgentApiError";
27
+ }
28
+ }
29
+ /** Core transport names for the optional consumer-bound task workflow, without general Core tools. */
30
+ export const AGENT_SESSION_WORKFLOW_TOOLS = [
31
+ "task_executor_options", "task_options", "task_list", "task_get", "task_create", "task_edit", "task_action",
32
+ "task_result", "task_fail", "task_request_input", "task_adopt", "task_prepare_executor", "task_delegate",
33
+ "task_wait", "task_plan", "task_bind_workspace", "task_execution_get",
34
+ ];
@@ -39,7 +39,12 @@ export declare class ProviderClient {
39
39
  signal?: AbortSignal; /** Total deadline, 1–930000 ms; defaults to five minutes. */
40
40
  timeoutMs?: number;
41
41
  }): Promise<SpeechResult>;
42
- translationCapabilities(provider: Pick<ProviderDescriptor, "appId" | "key">, signal?: AbortSignal): Promise<TranslationCapabilities>;
42
+ translationCapabilities(provider: Pick<ProviderDescriptor, "appId" | "key">, signal?: AbortSignal, options?: {
43
+ connection: {
44
+ id: string;
45
+ revision: string;
46
+ };
47
+ }): Promise<TranslationCapabilities>;
43
48
  /** Translate text or Markdown through the explicitly selected provider; never retries or falls back. */
44
49
  translate(provider: Pick<ProviderDescriptor, "appId" | "key">, input: TranslationRequest, signal?: AbortSignal): Promise<TranslationResult>;
45
50
  /** User-attributed requests preserve the assistant's existing handoff and dispatch policy. */
@@ -92,9 +92,18 @@ export class ProviderClient {
92
92
  await dispatcher.close();
93
93
  }
94
94
  }
95
- async translationCapabilities(provider, signal) {
95
+ async translationCapabilities(provider, signal, options) {
96
+ const connection = options?.connection;
97
+ if (options && (!connection || typeof connection.id !== "string" || !connection.id || connection.id.length > 200
98
+ || /[\u0000-\u001f\u007f]/.test(connection.id) || typeof connection.revision !== "string" || !/^(0|[1-9][0-9]{0,19})$/.test(connection.revision)))
99
+ throw new ProviderError("translation_connection_invalid", "Select an exact provider connection and decimal revision.", 400);
96
100
  const binding = await this.connect({ ...provider, kind: "translation" }, signal);
97
- return read(await fetch(`${binding.url}/capabilities`, { redirect: "error", signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(10_000)]) : AbortSignal.timeout(10_000), headers: { authorization: `Bearer ${binding.token}` } }));
101
+ const url = new URL(`${binding.url}/capabilities`);
102
+ if (connection) {
103
+ url.searchParams.set("connectionId", connection.id);
104
+ url.searchParams.set("connectionRevision", connection.revision);
105
+ }
106
+ return read(await fetch(url.href, { redirect: "error", signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(10_000)]) : AbortSignal.timeout(10_000), headers: { authorization: `Bearer ${binding.token}` } }));
98
107
  }
99
108
  /** Translate text or Markdown through the explicitly selected provider; never retries or falls back. */
100
109
  async translate(provider, input, signal) {
@@ -142,6 +151,13 @@ export class ProviderClient {
142
151
  if (invocation.version !== 2 || invocation.kind !== kind || invocation.key !== key || invocation.operation !== request.operation
143
152
  || !invocation.userId || !invocation.principalId || !Array.isArray(invocation.resourceIds))
144
153
  throw new ProviderError("token_invalid", "Core returned an invalid mediated invocation.", 401);
154
+ const execution = invocation.agentExecution;
155
+ const identity = (value) => typeof value === "string" && value.length > 0 && value.length <= 512
156
+ && value.trim() === value && !/[\u0000-\u001f\u007f]/.test(value);
157
+ if (request.operation === "session.workflow" && (kind !== "task-executor" || !execution)
158
+ || execution && (!identity(execution.sessionId) || !identity(execution.runId)
159
+ || !execution.provider || !identity(execution.provider.appId) || !identity(execution.provider.installationId) || !identity(execution.provider.key)))
160
+ throw new ProviderError("token_invalid", "Core returned an invalid admitted agent workflow binding.", 401);
145
161
  return invocation;
146
162
  }
147
163
  /** Provider-side validation checks live grants on every request; never cache this result. */
@@ -1,5 +1,5 @@
1
1
  /** Provider categories supported by Core. Task execution does not expose model/profile configuration. */
2
- export type ProviderKind = "speech-to-text" | "assistant" | "translation" | "tasks" | "task-executor" | "conversation-history" | "agent-sessions";
2
+ export type ProviderKind = "agent" | "speech-to-text" | "assistant" | "translation" | "tasks" | "task-executor" | "conversation-history" | "agent-sessions";
3
3
  export type ProviderDescriptor = {
4
4
  appId: string;
5
5
  displayName: string;
@@ -38,6 +38,8 @@ export type ProviderInvocation = {
38
38
  };
39
39
  /** Core-mediated v2 invocations carry the original principal; direct clients have no app identity. */
40
40
  export type MediatedProviderInvocation = {
41
+ /** Present for exact session.workflow requests under retained admitted agent authority. */
42
+ agentExecution?: import("./agent.js").AgentExecutionReference;
41
43
  taskWorkflow?: TaskWorkflowBinding;
42
44
  version: 2;
43
45
  callerAppId: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hosty-sdk/app",
3
- "version": "0.47.0",
3
+ "version": "0.48.0",
4
4
  "description": "Hosty app auth: session state machine, recovery bridge, Core revalidation, and the embedder responder.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -153,6 +153,22 @@
153
153
  "types": "./dist/agent-sessions.d.ts",
154
154
  "default": "./dist/agent-sessions.js"
155
155
  },
156
+ "./agent": {
157
+ "types": "./dist/agent.d.ts",
158
+ "default": "./dist/agent.js"
159
+ },
160
+ "./agent/client": {
161
+ "types": "./dist/agent-client.d.ts",
162
+ "default": "./dist/agent-client.js"
163
+ },
164
+ "./agent/server": {
165
+ "types": "./dist/agent-server.d.ts",
166
+ "default": "./dist/agent-server.js"
167
+ },
168
+ "./agent/schemas": {
169
+ "types": "./dist/agent-schemas.d.ts",
170
+ "default": "./dist/agent-schemas.js"
171
+ },
156
172
  "./history": {
157
173
  "types": "./dist/history.d.ts",
158
174
  "default": "./dist/history.js"
@@ -176,12 +192,12 @@
176
192
  },
177
193
  "dependencies": {
178
194
  "@noble/hashes": "^2.4.0",
179
- "lucide-react": "^1.55.0",
195
+ "lucide-react": "^1.70.0",
180
196
  "server-only": "^0.0.1",
181
- "undici": "^8.12.3"
197
+ "undici": "^8.12.4"
182
198
  },
183
199
  "peerDependencies": {
184
- "next": "^16.4.0",
200
+ "next": "^16.4.5",
185
201
  "react": "^19.2.8",
186
202
  "react-dom": "^19.2.8"
187
203
  },
@@ -201,11 +217,11 @@
201
217
  "@types/react": "^19.3.0",
202
218
  "@types/react-dom": "^19.3.0",
203
219
  "jsdom": "^30.1.2",
204
- "react": "^19.3.0",
205
- "react-dom": "^19.3.0",
220
+ "react": "^19.3.1",
221
+ "react-dom": "^19.3.1",
206
222
  "typescript": "^6",
207
- "vitest": "^5.0.3",
208
- "vite": "^8.3.5"
223
+ "vite": "^8.3.7",
224
+ "vitest": "^5.1.0"
209
225
  },
210
226
  "repository": {
211
227
  "type": "git",
@@ -214,6 +230,7 @@
214
230
  },
215
231
  "files": [
216
232
  "dist",
233
+ "schemas",
217
234
  "README.md"
218
235
  ],
219
236
  "sideEffects": false,