Files
wehub-resource-sync e0e362d700
SDK Tests / changes (push) Successful in 2m29s
Real E2E Tests / changes (push) Successful in 2m29s
Deploy Docs Pages / build (push) Has been cancelled
Deploy Docs Pages / deploy (push) Has been cancelled
Real E2E Tests / JavaScript E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Python E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Java E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / C# E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Go E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Real E2E CI (push) Has been cancelled
SDK Tests / SDK CI (push) Has been cancelled
SDK Tests / CLI Tests (push) Has been cancelled
SDK Tests / Python SDK Quality (code-interpreter) (push) Has been cancelled
SDK Tests / Python SDK Quality (sandbox) (push) Has been cancelled
SDK Tests / Python SDK Tests (code-interpreter) (push) Has been cancelled
SDK Tests / JavaScript SDK Quality And Tests (code-interpreter) (push) Has been cancelled
SDK Tests / JavaScript SDK Quality And Tests (sandbox) (push) Has been cancelled
SDK Tests / Python SDK Tests (sandbox) (push) Has been cancelled
SDK Tests / CLI Quality (push) Has been cancelled
SDK Tests / Kotlin SDK Quality And Tests (sandbox) (push) Has been cancelled
SDK Tests / Kotlin SDK Quality And Tests (code-interpreter) (push) Has been cancelled
SDK Tests / C# SDK Quality And Tests (code-interpreter) (push) Has been cancelled
SDK Tests / C# SDK Quality And Tests (sandbox) (push) Has been cancelled
SDK Tests / Go SDK Quality And Tests (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:33 +08:00

63 lines
2.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright 2025 Alibaba Group Holding Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package model
// ClientFrame is a JSON frame sent from the WebSocket client to the server.
type ClientFrame struct {
Type string `json:"type"`
Data string `json:"data,omitempty"`
Cols int `json:"cols,omitempty"`
Rows int `json:"rows,omitempty"`
Signal string `json:"signal,omitempty"`
}
// ServerFrame is a JSON frame sent from the server to the WebSocket client.
type ServerFrame struct {
Type string `json:"type"`
SessionID string `json:"session_id,omitempty"`
Mode string `json:"mode,omitempty"`
Data string `json:"data,omitempty"`
Offset int64 `json:"offset,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
Error string `json:"error,omitempty"`
Code string `json:"code,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
}
// Binary WebSocket frame type bytes — prefix byte for all binary frames.
const (
BinStdin byte = 0x00 // Client → Server: raw stdin bytes
BinStdout byte = 0x01 // Server → Client: raw stdout bytes
BinStderr byte = 0x02 // Server → Client: raw stderr bytes (pipe mode)
BinReplay byte = 0x03 // Server → Client: [8 bytes int64 BE offset][raw bytes]
)
// WebSocket error codes sent in ServerFrame.Code.
const (
WSErrCodeSessionGone = "SESSION_GONE"
WSErrCodeStartFailed = "START_FAILED"
WSErrCodeStdinWriteFailed = "STDIN_WRITE_FAILED"
WSErrCodeInvalidFrame = "INVALID_FRAME"
WSErrCodeAlreadyConnected = "ALREADY_CONNECTED"
WSErrCodeTakenOver = "TAKEN_OVER"
WSErrCodeRuntimeError = "RUNTIME_ERROR"
)
// WSCloseTakenOver is the WebSocket close code sent to a client whose session was
// taken over by another client (via ?takeover=1). It lives in the application-private
// range (40004999, RFC 6455 §7.4.2) so clients can distinguish an intentional
// handoff from a network drop and avoid auto-reconnecting into the new holder.
const WSCloseTakenOver = 4001