Files
admin 875c7f9b91 feat: Complete zCode CLI X with Telegram bot integration
- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
2026-05-05 09:01:26 +00:00

64 lines
2.1 KiB
JavaScript

/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
import { hrTimeToNanoseconds } from '@opentelemetry/core';
import { hexToBinary } from './hex-to-binary';
export function hrTimeToNanos(hrTime) {
const NANOSECONDS = BigInt(1000000000);
return (BigInt(Math.trunc(hrTime[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime[1])));
}
export function toLongBits(value) {
const low = Number(BigInt.asUintN(32, value));
const high = Number(BigInt.asUintN(32, value >> BigInt(32)));
return { low, high };
}
export function encodeAsLongBits(hrTime) {
const nanos = hrTimeToNanos(hrTime);
return toLongBits(nanos);
}
export function encodeAsString(hrTime) {
const nanos = hrTimeToNanos(hrTime);
return nanos.toString();
}
const encodeTimestamp = typeof BigInt !== 'undefined' ? encodeAsString : hrTimeToNanoseconds;
function identity(value) {
return value;
}
function optionalHexToBinary(str) {
if (str === undefined)
return undefined;
return hexToBinary(str);
}
/**
* Encoder for protobuf format.
* Uses { high, low } timestamps and binary for span/trace IDs, leaves Uint8Array attributes as-is.
*/
export const PROTOBUF_ENCODER = {
encodeHrTime: encodeAsLongBits,
encodeSpanContext: hexToBinary,
encodeOptionalSpanContext: optionalHexToBinary,
encodeUint8Array: identity,
};
/**
* Encoder for JSON format.
* Uses string timestamps, hex for span/trace IDs, and base64 for Uint8Array.
*/
export const JSON_ENCODER = {
encodeHrTime: encodeTimestamp,
encodeSpanContext: identity,
encodeOptionalSpanContext: identity,
encodeUint8Array: (bytes) => {
if (typeof Buffer !== 'undefined') {
return Buffer.from(bytes).toString('base64');
}
// implementation note: not using spread operator and passing to
// btoa to avoid stack overflow on large Uint8Arrays
const chars = new Array(bytes.length);
for (let i = 0; i < bytes.length; i++) {
chars[i] = String.fromCharCode(bytes[i]);
}
return btoa(chars.join(''));
},
};
//# sourceMappingURL=utils.js.map