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,7 @@
import { Sampler, SamplingResult } from '../Sampler';
/** Sampler that samples no traces. */
export declare class AlwaysOffSampler implements Sampler {
shouldSample(): SamplingResult;
toString(): string;
}
//# sourceMappingURL=AlwaysOffSampler.d.ts.map

View File

@@ -0,0 +1,32 @@
/*
* Copyright The OpenTelemetry Authors
*
* 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
*
* https://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.
*/
import { SamplingDecision } from '../Sampler';
/** Sampler that samples no traces. */
var AlwaysOffSampler = /** @class */ (function () {
function AlwaysOffSampler() {
}
AlwaysOffSampler.prototype.shouldSample = function () {
return {
decision: SamplingDecision.NOT_RECORD,
};
};
AlwaysOffSampler.prototype.toString = function () {
return 'AlwaysOffSampler';
};
return AlwaysOffSampler;
}());
export { AlwaysOffSampler };
//# sourceMappingURL=AlwaysOffSampler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AlwaysOffSampler.js","sourceRoot":"","sources":["../../../src/sampler/AlwaysOffSampler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAW,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAEvE,sCAAsC;AACtC;IAAA;IAUA,CAAC;IATC,uCAAY,GAAZ;QACE,OAAO;YACL,QAAQ,EAAE,gBAAgB,CAAC,UAAU;SACtC,CAAC;IACJ,CAAC;IAED,mCAAQ,GAAR;QACE,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACH,uBAAC;AAAD,CAAC,AAVD,IAUC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Sampler, SamplingDecision, SamplingResult } from '../Sampler';\n\n/** Sampler that samples no traces. */\nexport class AlwaysOffSampler implements Sampler {\n shouldSample(): SamplingResult {\n return {\n decision: SamplingDecision.NOT_RECORD,\n };\n }\n\n toString(): string {\n return 'AlwaysOffSampler';\n }\n}\n"]}

View File

@@ -0,0 +1,7 @@
import { Sampler, SamplingResult } from '../Sampler';
/** Sampler that samples all traces. */
export declare class AlwaysOnSampler implements Sampler {
shouldSample(): SamplingResult;
toString(): string;
}
//# sourceMappingURL=AlwaysOnSampler.d.ts.map

View File

@@ -0,0 +1,32 @@
/*
* Copyright The OpenTelemetry Authors
*
* 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
*
* https://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.
*/
import { SamplingDecision } from '../Sampler';
/** Sampler that samples all traces. */
var AlwaysOnSampler = /** @class */ (function () {
function AlwaysOnSampler() {
}
AlwaysOnSampler.prototype.shouldSample = function () {
return {
decision: SamplingDecision.RECORD_AND_SAMPLED,
};
};
AlwaysOnSampler.prototype.toString = function () {
return 'AlwaysOnSampler';
};
return AlwaysOnSampler;
}());
export { AlwaysOnSampler };
//# sourceMappingURL=AlwaysOnSampler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AlwaysOnSampler.js","sourceRoot":"","sources":["../../../src/sampler/AlwaysOnSampler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAW,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAEvE,uCAAuC;AACvC;IAAA;IAUA,CAAC;IATC,sCAAY,GAAZ;QACE,OAAO;YACL,QAAQ,EAAE,gBAAgB,CAAC,kBAAkB;SAC9C,CAAC;IACJ,CAAC;IAED,kCAAQ,GAAR;QACE,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACH,sBAAC;AAAD,CAAC,AAVD,IAUC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Sampler, SamplingDecision, SamplingResult } from '../Sampler';\n\n/** Sampler that samples all traces. */\nexport class AlwaysOnSampler implements Sampler {\n shouldSample(): SamplingResult {\n return {\n decision: SamplingDecision.RECORD_AND_SAMPLED,\n };\n }\n\n toString(): string {\n return 'AlwaysOnSampler';\n }\n}\n"]}

View File

@@ -0,0 +1,30 @@
import { Context, Link, SpanAttributes, SpanKind } from '@opentelemetry/api';
import { Sampler, SamplingResult } from '../Sampler';
/**
* A composite sampler that either respects the parent span's sampling decision
* or delegates to `delegateSampler` for root spans.
*/
export declare class ParentBasedSampler implements Sampler {
private _root;
private _remoteParentSampled;
private _remoteParentNotSampled;
private _localParentSampled;
private _localParentNotSampled;
constructor(config: ParentBasedSamplerConfig);
shouldSample(context: Context, traceId: string, spanName: string, spanKind: SpanKind, attributes: SpanAttributes, links: Link[]): SamplingResult;
toString(): string;
}
interface ParentBasedSamplerConfig {
/** Sampler called for spans with no parent */
root: Sampler;
/** Sampler called for spans with a remote parent which was sampled. Default AlwaysOn */
remoteParentSampled?: Sampler;
/** Sampler called for spans with a remote parent which was not sampled. Default AlwaysOff */
remoteParentNotSampled?: Sampler;
/** Sampler called for spans with a local parent which was sampled. Default AlwaysOn */
localParentSampled?: Sampler;
/** Sampler called for spans with a local parent which was not sampled. Default AlwaysOff */
localParentNotSampled?: Sampler;
}
export {};
//# sourceMappingURL=ParentBasedSampler.d.ts.map

View File

@@ -0,0 +1,63 @@
/*
* Copyright The OpenTelemetry Authors
*
* 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
*
* https://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.
*/
import { isSpanContextValid, TraceFlags, trace, } from '@opentelemetry/api';
import { globalErrorHandler } from '@opentelemetry/core';
import { AlwaysOffSampler } from './AlwaysOffSampler';
import { AlwaysOnSampler } from './AlwaysOnSampler';
/**
* A composite sampler that either respects the parent span's sampling decision
* or delegates to `delegateSampler` for root spans.
*/
var ParentBasedSampler = /** @class */ (function () {
function ParentBasedSampler(config) {
var _a, _b, _c, _d;
this._root = config.root;
if (!this._root) {
globalErrorHandler(new Error('ParentBasedSampler must have a root sampler configured'));
this._root = new AlwaysOnSampler();
}
this._remoteParentSampled =
(_a = config.remoteParentSampled) !== null && _a !== void 0 ? _a : new AlwaysOnSampler();
this._remoteParentNotSampled =
(_b = config.remoteParentNotSampled) !== null && _b !== void 0 ? _b : new AlwaysOffSampler();
this._localParentSampled =
(_c = config.localParentSampled) !== null && _c !== void 0 ? _c : new AlwaysOnSampler();
this._localParentNotSampled =
(_d = config.localParentNotSampled) !== null && _d !== void 0 ? _d : new AlwaysOffSampler();
}
ParentBasedSampler.prototype.shouldSample = function (context, traceId, spanName, spanKind, attributes, links) {
var parentContext = trace.getSpanContext(context);
if (!parentContext || !isSpanContextValid(parentContext)) {
return this._root.shouldSample(context, traceId, spanName, spanKind, attributes, links);
}
if (parentContext.isRemote) {
if (parentContext.traceFlags & TraceFlags.SAMPLED) {
return this._remoteParentSampled.shouldSample(context, traceId, spanName, spanKind, attributes, links);
}
return this._remoteParentNotSampled.shouldSample(context, traceId, spanName, spanKind, attributes, links);
}
if (parentContext.traceFlags & TraceFlags.SAMPLED) {
return this._localParentSampled.shouldSample(context, traceId, spanName, spanKind, attributes, links);
}
return this._localParentNotSampled.shouldSample(context, traceId, spanName, spanKind, attributes, links);
};
ParentBasedSampler.prototype.toString = function () {
return "ParentBased{root=" + this._root.toString() + ", remoteParentSampled=" + this._remoteParentSampled.toString() + ", remoteParentNotSampled=" + this._remoteParentNotSampled.toString() + ", localParentSampled=" + this._localParentSampled.toString() + ", localParentNotSampled=" + this._localParentNotSampled.toString() + "}";
};
return ParentBasedSampler;
}());
export { ParentBasedSampler };
//# sourceMappingURL=ParentBasedSampler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
import { Sampler, SamplingResult } from '../Sampler';
/** Sampler that samples a given fraction of traces based of trace id deterministically. */
export declare class TraceIdRatioBasedSampler implements Sampler {
private readonly _ratio;
private _upperBound;
constructor(_ratio?: number);
shouldSample(context: unknown, traceId: string): SamplingResult;
toString(): string;
private _normalize;
private _accumulate;
}
//# sourceMappingURL=TraceIdRatioBasedSampler.d.ts.map

View File

@@ -0,0 +1,53 @@
/*
* Copyright The OpenTelemetry Authors
*
* 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
*
* https://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.
*/
import { isValidTraceId } from '@opentelemetry/api';
import { SamplingDecision } from '../Sampler';
/** Sampler that samples a given fraction of traces based of trace id deterministically. */
var TraceIdRatioBasedSampler = /** @class */ (function () {
function TraceIdRatioBasedSampler(_ratio) {
if (_ratio === void 0) { _ratio = 0; }
this._ratio = _ratio;
this._ratio = this._normalize(_ratio);
this._upperBound = Math.floor(this._ratio * 0xffffffff);
}
TraceIdRatioBasedSampler.prototype.shouldSample = function (context, traceId) {
return {
decision: isValidTraceId(traceId) && this._accumulate(traceId) < this._upperBound
? SamplingDecision.RECORD_AND_SAMPLED
: SamplingDecision.NOT_RECORD,
};
};
TraceIdRatioBasedSampler.prototype.toString = function () {
return "TraceIdRatioBased{" + this._ratio + "}";
};
TraceIdRatioBasedSampler.prototype._normalize = function (ratio) {
if (typeof ratio !== 'number' || isNaN(ratio))
return 0;
return ratio >= 1 ? 1 : ratio <= 0 ? 0 : ratio;
};
TraceIdRatioBasedSampler.prototype._accumulate = function (traceId) {
var accumulation = 0;
for (var i = 0; i < traceId.length / 8; i++) {
var pos = i * 8;
var part = parseInt(traceId.slice(pos, pos + 8), 16);
accumulation = (accumulation ^ part) >>> 0;
}
return accumulation;
};
return TraceIdRatioBasedSampler;
}());
export { TraceIdRatioBasedSampler };
//# sourceMappingURL=TraceIdRatioBasedSampler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TraceIdRatioBasedSampler.js","sourceRoot":"","sources":["../../../src/sampler/TraceIdRatioBasedSampler.ts"],"names":[],"mappings":"AAAA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IAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YAClB,IAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACvD,YAAY,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SAC5C;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IACH,+BAAC;AAAD,CAAC,AAnCD,IAmCC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isValidTraceId } from '@opentelemetry/api';\nimport { Sampler, SamplingDecision, SamplingResult } from '../Sampler';\n\n/** Sampler that samples a given fraction of traces based of trace id deterministically. */\nexport class TraceIdRatioBasedSampler implements Sampler {\n private _upperBound: number;\n\n constructor(private readonly _ratio: number = 0) {\n this._ratio = this._normalize(_ratio);\n this._upperBound = Math.floor(this._ratio * 0xffffffff);\n }\n\n shouldSample(context: unknown, traceId: string): SamplingResult {\n return {\n decision:\n isValidTraceId(traceId) && this._accumulate(traceId) < this._upperBound\n ? SamplingDecision.RECORD_AND_SAMPLED\n : SamplingDecision.NOT_RECORD,\n };\n }\n\n toString(): string {\n return `TraceIdRatioBased{${this._ratio}}`;\n }\n\n private _normalize(ratio: number): number {\n if (typeof ratio !== 'number' || isNaN(ratio)) return 0;\n return ratio >= 1 ? 1 : ratio <= 0 ? 0 : ratio;\n }\n\n private _accumulate(traceId: string): number {\n let accumulation = 0;\n for (let i = 0; i < traceId.length / 8; i++) {\n const pos = i * 8;\n const part = parseInt(traceId.slice(pos, pos + 8), 16);\n accumulation = (accumulation ^ part) >>> 0;\n }\n return accumulation;\n }\n}\n"]}