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
This commit is contained in:
admin
2026-05-05 09:01:26 +00:00
Unverified
parent 4a7035dd92
commit 875c7f9b91
24688 changed files with 3224957 additions and 221 deletions

View File

@@ -0,0 +1,2 @@
export declare function hexToBinary(hexStr: string): Uint8Array;
//# sourceMappingURL=hex-to-binary.d.ts.map

View File

@@ -0,0 +1,27 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
function intValue(charCode) {
// 0-9
if (charCode >= 48 && charCode <= 57) {
return charCode - 48;
}
// a-f
if (charCode >= 97 && charCode <= 102) {
return charCode - 87;
}
// A-F
return charCode - 55;
}
export function hexToBinary(hexStr) {
const buf = new Uint8Array(hexStr.length / 2);
let offset = 0;
for (let i = 0; i < hexStr.length; i += 2) {
const hi = intValue(hexStr.charCodeAt(i));
const lo = intValue(hexStr.charCodeAt(i + 1));
buf[offset++] = (hi << 4) | lo;
}
return buf;
}
//# sourceMappingURL=hex-to-binary.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"hex-to-binary.js","sourceRoot":"","sources":["../../../src/common/hex-to-binary.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,SAAS,QAAQ,CAAC,QAAgB;IAChC,MAAM;IACN,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,EAAE,EAAE;QACpC,OAAO,QAAQ,GAAG,EAAE,CAAC;KACtB;IAED,MAAM;IACN,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,IAAI,GAAG,EAAE;QACrC,OAAO,QAAQ,GAAG,EAAE,CAAC;KACtB;IAED,MAAM;IACN,OAAO,QAAQ,GAAG,EAAE,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9C,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACzC,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;KAChC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nfunction intValue(charCode: number): number {\n // 0-9\n if (charCode >= 48 && charCode <= 57) {\n return charCode - 48;\n }\n\n // a-f\n if (charCode >= 97 && charCode <= 102) {\n return charCode - 87;\n }\n\n // A-F\n return charCode - 55;\n}\n\nexport function hexToBinary(hexStr: string): Uint8Array {\n const buf = new Uint8Array(hexStr.length / 2);\n let offset = 0;\n\n for (let i = 0; i < hexStr.length; i += 2) {\n const hi = intValue(hexStr.charCodeAt(i));\n const lo = intValue(hexStr.charCodeAt(i + 1));\n buf[offset++] = (hi << 4) | lo;\n }\n\n return buf;\n}\n"]}

View File

@@ -0,0 +1,66 @@
/** Properties of a Resource. */
export interface Resource {
/** Resource attributes */
attributes: IKeyValue[];
/** Resource droppedAttributesCount */
droppedAttributesCount: number;
/** Resource schemaUrl */
schemaUrl?: string;
}
/** Properties of an InstrumentationScope. */
export interface IInstrumentationScope {
/** InstrumentationScope name */
name: string;
/** InstrumentationScope version */
version?: string;
/** InstrumentationScope attributes */
attributes?: IKeyValue[];
/** InstrumentationScope droppedAttributesCount */
droppedAttributesCount?: number;
}
/** Properties of a KeyValue. */
export interface IKeyValue {
/** KeyValue key */
key: string;
/** KeyValue value */
value: IAnyValue;
}
/** Properties of an AnyValue. */
export interface IAnyValue {
/** AnyValue stringValue */
stringValue?: string | null;
/** AnyValue boolValue */
boolValue?: boolean | null;
/** AnyValue intValue */
intValue?: number | null;
/** AnyValue doubleValue */
doubleValue?: number | null;
/** AnyValue arrayValue */
arrayValue?: IArrayValue;
/** AnyValue kvlistValue */
kvlistValue?: IKeyValueList;
/** AnyValue bytesValue */
bytesValue?: Uint8Array | string;
}
/** Properties of an ArrayValue. */
export interface IArrayValue {
/** ArrayValue values */
values: IAnyValue[];
}
/** Properties of a KeyValueList. */
export interface IKeyValueList {
/** KeyValueList values */
values: IKeyValue[];
}
export interface LongBits {
low: number;
high: number;
}
export type Fixed64 = LongBits | string | number;
export interface OtlpEncodingOptions {
/** Convert trace and span IDs to hex strings. */
useHex?: boolean;
/** Convert HrTime to 2 part 64 bit values. */
useLongBits?: boolean;
}
//# sourceMappingURL=internal-types.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=internal-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"internal-types.js","sourceRoot":"","sources":["../../../src/common/internal-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/** Properties of a Resource. */\nexport interface Resource {\n /** Resource attributes */\n attributes: IKeyValue[];\n\n /** Resource droppedAttributesCount */\n droppedAttributesCount: number;\n\n /** Resource schemaUrl */\n schemaUrl?: string;\n}\n\n/** Properties of an InstrumentationScope. */\nexport interface IInstrumentationScope {\n /** InstrumentationScope name */\n name: string;\n\n /** InstrumentationScope version */\n version?: string;\n\n /** InstrumentationScope attributes */\n attributes?: IKeyValue[];\n\n /** InstrumentationScope droppedAttributesCount */\n droppedAttributesCount?: number;\n}\n\n/** Properties of a KeyValue. */\nexport interface IKeyValue {\n /** KeyValue key */\n key: string;\n\n /** KeyValue value */\n value: IAnyValue;\n}\n\n/** Properties of an AnyValue. */\nexport interface IAnyValue {\n /** AnyValue stringValue */\n stringValue?: string | null;\n\n /** AnyValue boolValue */\n boolValue?: boolean | null;\n\n /** AnyValue intValue */\n intValue?: number | null;\n\n /** AnyValue doubleValue */\n doubleValue?: number | null;\n\n /** AnyValue arrayValue */\n arrayValue?: IArrayValue;\n\n /** AnyValue kvlistValue */\n kvlistValue?: IKeyValueList;\n\n /** AnyValue bytesValue */\n bytesValue?: Uint8Array | string;\n}\n\n/** Properties of an ArrayValue. */\nexport interface IArrayValue {\n /** ArrayValue values */\n values: IAnyValue[];\n}\n\n/** Properties of a KeyValueList. */\nexport interface IKeyValueList {\n /** KeyValueList values */\n values: IKeyValue[];\n}\n\nexport interface LongBits {\n low: number;\n high: number;\n}\n\nexport type Fixed64 = LongBits | string | number;\n\nexport interface OtlpEncodingOptions {\n /** Convert trace and span IDs to hex strings. */\n useHex?: boolean;\n /** Convert HrTime to 2 part 64 bit values. */\n useLongBits?: boolean;\n}\n"]}

View File

@@ -0,0 +1,11 @@
import type { IAnyValue, IInstrumentationScope, IKeyValue, Resource } from './internal-types';
import type { Attributes } from '@opentelemetry/api';
import type { InstrumentationScope } from '@opentelemetry/core';
import type { Resource as ISdkResource } from '@opentelemetry/resources';
import type { Encoder } from './utils';
export declare function createResource(resource: ISdkResource, encoder: Encoder): Resource;
export declare function createInstrumentationScope(scope: InstrumentationScope): IInstrumentationScope;
export declare function toAttributes(attributes: Attributes, encoder: Encoder): IKeyValue[];
export declare function toKeyValue(key: string, value: unknown, encoder: Encoder): IKeyValue;
export declare function toAnyValue(value: unknown, encoder: Encoder): IAnyValue;
//# sourceMappingURL=internal.d.ts.map

View File

@@ -0,0 +1,59 @@
export function createResource(resource, encoder) {
const result = {
attributes: toAttributes(resource.attributes, encoder),
droppedAttributesCount: 0,
};
const schemaUrl = resource.schemaUrl;
if (schemaUrl && schemaUrl !== '')
result.schemaUrl = schemaUrl;
return result;
}
export function createInstrumentationScope(scope) {
return {
name: scope.name,
version: scope.version,
};
}
export function toAttributes(attributes, encoder) {
return Object.keys(attributes).map(key => toKeyValue(key, attributes[key], encoder));
}
export function toKeyValue(key, value, encoder) {
return {
key: key,
value: toAnyValue(value, encoder),
};
}
export function toAnyValue(value, encoder) {
const t = typeof value;
if (t === 'string')
return { stringValue: value };
if (t === 'number') {
if (!Number.isInteger(value))
return { doubleValue: value };
return { intValue: value };
}
if (t === 'boolean')
return { boolValue: value };
if (value instanceof Uint8Array)
return { bytesValue: encoder.encodeUint8Array(value) };
if (Array.isArray(value)) {
const values = new Array(value.length);
for (let i = 0; i < value.length; i++) {
values[i] = toAnyValue(value[i], encoder);
}
return { arrayValue: { values } };
}
if (t === 'object' && value != null) {
const keys = Object.keys(value);
const values = new Array(keys.length);
for (let i = 0; i < keys.length; i++) {
values[i] = {
key: keys[i],
value: toAnyValue(value[keys[i]], encoder),
};
}
return { kvlistValue: { values } };
}
return {};
}
//# sourceMappingURL=internal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/common/internal.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,cAAc,CAC5B,QAAsB,EACtB,OAAgB;IAEhB,MAAM,MAAM,GAAa;QACvB,UAAU,EAAE,YAAY,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;QACtD,sBAAsB,EAAE,CAAC;KAC1B,CAAC;IAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;IACrC,IAAI,SAAS,IAAI,SAAS,KAAK,EAAE;QAAE,MAAM,CAAC,SAAS,GA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,GAAgB,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SAC3C;QACD,OAAO,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;KACnC;IACD,IAAI,CAAC,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,EAAE;QACnC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,MAAM,GAAgB,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,MAAM,CAAC,CAAC,CAAC,GAAG;gBACV,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;gBACZ,KAAK,EAAE,UAAU,CAAE,KAAiC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;aACxE,CAAC;SACH;QACD,OAAO,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;KACpC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type {\n IAnyValue,\n IInstrumentationScope,\n IKeyValue,\n Resource,\n} from './internal-types';\nimport type { Attributes } from '@opentelemetry/api';\nimport type { InstrumentationScope } from '@opentelemetry/core';\nimport type { Resource as ISdkResource } from '@opentelemetry/resources';\nimport type { Encoder } from './utils';\n\nexport function createResource(\n resource: ISdkResource,\n encoder: Encoder\n): Resource {\n const result: Resource = {\n attributes: toAttributes(resource.attributes, encoder),\n droppedAttributesCount: 0,\n };\n\n const schemaUrl = resource.schemaUrl;\n if (schemaUrl && schemaUrl !== '') result.schemaUrl = schemaUrl;\n\n return result;\n}\n\nexport function createInstrumentationScope(\n scope: InstrumentationScope\n): IInstrumentationScope {\n return {\n name: scope.name,\n version: scope.version,\n };\n}\n\nexport function toAttributes(\n attributes: Attributes,\n encoder: Encoder\n): IKeyValue[] {\n return Object.keys(attributes).map(key =>\n toKeyValue(key, attributes[key], encoder)\n );\n}\n\nexport function toKeyValue(\n key: string,\n value: unknown,\n encoder: Encoder\n): IKeyValue {\n return {\n key: key,\n value: toAnyValue(value, encoder),\n };\n}\n\nexport function toAnyValue(value: unknown, encoder: Encoder): IAnyValue {\n const t = typeof value;\n if (t === 'string') return { stringValue: value as string };\n if (t === 'number') {\n if (!Number.isInteger(value)) return { doubleValue: value as number };\n return { intValue: value as number };\n }\n if (t === 'boolean') return { boolValue: value as boolean };\n if (value instanceof Uint8Array)\n return { bytesValue: encoder.encodeUint8Array(value) };\n if (Array.isArray(value)) {\n const values: IAnyValue[] = new Array(value.length);\n for (let i = 0; i < value.length; i++) {\n values[i] = toAnyValue(value[i], encoder);\n }\n return { arrayValue: { values } };\n }\n if (t === 'object' && value != null) {\n const keys = Object.keys(value);\n const values: IKeyValue[] = new Array(keys.length);\n for (let i = 0; i < keys.length; i++) {\n values[i] = {\n key: keys[i],\n value: toAnyValue((value as Record<string, unknown>)[keys[i]], encoder),\n };\n }\n return { kvlistValue: { values } };\n }\n\n return {};\n}\n"]}

View File

@@ -0,0 +1,8 @@
import type * as protobuf from 'protobufjs';
export interface ExportType<T, R = T & {
toJSON: () => unknown;
}> {
encode(message: T, writer?: protobuf.Writer): protobuf.Writer;
decode(reader: protobuf.Reader | Uint8Array, length?: number): R;
}
//# sourceMappingURL=protobuf-export-type.d.ts.map

View File

@@ -0,0 +1,6 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=protobuf-export-type.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"protobuf-export-type.js","sourceRoot":"","sources":["../../../../src/common/protobuf/protobuf-export-type.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type * as protobuf from 'protobufjs';\n\nexport interface ExportType<T, R = T & { toJSON: () => unknown }> {\n encode(message: T, writer?: protobuf.Writer): protobuf.Writer;\n decode(reader: protobuf.Reader | Uint8Array, length?: number): R;\n}\n"]}

View File

@@ -0,0 +1,27 @@
import type { Fixed64, LongBits } from './internal-types';
import type { HrTime } from '@opentelemetry/api';
export declare function hrTimeToNanos(hrTime: HrTime): bigint;
export declare function toLongBits(value: bigint): LongBits;
export declare function encodeAsLongBits(hrTime: HrTime): LongBits;
export declare function encodeAsString(hrTime: HrTime): string;
export type HrTimeEncodeFunction = (hrTime: HrTime) => Fixed64;
export type SpanContextEncodeFunction = (spanContext: string) => string | Uint8Array;
export type OptionalSpanContextEncodeFunction = (spanContext: string | undefined) => string | Uint8Array | undefined;
export type Uint8ArrayEncodeFunction = (value: Uint8Array) => string | Uint8Array;
export interface Encoder {
encodeHrTime: HrTimeEncodeFunction;
encodeSpanContext: SpanContextEncodeFunction;
encodeOptionalSpanContext: OptionalSpanContextEncodeFunction;
encodeUint8Array: Uint8ArrayEncodeFunction;
}
/**
* Encoder for protobuf format.
* Uses { high, low } timestamps and binary for span/trace IDs, leaves Uint8Array attributes as-is.
*/
export declare const PROTOBUF_ENCODER: Encoder;
/**
* Encoder for JSON format.
* Uses string timestamps, hex for span/trace IDs, and base64 for Uint8Array.
*/
export declare const JSON_ENCODER: Encoder;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1,64 @@
/*
* 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

File diff suppressed because one or more lines are too long