Import packages/protocol/src/index.ts
This commit is contained in:
parent
65bef795b1
commit
2262755bab
|
|
@ -1,3 +1,26 @@
|
|||
export { LAN_UPLOAD_CAPABILITY, LAN_UPLOAD_MIN_BYTES, LAN_UPLOAD_TICKET_MS, LAN_UPLOAD_CONNECT_MS, lanUploadScopeSchema, lanUploadRequestSchema, lanUploadOfferSchema, isLanUploadAddress, validateLanUploadOffer, createLanUploadPrologue, type LanUploadOffer } from './lan-upload.js'
|
||||
export {
|
||||
TRANSPORT_UPGRADE_CAPABILITY,
|
||||
UPGRADE_SEQUENCE_HEADER_BYTES,
|
||||
MAX_REORDER_BUFFERED_FRAMES,
|
||||
MAX_REORDER_BUFFERED_BYTES,
|
||||
DEFAULT_REORDER_GAP_TIMEOUT_MS,
|
||||
DEFAULT_PREVIOUS_LEG_DRAIN_MS,
|
||||
transportUpgradeCandidateSchema,
|
||||
transportUpgradeOfferSchema,
|
||||
transportUpgradeIceSchema,
|
||||
transportUpgradeActivateSchema,
|
||||
transportUpgradeDrainSchema,
|
||||
transportUpgradeAbortSchema,
|
||||
transportTierRank,
|
||||
wireFromTransportTier,
|
||||
wrapUpgradedTransportFrame,
|
||||
unwrapUpgradedTransportFrame,
|
||||
SequencedCiphertextReorderBuffer,
|
||||
type TransportTier,
|
||||
} from './transport-upgrade.js'
|
||||
import { encodeBinaryUpload, decodeBinaryUpload } from './binary-upload.js'
|
||||
export { BINARY_UPLOAD_CAPABILITY, BINARY_UPLOAD_CHUNK_BYTES } from './binary-upload.js'
|
||||
export * from './loopback.js'
|
||||
import { parseWireJson } from './wire-json.js'
|
||||
export { parseWireJson } from './wire-json.js'
|
||||
|
|
@ -147,8 +170,10 @@ export const controlFrameTypes = [
|
|||
] as const
|
||||
|
||||
export const rpcMethods = [
|
||||
'workspace.upload.lan.open',
|
||||
'workspace.upload.open',
|
||||
'workspace.upload.chunk',
|
||||
'workspace.upload.chunk.binary',
|
||||
'workspace.upload.commit',
|
||||
'workspace.upload.abort',
|
||||
'harness.transport.describe',
|
||||
|
|
@ -170,6 +195,9 @@ export const rpcMethods = [
|
|||
'harness.remote.transfer.close',
|
||||
'harness.remote.stream.open',
|
||||
'harness.remote.stream.close',
|
||||
'harness.remote.compaction.submit',
|
||||
'harness.remote.compaction.status',
|
||||
'harness.remote.compaction.cancel',
|
||||
'loopback.call',
|
||||
'fileviewer.call',
|
||||
'codex.app.call',
|
||||
|
|
@ -213,6 +241,7 @@ export const remoteEvents = [
|
|||
'acp.session.update',
|
||||
'acp.session.request_permission',
|
||||
'acp.session.closed',
|
||||
'remote.transport.upgrade.ice',
|
||||
] as const
|
||||
|
||||
export const errorCodes = [
|
||||
|
|
@ -493,7 +522,10 @@ export const transportCapabilities = [
|
|||
*/
|
||||
export const harnessCapabilityValues = [
|
||||
'remote.history.compact.v1',
|
||||
'remote.compaction.async.v1',
|
||||
'remote.session.events.v1',
|
||||
'workspace.upload.v1',
|
||||
'workspace.upload.binary.v1',
|
||||
'harness.api.v1',
|
||||
'harness.api.transfer.v1',
|
||||
'harness.remote.v1',
|
||||
|
|
@ -725,6 +757,67 @@ export interface HarnessRemoteStreamClosedData {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote-owned asynchronous compaction contract.
|
||||
*
|
||||
* Harness `commands/execute('/compact')` legitimately waits for the whole
|
||||
* summarization, which can take minutes on slow local inference backends. The
|
||||
* Remote bridge therefore registers the operation on the Host and returns
|
||||
* immediately; the command keeps running on the Host runtime even when the
|
||||
* submitting client disconnects. Clients observe the operation through
|
||||
* `harness.remote.compaction.status` and the ordinary Session event stream.
|
||||
*
|
||||
* Every result is settled by the Host's own background call: a
|
||||
* `compaction/end` event never fabricates success.
|
||||
*/
|
||||
export const REMOTE_COMPACTION_CAPABILITY = 'remote.compaction.async.v1'
|
||||
export const REMOTE_SESSION_EVENTS_CAPABILITY = 'remote.session.events.v1'
|
||||
|
||||
/** Operation states visible to Remote clients. */
|
||||
export type RemoteCompactionState =
|
||||
| 'accepted'
|
||||
| 'running'
|
||||
| 'cancelling'
|
||||
| 'succeeded'
|
||||
| 'failed'
|
||||
| 'cancelled'
|
||||
| 'interrupted'
|
||||
/** The run committed, but cancellation/timing hid the final persistence result. */
|
||||
| 'unconfirmed'
|
||||
|
||||
export interface RemoteCompactionSubmitParams {
|
||||
sessionId: string
|
||||
/** Client-chosen idempotency key; retrying the same id never starts a second run. */
|
||||
requestId: string
|
||||
/**
|
||||
* Wall-clock budget for the compaction task itself, independent of any RPC
|
||||
* deadline. Hosts clamp it to [60_000, 7_200_000]; the default is 30 minutes.
|
||||
*/
|
||||
budgetMs?: number
|
||||
}
|
||||
|
||||
export interface RemoteCompactionSubmitResult {
|
||||
operationId: string
|
||||
state: RemoteCompactionState
|
||||
}
|
||||
|
||||
export interface RemoteCompactionStatusParams {
|
||||
sessionId: string
|
||||
operationId: string
|
||||
}
|
||||
|
||||
export interface RemoteCompactionStatusResult {
|
||||
operationId: string
|
||||
sessionId: string
|
||||
state: RemoteCompactionState
|
||||
/** Epoch ms when the Host accepted the operation; absent when the Host lost it. */
|
||||
acceptedAt?: number
|
||||
startedAt?: number
|
||||
finishedAt?: number
|
||||
/** Human-readable outcome detail; never a substituted success. */
|
||||
message?: string
|
||||
}
|
||||
|
||||
export interface RemoteWorkspaceTypeDescription {
|
||||
id: string
|
||||
name: string
|
||||
|
|
@ -1353,11 +1446,11 @@ function parseRelayDataFrame(input: unknown): RelayDataFrame {
|
|||
}
|
||||
|
||||
export function encodeMessage(message: RemoteMessage): Uint8Array {
|
||||
return new TextEncoder().encode(JSON.stringify(message))
|
||||
return encodeBinaryUpload(message) ?? new TextEncoder().encode(JSON.stringify(message))
|
||||
}
|
||||
|
||||
export function decodeMessage(data: Uint8Array | string): RemoteMessage {
|
||||
return parseRemoteMessage(parseWireJson(data))
|
||||
return parseRemoteMessage(decodeBinaryUpload(data) ?? parseWireJson(data))
|
||||
}
|
||||
|
||||
interface FragmentAssembly {
|
||||
|
|
|
|||
Loading…
Reference in New Issue