@byok-sdk/server 0.17.0 → 0.18.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Hono } from 'hono';
2
- import { type PairingCodeInfo } from '@byok-sdk/cloud';
3
- import { type AgentRef } from '@byok-sdk/protocol';
2
+ import { type EnqueuedOffer, type PairingCodeInfo, type TaskAttempt } from '@byok-sdk/cloud';
3
+ import { type AgentRef, type AgentMessagePublishPayload, type AgentMessageDispositionPayload } from '@byok-sdk/protocol';
4
4
  import type { MailboxRetentionInput, MailboxRetentionResult } from '@byok-sdk/core';
5
5
  import type { ByokServerEvent, AgentContentReadRequest, AgentHomeProjectionRequest, AgentHomeProjectionStatusReadback, AgentEgressReceipt, CreateByokServerOptions, DispatchInput, FreshAgentEgressDispatchInput, HubStats, MachineInfo, TaskHandle, TaskSnapshot } from './types';
6
6
  export type { ByokServerEvent, AgentContentReadRequest, AgentHomeProjectionRequest, AgentHomeProjectionStatusReadback, AgentEgressReceipt, ByokServerStorage, CreateByokServerOptions, DispatchInput, FreshAgentEgressDispatchInput, HubStats, MachineInfo, ServerTaskEvent, TaskHandle, TaskResult, TaskSnapshot, } from './types';
@@ -82,6 +82,10 @@ export interface ByokServer {
82
82
  /** Mint a single-use pairing code for this server's product and tenant (docs/protocol.md §6.1). */
83
83
  createPairingCode(input: CreatePairingCodeInput): Promise<PairingCodeInfo>;
84
84
  };
85
+ /** Durable recurring submission; no TaskHandle is needed to recover after restart. */
86
+ recurring: {
87
+ submit(input: import('@byok-sdk/cloud').RecurringExecutionInput): Promise<EnqueuedOffer>;
88
+ };
85
89
  dispatch(input: DispatchInput): Promise<TaskHandle>;
86
90
  /** Dispatch a fresh Agent execution whose runtime will mint its session after start. */
87
91
  dispatchFreshAgentEgress(input: FreshAgentEgressDispatchInput): Promise<TaskHandle>;
@@ -92,9 +96,17 @@ export interface ByokServer {
92
96
  /** Durable desired-state and terminal-outcome readback for one exact device-and-Agent request. */
93
97
  readAgentHomeProjection(deviceId: string, agentRef: AgentRef, requestId: string): Promise<AgentHomeProjectionStatusReadback | undefined>;
94
98
  tasks: {
99
+ /** Canonical durable attempt, including cancellation intent; not a resource-release observation. */
100
+ attempt(taskId: string): Promise<TaskAttempt | undefined>;
95
101
  get(taskId: string): Promise<TaskSnapshot | undefined>;
102
+ /** Actual device terminal, independently of Host cancellation or home release. */
103
+ deviceTerminal(taskId: string): Promise<import('@byok-sdk/cloud').DeviceTerminal | undefined>;
96
104
  /** Immutable kernel offer readback for verifying a persisted host binding. No transport seq is inferred. */
97
105
  offer(taskId: string): Promise<import('@byok-sdk/cloud').TaskOfferReadback | undefined>;
106
+ /** Discover the unique message and its pending/final disposition through the frozen Agent binding. */
107
+ agentMessage(taskId: string, deviceId: string, agentRef: AgentRef): Promise<import('@byok-sdk/cloud').TaskAgentMessage | undefined>;
108
+ /** Exact SDK message decision; pending is undefined and corrupt persisted evidence throws. */
109
+ messageDisposition(taskId: string, deviceId: string, payload: AgentMessagePublishPayload): Promise<AgentMessageDispositionPayload | undefined>;
98
110
  /** Request cancellation through the kernel without a process-owned TaskHandle. */
99
111
  cancel(taskId: string, reason?: string): Promise<void>;
100
112
  /**
package/dist/index.js CHANGED
@@ -1174,6 +1174,20 @@ var SqliteTaskAttemptStore = class {
1174
1174
  return "reserved";
1175
1175
  });
1176
1176
  }
1177
+ readTaskAgentMessage(tenant, input) {
1178
+ return this.coordinator.run((db) => {
1179
+ if (readTask(db, tenant, input.taskId)?.deviceId !== input.deviceId) return void 0;
1180
+ const row = db.prepare(
1181
+ `SELECT message_id, payload_body, terminal_body FROM agent_message_admission
1182
+ WHERE tenant_id = ? AND task_id = ?`
1183
+ ).get(tenant, input.taskId);
1184
+ return row === void 0 ? void 0 : {
1185
+ messageId: row.message_id,
1186
+ payloadBody: row.payload_body,
1187
+ ...row.terminal_body === null ? {} : { terminalBody: row.terminal_body }
1188
+ };
1189
+ });
1190
+ }
1177
1191
  readAgentMessage(tenant, input) {
1178
1192
  return this.coordinator.run((db) => {
1179
1193
  const attempt = readTask(db, tenant, input.taskId);
@@ -2311,10 +2325,25 @@ function createByokServer(opts) {
2311
2325
  projectionHash: desired.projectionHash
2312
2326
  });
2313
2327
  },
2328
+ recurring: { submit(input) {
2329
+ return cloud.submitRecurringExecution(tenant, input);
2330
+ } },
2314
2331
  tasks: {
2332
+ attempt(taskId) {
2333
+ return cloud.readTaskAttempt(tenant, taskId);
2334
+ },
2335
+ deviceTerminal(taskId) {
2336
+ return cloud.readDeviceTerminal(tenant, taskId);
2337
+ },
2315
2338
  offer(taskId) {
2316
2339
  return cloud.readTaskOffer(tenant, taskId);
2317
2340
  },
2341
+ agentMessage(taskId, deviceId, agentRef) {
2342
+ return cloud.readTaskAgentMessage(tenant, deviceId, taskId, agentRef);
2343
+ },
2344
+ messageDisposition(taskId, deviceId, payload) {
2345
+ return cloud.readAgentMessageDisposition(tenant, deviceId, taskId, payload);
2346
+ },
2318
2347
  async cancel(taskId, reason) {
2319
2348
  const attempt = await cloud.cancelTask(tenant, taskId, reason);
2320
2349
  if (attempt.cancellation !== void 0) {