- 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
70 lines
2.5 KiB
JavaScript
70 lines
2.5 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Shared utilities for tracking SDK helper usage.
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.SDK_HELPER_SYMBOL = void 0;
|
|
exports.wasCreatedByStainlessHelper = wasCreatedByStainlessHelper;
|
|
exports.collectStainlessHelpers = collectStainlessHelpers;
|
|
exports.stainlessHelperHeader = stainlessHelperHeader;
|
|
exports.stainlessHelperHeaderFromFile = stainlessHelperHeaderFromFile;
|
|
/**
|
|
* Symbol used to mark objects created by SDK helpers for tracking.
|
|
* The value is the helper name (e.g., 'mcpTool', 'betaZodTool').
|
|
*/
|
|
exports.SDK_HELPER_SYMBOL = Symbol('anthropic.sdk.stainlessHelper');
|
|
function wasCreatedByStainlessHelper(value) {
|
|
return typeof value === 'object' && value !== null && exports.SDK_HELPER_SYMBOL in value;
|
|
}
|
|
/**
|
|
* Collects helper names from tools and messages arrays.
|
|
* Returns a deduplicated array of helper names found.
|
|
*/
|
|
function collectStainlessHelpers(tools, messages) {
|
|
const helpers = new Set();
|
|
// Collect from tools
|
|
if (tools) {
|
|
for (const tool of tools) {
|
|
if (wasCreatedByStainlessHelper(tool)) {
|
|
helpers.add(tool[exports.SDK_HELPER_SYMBOL]);
|
|
}
|
|
}
|
|
}
|
|
// Collect from messages and their content blocks
|
|
if (messages) {
|
|
for (const message of messages) {
|
|
if (wasCreatedByStainlessHelper(message)) {
|
|
helpers.add(message[exports.SDK_HELPER_SYMBOL]);
|
|
}
|
|
if (Array.isArray(message.content)) {
|
|
for (const block of message.content) {
|
|
if (wasCreatedByStainlessHelper(block)) {
|
|
helpers.add(block[exports.SDK_HELPER_SYMBOL]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Array.from(helpers);
|
|
}
|
|
/**
|
|
* Builds x-stainless-helper header value from tools and messages.
|
|
* Returns an empty object if no helpers are found.
|
|
*/
|
|
function stainlessHelperHeader(tools, messages) {
|
|
const helpers = collectStainlessHelpers(tools, messages);
|
|
if (helpers.length === 0)
|
|
return {};
|
|
return { 'x-stainless-helper': helpers.join(', ') };
|
|
}
|
|
/**
|
|
* Builds x-stainless-helper header value from a file object.
|
|
* Returns an empty object if the file is not marked with a helper.
|
|
*/
|
|
function stainlessHelperHeaderFromFile(file) {
|
|
if (wasCreatedByStainlessHelper(file)) {
|
|
return { 'x-stainless-helper': file[exports.SDK_HELPER_SYMBOL] };
|
|
}
|
|
return {};
|
|
}
|
|
//# sourceMappingURL=stainless-helper-header.js.map
|