@draht/coding-agent 2026.7.7-1 → 2026.7.11
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/CHANGELOG.md +21 -0
- package/README.md +2 -2
- package/agents/advisor.md +44 -0
- package/bin/draht-tools.cjs +1808 -988
- package/dist/agents/advisor.md +44 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts +16 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +76 -18
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-stats.d.ts +49 -0
- package/dist/core/cache-stats.d.ts.map +1 -0
- package/dist/core/cache-stats.js +101 -0
- package/dist/core/cache-stats.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +1 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +51 -73
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +23 -4
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -24
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +9 -9
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/model-registry.d.ts +4 -6
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +34 -8
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +2 -5
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +7 -3
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +10 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts +1 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -3
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/gsd/hook-utils.d.ts.map +1 -1
- package/dist/gsd/hook-utils.js +3 -1
- package/dist/gsd/hook-utils.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +4 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +3 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +17 -6
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +10 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +247 -47
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +3 -4
- package/dist/modes/interactive/theme/theme.d.ts +2 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +8 -4
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +6 -6
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +3 -3
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +4 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/prompts/commands/execute-phase.md +2 -2
- package/dist/prompts/commands/fix.md +1 -1
- package/dist/prompts/commands/map-codebase.md +8 -8
- package/dist/prompts/commands/next-milestone.md +1 -0
- package/dist/prompts/commands/orchestrate-loop.md +99 -0
- package/dist/prompts/commands/orchestrate.md +25 -2
- package/dist/prompts/commands/pause-work.md +2 -1
- package/dist/prompts/commands/plan-phase.md +1 -0
- package/dist/prompts/commands/quick.md +2 -2
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/docs/custom-provider.md +4 -3
- package/docs/extensions.md +15 -10
- package/docs/models.md +49 -8
- package/docs/rpc.md +15 -5
- package/docs/sdk.md +1 -1
- package/docs/settings.md +3 -2
- package/docs/themes.md +5 -3
- package/docs/tui.md +1 -1
- package/docs/usage.md +2 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/preset.ts +2 -2
- package/examples/extensions/reload-runtime.ts +2 -2
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/README.md +1 -1
- package/package.json +5 -5
- package/prompts/commands/execute-phase.md +2 -2
- package/prompts/commands/fix.md +1 -1
- package/prompts/commands/map-codebase.md +8 -8
- package/prompts/commands/next-milestone.md +1 -0
- package/prompts/commands/orchestrate-loop.md +99 -0
- package/prompts/commands/orchestrate.md +25 -2
- package/prompts/commands/pause-work.md +2 -1
- package/prompts/commands/plan-phase.md +1 -0
- package/prompts/commands/quick.md +2 -2
|
@@ -72,6 +72,9 @@ export class AgentSession {
|
|
|
72
72
|
// Event subscription state
|
|
73
73
|
_unsubscribeAgent;
|
|
74
74
|
_eventListeners = [];
|
|
75
|
+
_isAgentRunActive = false;
|
|
76
|
+
_idleWaitPromise;
|
|
77
|
+
_resolveIdleWait;
|
|
75
78
|
/** Tracks pending steering messages for UI display. Removed when delivered. */
|
|
76
79
|
_steeringMessages = [];
|
|
77
80
|
/** Tracks pending follow-up messages for UI display. Removed when delivered. */
|
|
@@ -265,6 +268,33 @@ export class AgentSession {
|
|
|
265
268
|
followUp: [...this._followUpMessages],
|
|
266
269
|
});
|
|
267
270
|
}
|
|
271
|
+
_getIdleWaitPromise() {
|
|
272
|
+
if (!this._idleWaitPromise) {
|
|
273
|
+
this._idleWaitPromise = new Promise((resolve) => {
|
|
274
|
+
this._resolveIdleWait = resolve;
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return this._idleWaitPromise;
|
|
278
|
+
}
|
|
279
|
+
_resolveIdleWaitIfIdle() {
|
|
280
|
+
if (this._isAgentRunActive || !this._resolveIdleWait) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const resolve = this._resolveIdleWait;
|
|
284
|
+
this._idleWaitPromise = undefined;
|
|
285
|
+
this._resolveIdleWait = undefined;
|
|
286
|
+
resolve();
|
|
287
|
+
}
|
|
288
|
+
async _emitAgentSettled() {
|
|
289
|
+
this._isAgentRunActive = false;
|
|
290
|
+
try {
|
|
291
|
+
await this._extensionRunner.emit({ type: "agent_settled" });
|
|
292
|
+
this._emit({ type: "agent_settled" });
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
this._resolveIdleWaitIfIdle();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
268
298
|
// Track last assistant message for auto-compaction check
|
|
269
299
|
_lastAssistantMessage = undefined;
|
|
270
300
|
/** Internal handler for agent events - shared by subscribe and reconnect */
|
|
@@ -538,9 +568,13 @@ export class AgentSession {
|
|
|
538
568
|
get thinkingLevel() {
|
|
539
569
|
return this.agent.state.thinkingLevel;
|
|
540
570
|
}
|
|
541
|
-
/** Whether
|
|
571
|
+
/** Whether the session is currently processing an agent run or post-run continuation. */
|
|
542
572
|
get isStreaming() {
|
|
543
|
-
return this.
|
|
573
|
+
return this._isAgentRunActive;
|
|
574
|
+
}
|
|
575
|
+
/** Whether the session has no active agent run, retry, auto-compaction, or queued continuation. */
|
|
576
|
+
get isIdle() {
|
|
577
|
+
return !this._isAgentRunActive;
|
|
544
578
|
}
|
|
545
579
|
/** Current effective system prompt (includes any per-turn extension modifications) */
|
|
546
580
|
get systemPrompt() {
|
|
@@ -692,6 +726,7 @@ export class AgentSession {
|
|
|
692
726
|
// Prompting
|
|
693
727
|
// =========================================================================
|
|
694
728
|
async _runAgentPrompt(messages) {
|
|
729
|
+
this._isAgentRunActive = true;
|
|
695
730
|
try {
|
|
696
731
|
await this.agent.prompt(messages);
|
|
697
732
|
while (await this._handlePostAgentRun()) {
|
|
@@ -701,6 +736,7 @@ export class AgentSession {
|
|
|
701
736
|
finally {
|
|
702
737
|
this._systemPromptOverride = undefined;
|
|
703
738
|
this._flushPendingBashMessages();
|
|
739
|
+
await this._emitAgentSettled();
|
|
704
740
|
}
|
|
705
741
|
}
|
|
706
742
|
async _handlePostAgentRun() {
|
|
@@ -1111,7 +1147,13 @@ export class AgentSession {
|
|
|
1111
1147
|
async abort() {
|
|
1112
1148
|
this.abortRetry();
|
|
1113
1149
|
this.agent.abort();
|
|
1114
|
-
await this.
|
|
1150
|
+
await this.waitForIdle();
|
|
1151
|
+
}
|
|
1152
|
+
async waitForIdle() {
|
|
1153
|
+
if (this.isIdle) {
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
await this._getIdleWaitPromise();
|
|
1115
1157
|
}
|
|
1116
1158
|
// =========================================================================
|
|
1117
1159
|
// Model Management
|
|
@@ -1826,7 +1868,7 @@ export class AgentSession {
|
|
|
1826
1868
|
setThinkingLevel: (level) => this.setThinkingLevel(level),
|
|
1827
1869
|
}, {
|
|
1828
1870
|
getModel: () => this.model,
|
|
1829
|
-
isIdle: () =>
|
|
1871
|
+
isIdle: () => this.isIdle,
|
|
1830
1872
|
isProjectTrusted: () => this.settingsManager.isProjectTrusted(),
|
|
1831
1873
|
getSignal: () => this.agent.signal,
|
|
1832
1874
|
abort: () => {
|
|
@@ -2384,28 +2426,44 @@ export class AgentSession {
|
|
|
2384
2426
|
return "";
|
|
2385
2427
|
}
|
|
2386
2428
|
/**
|
|
2387
|
-
* Get session statistics.
|
|
2429
|
+
* Get session statistics. Aggregates over ALL session entries (including
|
|
2430
|
+
* history that was compacted away), so token/cost totals reflect what was
|
|
2431
|
+
* actually billed across the session.
|
|
2388
2432
|
*/
|
|
2389
2433
|
getSessionStats() {
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2434
|
+
let userMessages = 0;
|
|
2435
|
+
let assistantMessages = 0;
|
|
2436
|
+
let toolResults = 0;
|
|
2437
|
+
let totalMessages = 0;
|
|
2394
2438
|
let toolCalls = 0;
|
|
2395
2439
|
let totalInput = 0;
|
|
2396
2440
|
let totalOutput = 0;
|
|
2397
2441
|
let totalCacheRead = 0;
|
|
2398
2442
|
let totalCacheWrite = 0;
|
|
2399
2443
|
let totalCost = 0;
|
|
2400
|
-
for (const
|
|
2401
|
-
if (
|
|
2444
|
+
for (const entry of this.sessionManager.getEntries()) {
|
|
2445
|
+
if (entry.type !== "message")
|
|
2446
|
+
continue;
|
|
2447
|
+
totalMessages++;
|
|
2448
|
+
const message = entry.message;
|
|
2449
|
+
if (message.role === "user") {
|
|
2450
|
+
userMessages++;
|
|
2451
|
+
}
|
|
2452
|
+
else if (message.role === "toolResult") {
|
|
2453
|
+
toolResults++;
|
|
2454
|
+
}
|
|
2455
|
+
else if (message.role === "assistant") {
|
|
2456
|
+
assistantMessages++;
|
|
2402
2457
|
const assistantMsg = message;
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2458
|
+
if (Array.isArray(assistantMsg.content)) {
|
|
2459
|
+
toolCalls += assistantMsg.content.filter((c) => c.type === "toolCall").length;
|
|
2460
|
+
}
|
|
2461
|
+
const usage = assistantMsg.usage;
|
|
2462
|
+
totalInput += usage.input;
|
|
2463
|
+
totalOutput += usage.output;
|
|
2464
|
+
totalCacheRead += usage.cacheRead;
|
|
2465
|
+
totalCacheWrite += usage.cacheWrite;
|
|
2466
|
+
totalCost += usage.cost.total;
|
|
2409
2467
|
}
|
|
2410
2468
|
}
|
|
2411
2469
|
return {
|
|
@@ -2415,7 +2473,7 @@ export class AgentSession {
|
|
|
2415
2473
|
assistantMessages,
|
|
2416
2474
|
toolCalls,
|
|
2417
2475
|
toolResults,
|
|
2418
|
-
totalMessages
|
|
2476
|
+
totalMessages,
|
|
2419
2477
|
tokens: {
|
|
2420
2478
|
input: totalInput,
|
|
2421
2479
|
output: totalOutput,
|