mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* Revert "fix terminal attribution shim removal edge cases (#14187)"
This reverts 585dd6d3a9. Re-landed in the next commit without the host capability gate. Nothing shipped with it, so no migration constraint.
* rm git shim: neutralize stale wrappers without a host gate
Re-lands the cleanup half of #14187: pass-through tombstones for retained wrapper paths, env/PATH scrubbing at every spawn owner, and the retired setting drop.
Only writes tombstones when the legacy directory already exists, so a clean install no longer has it created. Leaves out the terminal.attribution-removed.v1 capability gate: the tombstone neutralizes each host locally, so refusing terminal create/split against older hosts denied service without adding cleanup.
* rm git shim: surface neutralization failures and fix rollback marker
Readiness review follow-ups: warn on each failed attempt and on give-up (was silent and undiagnosable); write a VERSION marker distinct from the retired shim's '7' so a rolled-back build rewrites its own wrappers; clear a captured ORCA_REAL_* path that no longer exists so the cmd wrapper's where.exe fallback can run; stop a locked temp file masking the real error. Adds retry-exhaustion coverage.
* rm git shim: pin the cmd fallback order and correct the give-up count
Round-2 review follow-ups: string-pin that a stale ORCA_REAL_* is cleared before the where.exe fallback, and count the initial attempt in the give-up warning so it agrees with the per-attempt line.
* rm git shim: keep the split-failure toast
The revert took a toast that #14187 added alongside the gate but which stands on its own: without it a failed remote split only reaches the console and the pane silently never appears. Also pins attempt ordinals in the retry-exhaustion test.
89 lines
3.6 KiB
TypeScript
89 lines
3.6 KiB
TypeScript
import {
|
|
JsonStringifyByteLimitError,
|
|
stringifyJsonWithinByteLimit
|
|
} from './node-bounded-json-stringify'
|
|
import { RemoteRuntimeClientError } from './remote-runtime-client-error'
|
|
import type { RuntimeOrchestrationEnvelope } from './runtime-rpc-envelope'
|
|
|
|
export const REMOTE_RUNTIME_MAX_OUTBOUND_JSON_BYTES = 4 * 1024 * 1024
|
|
export const REMOTE_RUNTIME_MAX_WEBSOCKET_FRAME_BYTES = 8 * 1024 * 1024 + 64
|
|
export const REMOTE_RUNTIME_MAX_SUBSCRIPTIONS = 256
|
|
export const REMOTE_RUNTIME_MAX_SUBSCRIPTION_PARAM_BYTES = 1024 * 1024
|
|
export const REMOTE_RUNTIME_MAX_RETAINED_SUBSCRIPTION_BYTES = 16 * 1024 * 1024
|
|
export const REMOTE_RUNTIME_MAX_PENDING_REQUESTS = 256
|
|
export const REMOTE_RUNTIME_MAX_PENDING_RPC_BYTES = 32 * 1024 * 1024
|
|
export const REMOTE_RUNTIME_MAX_PREPARED_RPC_BYTES = REMOTE_RUNTIME_MAX_PENDING_RPC_BYTES
|
|
export const REMOTE_RUNTIME_MAX_PROCESS_PENDING_REQUESTS = REMOTE_RUNTIME_MAX_PENDING_REQUESTS * 2
|
|
export const REMOTE_RUNTIME_MAX_PROCESS_PENDING_RPC_BYTES = REMOTE_RUNTIME_MAX_PENDING_RPC_BYTES * 2
|
|
export const REMOTE_RUNTIME_MAX_READY_WAITERS =
|
|
REMOTE_RUNTIME_MAX_PENDING_REQUESTS + REMOTE_RUNTIME_MAX_SUBSCRIPTIONS
|
|
export const REMOTE_RUNTIME_MAX_OUTBOUND_BINARY_FRAME_BYTES = 8 * 1024 * 1024
|
|
|
|
export function serializeRemoteRuntimePayload(value: unknown): string {
|
|
try {
|
|
return stringifyJsonWithinByteLimit(value, REMOTE_RUNTIME_MAX_OUTBOUND_JSON_BYTES).serialized
|
|
} catch (error) {
|
|
if (error instanceof JsonStringifyByteLimitError) {
|
|
throw new RemoteRuntimeClientError(
|
|
'invalid_argument',
|
|
`Remote runtime JSON payload exceeds ${REMOTE_RUNTIME_MAX_OUTBOUND_JSON_BYTES} bytes.`
|
|
)
|
|
}
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
throw new RemoteRuntimeClientError(
|
|
'invalid_argument',
|
|
`Remote runtime JSON payload could not be serialized: ${message}`
|
|
)
|
|
}
|
|
}
|
|
|
|
export function measureRemoteRuntimeSubscriptionParams(params: unknown): number {
|
|
if (params === undefined) {
|
|
return 0
|
|
}
|
|
try {
|
|
return stringifyJsonWithinByteLimit(params, REMOTE_RUNTIME_MAX_SUBSCRIPTION_PARAM_BYTES)
|
|
.byteLength
|
|
} catch (error) {
|
|
if (error instanceof JsonStringifyByteLimitError) {
|
|
throw new RemoteRuntimeClientError(
|
|
'invalid_argument',
|
|
`Remote runtime subscription parameters exceed ${REMOTE_RUNTIME_MAX_SUBSCRIPTION_PARAM_BYTES} bytes.`
|
|
)
|
|
}
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
throw new RemoteRuntimeClientError(
|
|
'invalid_argument',
|
|
`Remote runtime subscription parameters could not be serialized: ${message}`
|
|
)
|
|
}
|
|
}
|
|
|
|
export function serializeRemoteRuntimeRpcRequest(args: {
|
|
requestId: string
|
|
deviceToken: string
|
|
method: string
|
|
params: unknown
|
|
envelope?: RuntimeOrchestrationEnvelope
|
|
}): string {
|
|
return serializeRemoteRuntimePayload({
|
|
id: args.requestId,
|
|
deviceToken: args.deviceToken,
|
|
method: args.method,
|
|
params: args.params,
|
|
orchestrationCapability: args.envelope?.orchestrationCapability,
|
|
orchestrationContractVersion: args.envelope?.orchestrationContractVersion,
|
|
orchestrationRequestId: args.envelope?.orchestrationRequestId,
|
|
compatibilityInvocationId: args.envelope?.compatibilityInvocationId,
|
|
orchestrationCompatibilityEvidence: args.envelope?.orchestrationCompatibilityEvidence
|
|
})
|
|
}
|
|
|
|
export function retainedRemoteRuntimeJsonStringBytes(value: string): number {
|
|
return value.length * 3
|
|
}
|
|
|
|
export function isRemoteRuntimeBinaryFrameWithinLimit(bytes: Uint8Array<ArrayBufferLike>): boolean {
|
|
return bytes.byteLength <= REMOTE_RUNTIME_MAX_OUTBOUND_BINARY_FRAME_BYTES
|
|
}
|