@questionbase/deskfree 0.4.0-alpha.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +33 -29
- package/dist/bin.js.map +1 -1
- package/dist/cli/install.js +1 -1
- package/dist/cli/install.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -28
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/bin.js
CHANGED
|
@@ -3,8 +3,7 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import { execSync, execFile } from 'child_process';
|
|
4
4
|
import { writeFileSync, chmodSync, existsSync, unlinkSync, mkdirSync, readdirSync, readFileSync, createWriteStream } from 'fs';
|
|
5
5
|
import { createRequire as createRequire$1 } from 'module';
|
|
6
|
-
import { join, dirname,
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
6
|
+
import { join, dirname, extname } from 'path';
|
|
8
7
|
import { query, createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
9
8
|
import { z } from 'zod';
|
|
10
9
|
import { appendFile, readFile, mkdir, unlink } from 'fs/promises';
|
|
@@ -104,7 +103,7 @@ var init_install = __esm({
|
|
|
104
103
|
SERVICE_NAME = "deskfree-agent";
|
|
105
104
|
SERVICE_FILE = `/etc/systemd/system/${SERVICE_NAME}.service`;
|
|
106
105
|
ENV_FILE = `/etc/${SERVICE_NAME}.env`;
|
|
107
|
-
PACKAGE = "@questionbase/deskfree
|
|
106
|
+
PACKAGE = "@questionbase/deskfree@latest";
|
|
108
107
|
}
|
|
109
108
|
});
|
|
110
109
|
|
|
@@ -2781,7 +2780,7 @@ function validateApiUrl(value) {
|
|
|
2781
2780
|
"API URL must use HTTPS protocol for security. Make sure your DeskFree deployment supports HTTPS."
|
|
2782
2781
|
);
|
|
2783
2782
|
}
|
|
2784
|
-
var require2, __create2, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __getProtoOf2, __hasOwnProp2, __require2, __commonJS2, __export2, __copyProps2, __toESM2, require_constants, require_buffer_util, require_limiter, require_permessage_deflate, require_validation, require_receiver, require_sender, require_event_target, require_extension, require_websocket, require_stream, require_subprotocol, require_websocket_server, DEFAULT_REQUEST_TIMEOUT_MS, DeskFreeError, DeskFreeClient, value_exports, TypeSystemPolicy, TypeBoxError, TransformKind, ReadonlyKind, OptionalKind, Hint, Kind, type_exports, TypeGuardUnknownTypeError, KnownTypes, PatternBoolean, PatternNumber, PatternString, PatternNever, PatternNumberExact, PatternStringExact, PatternNeverExact, TemplateLiteralParserError, TemplateLiteralFiniteError, TemplateLiteralGenerateError, TemplateLiteralPatternError, Object2, includePatternProperties, ExtendsResolverError, ExtendsResult, TModule, Ordinal, TransformDecodeBuilder, TransformEncodeBuilder, type_exports2, Type, ORCHESTRATOR_TOOLS, SHARED_TOOLS, WORKER_TOOLS, MAX_FULL_MESSAGES,
|
|
2783
|
+
var require2, __create2, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __getProtoOf2, __hasOwnProp2, __require2, __commonJS2, __export2, __copyProps2, __toESM2, require_constants, require_buffer_util, require_limiter, require_permessage_deflate, require_validation, require_receiver, require_sender, require_event_target, require_extension, require_websocket, require_stream, require_subprotocol, require_websocket_server, DEFAULT_REQUEST_TIMEOUT_MS, DeskFreeError, DeskFreeClient, value_exports, TypeSystemPolicy, TypeBoxError, TransformKind, ReadonlyKind, OptionalKind, Hint, Kind, type_exports, TypeGuardUnknownTypeError, KnownTypes, PatternBoolean, PatternNumber, PatternString, PatternNever, PatternNumberExact, PatternStringExact, PatternNeverExact, TemplateLiteralParserError, TemplateLiteralFiniteError, TemplateLiteralGenerateError, TemplateLiteralPatternError, Object2, includePatternProperties, ExtendsResolverError, ExtendsResult, TModule, Ordinal, TransformDecodeBuilder, TransformEncodeBuilder, type_exports2, Type, ORCHESTRATOR_TOOLS, SHARED_TOOLS, WORKER_TOOLS, MAX_FULL_MESSAGES, DESKFREE_AGENT_DIRECTIVE, DESKFREE_WORKER_DIRECTIVE, DESKFREE_HEARTBEAT_DIRECTIVE, DESKFREE_SLEEP_DIRECTIVE, DESKFREE_DUSK_DIRECTIVE, THROTTLE_MS, CHAR_BUFFER_SIZE, CLOSE_MAX_RETRIES, DeskFreeStreamingSession, import_websocket, wrapper_default, activeWs, activeTaskId, completedTaskId, inboundThreadId, FLUSH_INTERVAL_MS, MAX_BATCH_SIZE, MAX_QUEUE_SIZE, _instance, ErrorReporter, accountHealth;
|
|
2785
2784
|
var init_dist = __esm({
|
|
2786
2785
|
"../core/dist/index.js"() {
|
|
2787
2786
|
require2 = createRequire$1(import.meta.url);
|
|
@@ -7342,10 +7341,6 @@ var init_dist = __esm({
|
|
|
7342
7341
|
PROPOSE: SHARED_TOOLS.PROPOSE
|
|
7343
7342
|
};
|
|
7344
7343
|
MAX_FULL_MESSAGES = 15;
|
|
7345
|
-
__dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
7346
|
-
JSON.parse(
|
|
7347
|
-
readFileSync(resolve(__dirname$1, "..", "package.json"), "utf-8")
|
|
7348
|
-
).version;
|
|
7349
7344
|
DESKFREE_AGENT_DIRECTIVE = `## DeskFree \u2014 Orchestrator
|
|
7350
7345
|
You are the orchestrator. Your job: turn human intent into approved tasks, then dispatch work.
|
|
7351
7346
|
|
|
@@ -11754,14 +11749,14 @@ function resetBackoff(state2) {
|
|
|
11754
11749
|
state2.attempt = 0;
|
|
11755
11750
|
}
|
|
11756
11751
|
function sleepWithAbort(ms, signal) {
|
|
11757
|
-
return new Promise((
|
|
11752
|
+
return new Promise((resolve) => {
|
|
11758
11753
|
const onAbort = () => {
|
|
11759
11754
|
clearTimeout(timer);
|
|
11760
|
-
|
|
11755
|
+
resolve();
|
|
11761
11756
|
};
|
|
11762
11757
|
const timer = setTimeout(() => {
|
|
11763
11758
|
signal.removeEventListener("abort", onAbort);
|
|
11764
|
-
|
|
11759
|
+
resolve();
|
|
11765
11760
|
}, ms);
|
|
11766
11761
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
11767
11762
|
});
|
|
@@ -11852,7 +11847,7 @@ async function runWebSocketConnection(opts) {
|
|
|
11852
11847
|
const { ticket, wsUrl, client, accountId, stateDir, log, abortSignal } = opts;
|
|
11853
11848
|
const ctx = { accountId };
|
|
11854
11849
|
let cursor = opts.cursor;
|
|
11855
|
-
return new Promise((
|
|
11850
|
+
return new Promise((resolve, reject) => {
|
|
11856
11851
|
const ws = new wrapper_default2(`${wsUrl}?ticket=${ticket}`);
|
|
11857
11852
|
let pingInterval;
|
|
11858
11853
|
let connectionTimer;
|
|
@@ -12051,7 +12046,7 @@ async function runWebSocketConnection(opts) {
|
|
|
12051
12046
|
} else {
|
|
12052
12047
|
log.info(`WebSocket closed: ${code} ${reason.toString()}`);
|
|
12053
12048
|
}
|
|
12054
|
-
|
|
12049
|
+
resolve(cursor);
|
|
12055
12050
|
});
|
|
12056
12051
|
ws.on("error", (err) => {
|
|
12057
12052
|
cleanup();
|
|
@@ -12669,7 +12664,7 @@ async function installTools(tools, toolsDir, log) {
|
|
|
12669
12664
|
log?.info(
|
|
12670
12665
|
`Installing tool packages into ${toolsDir}: ${Object.keys(deps).join(", ")}`
|
|
12671
12666
|
);
|
|
12672
|
-
await new Promise((
|
|
12667
|
+
await new Promise((resolve, reject) => {
|
|
12673
12668
|
const child = execFile(
|
|
12674
12669
|
"npm",
|
|
12675
12670
|
["install", "--omit=dev"],
|
|
@@ -12683,7 +12678,7 @@ ${stderr}` : ""}`
|
|
|
12683
12678
|
)
|
|
12684
12679
|
);
|
|
12685
12680
|
} else {
|
|
12686
|
-
|
|
12681
|
+
resolve();
|
|
12687
12682
|
}
|
|
12688
12683
|
}
|
|
12689
12684
|
);
|
|
@@ -13293,9 +13288,9 @@ var init_channel = __esm({
|
|
|
13293
13288
|
push(msg) {
|
|
13294
13289
|
if (this.closed) return;
|
|
13295
13290
|
if (this.waiter) {
|
|
13296
|
-
const
|
|
13291
|
+
const resolve = this.waiter;
|
|
13297
13292
|
this.waiter = null;
|
|
13298
|
-
|
|
13293
|
+
resolve(msg);
|
|
13299
13294
|
} else {
|
|
13300
13295
|
this.buffer.push(msg);
|
|
13301
13296
|
}
|
|
@@ -13304,9 +13299,9 @@ var init_channel = __esm({
|
|
|
13304
13299
|
close() {
|
|
13305
13300
|
this.closed = true;
|
|
13306
13301
|
if (this.waiter) {
|
|
13307
|
-
const
|
|
13302
|
+
const resolve = this.waiter;
|
|
13308
13303
|
this.waiter = null;
|
|
13309
|
-
|
|
13304
|
+
resolve(null);
|
|
13310
13305
|
}
|
|
13311
13306
|
}
|
|
13312
13307
|
async *[Symbol.asyncIterator]() {
|
|
@@ -13316,12 +13311,12 @@ var init_channel = __esm({
|
|
|
13316
13311
|
continue;
|
|
13317
13312
|
}
|
|
13318
13313
|
if (this.closed) return;
|
|
13319
|
-
const msg = await new Promise((
|
|
13314
|
+
const msg = await new Promise((resolve) => {
|
|
13320
13315
|
if (this.closed) {
|
|
13321
|
-
|
|
13316
|
+
resolve(null);
|
|
13322
13317
|
return;
|
|
13323
13318
|
}
|
|
13324
|
-
this.waiter =
|
|
13319
|
+
this.waiter = resolve;
|
|
13325
13320
|
});
|
|
13326
13321
|
if (msg === null) return;
|
|
13327
13322
|
yield msg;
|
|
@@ -13450,7 +13445,13 @@ var init_worker_manager = __esm({
|
|
|
13450
13445
|
teardownAll() {
|
|
13451
13446
|
this.pendingQueue.clear();
|
|
13452
13447
|
for (const taskId of [...this.workers.keys()]) {
|
|
13453
|
-
|
|
13448
|
+
try {
|
|
13449
|
+
this.teardown(taskId);
|
|
13450
|
+
} catch (err) {
|
|
13451
|
+
this.deps.log.warn(`Failed to teardown worker for task ${taskId}`, {
|
|
13452
|
+
error: err
|
|
13453
|
+
});
|
|
13454
|
+
}
|
|
13454
13455
|
}
|
|
13455
13456
|
}
|
|
13456
13457
|
// ── Private ────────────────────────────────────────────────────────────
|
|
@@ -13844,19 +13845,22 @@ async function startAgent(opts) {
|
|
|
13844
13845
|
}
|
|
13845
13846
|
process.env["ANTHROPIC_MODEL"] = config.model;
|
|
13846
13847
|
if (config.provider === "ollama") {
|
|
13848
|
+
delete process.env["CLAUDE_CODE_USE_BEDROCK"];
|
|
13847
13849
|
process.env["ANTHROPIC_BASE_URL"] = config.baseUrl ?? "http://localhost:11434";
|
|
13848
13850
|
process.env["ANTHROPIC_API_KEY"] = "ollama";
|
|
13849
13851
|
log.info(
|
|
13850
13852
|
`Using model: ${config.model} (Ollama, base URL: ${config.baseUrl ?? "http://localhost:11434"})`
|
|
13851
13853
|
);
|
|
13854
|
+
} else if (config.provider === "claude-code") {
|
|
13855
|
+
delete process.env["CLAUDE_CODE_USE_BEDROCK"];
|
|
13856
|
+
log.info(`Using model: ${config.model} (Claude Code, native OAuth)`);
|
|
13852
13857
|
} else if (config.provider === "anthropic") {
|
|
13853
|
-
|
|
13854
|
-
if (
|
|
13855
|
-
|
|
13856
|
-
log.info(`Using model: ${config.model} (Anthropic API key)`);
|
|
13857
|
-
} else {
|
|
13858
|
-
log.info(`Using model: ${config.model} (Anthropic, native auth)`);
|
|
13858
|
+
delete process.env["CLAUDE_CODE_USE_BEDROCK"];
|
|
13859
|
+
if (!config.anthropicApiKey) {
|
|
13860
|
+
throw new Error("Anthropic provider requires an API key");
|
|
13859
13861
|
}
|
|
13862
|
+
process.env["ANTHROPIC_API_KEY"] = config.anthropicApiKey;
|
|
13863
|
+
log.info(`Using model: ${config.model} (Anthropic API key)`);
|
|
13860
13864
|
} else {
|
|
13861
13865
|
process.env["CLAUDE_CODE_USE_BEDROCK"] = "1";
|
|
13862
13866
|
process.env["AWS_REGION"] = config.awsRegion;
|