agent-worker 0.7.0 → 0.8.0
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/backends-CoOMoMcP.mjs +3 -0
- package/dist/{backends-Hclwb_Zp.mjs → backends-rQZxF7Fl.mjs} +93 -46
- package/dist/cli/index.mjs +47 -10
- package/dist/{context-Bq7pSNVM.mjs → context-dgI2YCGG.mjs} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{mcp-server-D5Pnt0lB.mjs → mcp-server-BQCQxv2v.mjs} +32 -8
- package/dist/{skills-CrCMADND.mjs → skills-ks27oet6.mjs} +3 -2
- package/dist/{workflow-CzVHUE9I.mjs → workflow-B_y98Ood.mjs} +19 -5
- package/package.json +1 -1
- package/dist/backends-BN3LvE37.mjs +0 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { C as SDK_MODEL_ALIASES, S as CURSOR_MODEL_MAP, _ as execWithIdleTimeout, a as createMockBackend, b as CLAUDE_MODEL_MAP, c as CodexBackend, d as codexAdapter, f as createStreamParser, g as IdleTimeoutError, h as formatEvent, i as MockAIBackend, l as ClaudeCodeBackend, m as extractCodexResult, n as createBackend, o as SdkBackend, p as extractClaudeResult, r as listBackends, s as CursorBackend, t as checkBackends, u as claudeAdapter, v as DEFAULT_IDLE_TIMEOUT, w as getModelForBackend, x as CODEX_MODEL_MAP, y as BACKEND_DEFAULT_MODELS } from "./backends-rQZxF7Fl.mjs";
|
|
2
|
+
|
|
3
|
+
export { listBackends };
|
|
@@ -297,6 +297,14 @@ function parseModel(model) {
|
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/backends/types.ts
|
|
302
|
+
/**
|
|
303
|
+
* Default idle timeout for CLI backends (10 minutes).
|
|
304
|
+
* Timeout resets on any stdout activity, so this is an inactivity threshold.
|
|
305
|
+
*/
|
|
306
|
+
const DEFAULT_IDLE_TIMEOUT = 6e5;
|
|
307
|
+
|
|
300
308
|
//#endregion
|
|
301
309
|
//#region src/backends/idle-timeout.ts
|
|
302
310
|
/**
|
|
@@ -456,6 +464,10 @@ function formatEvent(event, backendName) {
|
|
|
456
464
|
if (event.sessionId) details.push(`session: ${event.sessionId}`);
|
|
457
465
|
return `${backendName} initialized${details.length > 0 ? ` (${details.join(", ")})` : ""}`;
|
|
458
466
|
}
|
|
467
|
+
case "tool_call_started": {
|
|
468
|
+
const callIdSuffix = event.callId ? ` [${event.callId.slice(0, 8)}]` : "";
|
|
469
|
+
return `STARTING ${event.name}${callIdSuffix}`;
|
|
470
|
+
}
|
|
459
471
|
case "tool_call": {
|
|
460
472
|
const truncated = event.args.length > 100 ? event.args.slice(0, 100) + "..." : event.args;
|
|
461
473
|
return `CALL ${event.name}(${truncated})`;
|
|
@@ -469,6 +481,10 @@ function formatEvent(event, backendName) {
|
|
|
469
481
|
if (details.length > 0) parts.push(`(${details.join(", ")})`);
|
|
470
482
|
return parts.join(" ");
|
|
471
483
|
}
|
|
484
|
+
case "unknown": {
|
|
485
|
+
const preview = JSON.stringify(event.raw).slice(0, 100);
|
|
486
|
+
return `[DEBUG] ${backendName} unknown event type="${event.type}": ${preview}...`;
|
|
487
|
+
}
|
|
472
488
|
}
|
|
473
489
|
}
|
|
474
490
|
/**
|
|
@@ -480,30 +496,28 @@ function formatEvent(event, backendName) {
|
|
|
480
496
|
* { type: "result", duration_ms: N, total_cost_usd: N }
|
|
481
497
|
*/
|
|
482
498
|
const claudeAdapter = (raw) => {
|
|
483
|
-
const
|
|
484
|
-
if (type === "system" &&
|
|
499
|
+
const event = raw;
|
|
500
|
+
if (event.type === "system" && event.subtype === "init") return {
|
|
485
501
|
kind: "init",
|
|
486
|
-
model:
|
|
487
|
-
sessionId:
|
|
502
|
+
model: event.model,
|
|
503
|
+
sessionId: event.session_id
|
|
488
504
|
};
|
|
489
|
-
if (type === "assistant") {
|
|
490
|
-
const
|
|
491
|
-
if (!message?.content) return null;
|
|
492
|
-
const toolCalls = message.content.filter((c) => c.type === "tool_use");
|
|
505
|
+
if (event.type === "assistant") {
|
|
506
|
+
const toolCalls = event.message.content.filter((c) => c.type === "tool_use");
|
|
493
507
|
if (toolCalls.length > 0) {
|
|
494
508
|
const tc = toolCalls[0];
|
|
495
509
|
return {
|
|
496
510
|
kind: "tool_call",
|
|
497
|
-
name: tc.name
|
|
511
|
+
name: tc.name,
|
|
498
512
|
args: formatToolInput(tc.input)
|
|
499
513
|
};
|
|
500
514
|
}
|
|
501
515
|
return null;
|
|
502
516
|
}
|
|
503
|
-
if (type === "result") return {
|
|
517
|
+
if (event.type === "result") return {
|
|
504
518
|
kind: "completed",
|
|
505
|
-
durationMs:
|
|
506
|
-
costUsd:
|
|
519
|
+
durationMs: event.duration_ms,
|
|
520
|
+
costUsd: event.total_cost_usd
|
|
507
521
|
};
|
|
508
522
|
return null;
|
|
509
523
|
};
|
|
@@ -531,6 +545,43 @@ function extractClaudeResult(stdout) {
|
|
|
531
545
|
return { content: stdout.trim() };
|
|
532
546
|
}
|
|
533
547
|
/**
|
|
548
|
+
* Adapter for Cursor stream-json format.
|
|
549
|
+
*
|
|
550
|
+
* Events:
|
|
551
|
+
* { type: "system", subtype: "init", model: "..." }
|
|
552
|
+
* { type: "tool_call", subtype: "started", call_id: "...", tool_call: { shellToolCall: {...} } }
|
|
553
|
+
* { type: "tool_call", subtype: "completed", call_id: "..." }
|
|
554
|
+
* { type: "result", duration_ms: N }
|
|
555
|
+
*/
|
|
556
|
+
const cursorAdapter = (raw) => {
|
|
557
|
+
const event = raw;
|
|
558
|
+
if (event.type === "system" && event.subtype === "init") return {
|
|
559
|
+
kind: "init",
|
|
560
|
+
model: event.model,
|
|
561
|
+
sessionId: event.session_id
|
|
562
|
+
};
|
|
563
|
+
if (event.type === "tool_call") {
|
|
564
|
+
if (event.subtype === "started" && event.tool_call) {
|
|
565
|
+
if (event.tool_call.shellToolCall) return {
|
|
566
|
+
kind: "tool_call_started",
|
|
567
|
+
name: "bash",
|
|
568
|
+
callId: event.call_id
|
|
569
|
+
};
|
|
570
|
+
return {
|
|
571
|
+
kind: "tool_call_started",
|
|
572
|
+
name: "tool",
|
|
573
|
+
callId: event.call_id
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
if (event.type === "result") return {
|
|
579
|
+
kind: "completed",
|
|
580
|
+
durationMs: event.duration_ms
|
|
581
|
+
};
|
|
582
|
+
return null;
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
534
585
|
* Adapter for Codex --json format.
|
|
535
586
|
*
|
|
536
587
|
* Events:
|
|
@@ -540,34 +591,26 @@ function extractClaudeResult(stdout) {
|
|
|
540
591
|
* { type: "turn.completed", usage: { input_tokens, output_tokens } }
|
|
541
592
|
*/
|
|
542
593
|
const codexAdapter = (raw) => {
|
|
543
|
-
const
|
|
544
|
-
if (type === "thread.started") {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
if (type === "item.completed") {
|
|
552
|
-
const item = raw.item;
|
|
553
|
-
if (!item) return null;
|
|
554
|
-
if (item.type === "function_call") return {
|
|
594
|
+
const event = raw;
|
|
595
|
+
if (event.type === "thread.started") return {
|
|
596
|
+
kind: "init",
|
|
597
|
+
sessionId: `${event.thread_id.slice(0, 8)}...`
|
|
598
|
+
};
|
|
599
|
+
if (event.type === "item.completed") {
|
|
600
|
+
if (event.item.type === "function_call") return {
|
|
555
601
|
kind: "tool_call",
|
|
556
|
-
name: item.name
|
|
557
|
-
args: item.arguments
|
|
602
|
+
name: event.item.name,
|
|
603
|
+
args: event.item.arguments
|
|
558
604
|
};
|
|
559
605
|
return null;
|
|
560
606
|
}
|
|
561
|
-
if (type === "turn.completed") {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
} : void 0
|
|
569
|
-
};
|
|
570
|
-
}
|
|
607
|
+
if (event.type === "turn.completed") return {
|
|
608
|
+
kind: "completed",
|
|
609
|
+
usage: {
|
|
610
|
+
input: event.usage.input_tokens,
|
|
611
|
+
output: event.usage.output_tokens
|
|
612
|
+
}
|
|
613
|
+
};
|
|
571
614
|
return null;
|
|
572
615
|
};
|
|
573
616
|
/**
|
|
@@ -605,8 +648,12 @@ function createStreamParser(debugLog, backendName, adapter) {
|
|
|
605
648
|
if (!line.trim()) continue;
|
|
606
649
|
try {
|
|
607
650
|
const raw = JSON.parse(line);
|
|
608
|
-
|
|
609
|
-
|
|
651
|
+
let event = adapter(raw);
|
|
652
|
+
if (!event && raw.type) event = {
|
|
653
|
+
kind: "unknown",
|
|
654
|
+
type: raw.type,
|
|
655
|
+
raw
|
|
656
|
+
};
|
|
610
657
|
if (event) {
|
|
611
658
|
const progress = formatEvent(event, backendName);
|
|
612
659
|
if (progress) debugLog(progress);
|
|
@@ -646,7 +693,7 @@ var ClaudeCodeBackend = class {
|
|
|
646
693
|
currentAbort;
|
|
647
694
|
constructor(options = {}) {
|
|
648
695
|
this.options = {
|
|
649
|
-
timeout:
|
|
696
|
+
timeout: DEFAULT_IDLE_TIMEOUT,
|
|
650
697
|
...options
|
|
651
698
|
};
|
|
652
699
|
}
|
|
@@ -666,7 +713,7 @@ var ClaudeCodeBackend = class {
|
|
|
666
713
|
const cwd = this.options.workspace || this.options.cwd;
|
|
667
714
|
const debugLog = this.options.debugLog;
|
|
668
715
|
const outputFormat = this.options.outputFormat ?? "stream-json";
|
|
669
|
-
const timeout = this.options.timeout ??
|
|
716
|
+
const timeout = this.options.timeout ?? DEFAULT_IDLE_TIMEOUT;
|
|
670
717
|
try {
|
|
671
718
|
const { promise, abort } = execWithIdleTimeoutAbortable({
|
|
672
719
|
command: "claude",
|
|
@@ -771,7 +818,7 @@ var CodexBackend = class {
|
|
|
771
818
|
options;
|
|
772
819
|
constructor(options = {}) {
|
|
773
820
|
this.options = {
|
|
774
|
-
timeout:
|
|
821
|
+
timeout: DEFAULT_IDLE_TIMEOUT,
|
|
775
822
|
...options
|
|
776
823
|
};
|
|
777
824
|
}
|
|
@@ -790,7 +837,7 @@ var CodexBackend = class {
|
|
|
790
837
|
const args = this.buildArgs(message);
|
|
791
838
|
const cwd = this.options.workspace || this.options.cwd;
|
|
792
839
|
const debugLog = this.options.debugLog;
|
|
793
|
-
const timeout = this.options.timeout ??
|
|
840
|
+
const timeout = this.options.timeout ?? DEFAULT_IDLE_TIMEOUT;
|
|
794
841
|
try {
|
|
795
842
|
const { stdout } = await execWithIdleTimeout({
|
|
796
843
|
command: "codex",
|
|
@@ -860,7 +907,7 @@ var CursorBackend = class {
|
|
|
860
907
|
resolvedCommand = null;
|
|
861
908
|
constructor(options = {}) {
|
|
862
909
|
this.options = {
|
|
863
|
-
timeout:
|
|
910
|
+
timeout: DEFAULT_IDLE_TIMEOUT,
|
|
864
911
|
...options
|
|
865
912
|
};
|
|
866
913
|
}
|
|
@@ -878,14 +925,14 @@ var CursorBackend = class {
|
|
|
878
925
|
const { command, args } = await this.buildCommand(message);
|
|
879
926
|
const cwd = this.options.workspace || this.options.cwd;
|
|
880
927
|
const debugLog = this.options.debugLog;
|
|
881
|
-
const timeout = this.options.timeout ??
|
|
928
|
+
const timeout = this.options.timeout ?? DEFAULT_IDLE_TIMEOUT;
|
|
882
929
|
try {
|
|
883
930
|
const { stdout } = await execWithIdleTimeout({
|
|
884
931
|
command,
|
|
885
932
|
args,
|
|
886
933
|
cwd,
|
|
887
934
|
timeout,
|
|
888
|
-
onStdout: debugLog ? createStreamParser(debugLog, "Cursor",
|
|
935
|
+
onStdout: debugLog ? createStreamParser(debugLog, "Cursor", cursorAdapter) : void 0
|
|
889
936
|
});
|
|
890
937
|
return extractClaudeResult(stdout);
|
|
891
938
|
} catch (error) {
|
|
@@ -1115,4 +1162,4 @@ async function listBackends() {
|
|
|
1115
1162
|
}
|
|
1116
1163
|
|
|
1117
1164
|
//#endregion
|
|
1118
|
-
export {
|
|
1165
|
+
export { getDefaultModel as A, SDK_MODEL_ALIASES as C, SUPPORTED_PROVIDERS as D, FRONTIER_MODELS as E, createModel as O, CURSOR_MODEL_MAP as S, parseModel as T, execWithIdleTimeout as _, createMockBackend as a, CLAUDE_MODEL_MAP as b, CodexBackend as c, codexAdapter as d, createStreamParser as f, IdleTimeoutError as g, formatEvent as h, MockAIBackend as i, createModelAsync as k, ClaudeCodeBackend as l, extractCodexResult as m, createBackend as n, SdkBackend as o, extractClaudeResult as p, listBackends as r, CursorBackend as s, checkBackends as t, claudeAdapter as u, DEFAULT_IDLE_TIMEOUT as v, getModelForBackend as w, CODEX_MODEL_MAP as x, BACKEND_DEFAULT_MODELS as y };
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { a as createSkillsTool, c as createFeedbackTool, l as AgentSession, o as SkillsProvider, s as FEEDBACK_PROMPT, t as SkillImporter } from "../skills-
|
|
2
|
+
import { A as getDefaultModel, E as FRONTIER_MODELS, n as createBackend } from "../backends-rQZxF7Fl.mjs";
|
|
3
|
+
import { a as createSkillsTool, c as createFeedbackTool, l as AgentSession, o as SkillsProvider, s as FEEDBACK_PROMPT, t as SkillImporter } from "../skills-ks27oet6.mjs";
|
|
4
4
|
import { jsonSchema, tool } from "ai";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, isAbsolute, join, relative } from "node:path";
|
|
@@ -604,6 +604,7 @@ function calculatePriority(msg) {
|
|
|
604
604
|
const KEYS = {
|
|
605
605
|
channel: "channel.jsonl",
|
|
606
606
|
inboxState: "_state/inbox.json",
|
|
607
|
+
agentStatus: "_state/agent-status.json",
|
|
607
608
|
documentPrefix: "documents/",
|
|
608
609
|
resourcePrefix: "resources/"
|
|
609
610
|
};
|
|
@@ -797,6 +798,42 @@ var ContextProviderImpl = class {
|
|
|
797
798
|
}
|
|
798
799
|
return null;
|
|
799
800
|
}
|
|
801
|
+
async loadAgentStatus() {
|
|
802
|
+
const raw = await this.storage.read(KEYS.agentStatus);
|
|
803
|
+
if (!raw) return {};
|
|
804
|
+
try {
|
|
805
|
+
return JSON.parse(raw);
|
|
806
|
+
} catch {
|
|
807
|
+
return {};
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
async saveAgentStatus(statuses) {
|
|
811
|
+
await this.storage.write(KEYS.agentStatus, JSON.stringify(statuses, null, 2));
|
|
812
|
+
}
|
|
813
|
+
async setAgentStatus(agent, status) {
|
|
814
|
+
const statuses = await this.loadAgentStatus();
|
|
815
|
+
const existing = statuses[agent] || {
|
|
816
|
+
state: "idle",
|
|
817
|
+
lastUpdate: (/* @__PURE__ */ new Date()).toISOString()
|
|
818
|
+
};
|
|
819
|
+
statuses[agent] = {
|
|
820
|
+
...existing,
|
|
821
|
+
...status,
|
|
822
|
+
lastUpdate: (/* @__PURE__ */ new Date()).toISOString()
|
|
823
|
+
};
|
|
824
|
+
if (status.state === "running" && existing.state !== "running") statuses[agent].startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
825
|
+
if (status.state === "idle") {
|
|
826
|
+
statuses[agent].startedAt = void 0;
|
|
827
|
+
statuses[agent].task = void 0;
|
|
828
|
+
}
|
|
829
|
+
await this.saveAgentStatus(statuses);
|
|
830
|
+
}
|
|
831
|
+
async getAgentStatus(agent) {
|
|
832
|
+
return (await this.loadAgentStatus())[agent] || null;
|
|
833
|
+
}
|
|
834
|
+
async listAgentStatus() {
|
|
835
|
+
return this.loadAgentStatus();
|
|
836
|
+
}
|
|
800
837
|
async markRunStart() {
|
|
801
838
|
this.runStartIndex = (await this.syncChannel()).length;
|
|
802
839
|
}
|
|
@@ -2120,7 +2157,7 @@ Examples:
|
|
|
2120
2157
|
|
|
2121
2158
|
Note: Workflow name is inferred from YAML 'name' field or filename
|
|
2122
2159
|
`).action(async (file, options) => {
|
|
2123
|
-
const { parseWorkflowFile, runWorkflowWithControllers } = await import("../workflow-
|
|
2160
|
+
const { parseWorkflowFile, runWorkflowWithControllers } = await import("../workflow-B_y98Ood.mjs");
|
|
2124
2161
|
const tag = options.tag || DEFAULT_TAG;
|
|
2125
2162
|
const parsedWorkflow = await parseWorkflowFile(file, { tag });
|
|
2126
2163
|
const workflowName = parsedWorkflow.name;
|
|
@@ -2131,7 +2168,7 @@ Note: Workflow name is inferred from YAML 'name' field or filename
|
|
|
2131
2168
|
isCleaningUp = true;
|
|
2132
2169
|
console.log("\nInterrupted, cleaning up...");
|
|
2133
2170
|
if (controllers) {
|
|
2134
|
-
const { shutdownControllers } = await import("../workflow-
|
|
2171
|
+
const { shutdownControllers } = await import("../workflow-B_y98Ood.mjs");
|
|
2135
2172
|
const { createSilentLogger } = await import("../logger-C3ekEOzi.mjs");
|
|
2136
2173
|
await shutdownControllers(controllers, createSilentLogger());
|
|
2137
2174
|
}
|
|
@@ -2201,7 +2238,7 @@ Examples:
|
|
|
2201
2238
|
|
|
2202
2239
|
Note: Workflow name is inferred from YAML 'name' field or filename
|
|
2203
2240
|
`).action(async (file, options) => {
|
|
2204
|
-
const { parseWorkflowFile, runWorkflowWithControllers } = await import("../workflow-
|
|
2241
|
+
const { parseWorkflowFile, runWorkflowWithControllers } = await import("../workflow-B_y98Ood.mjs");
|
|
2205
2242
|
const tag = options.tag || DEFAULT_TAG;
|
|
2206
2243
|
const parsedWorkflow = await parseWorkflowFile(file, { tag });
|
|
2207
2244
|
const workflowName = parsedWorkflow.name;
|
|
@@ -2396,7 +2433,7 @@ function registerInfoCommands(program) {
|
|
|
2396
2433
|
console.log(`\nDefault: ${defaultModel} (when no model specified)`);
|
|
2397
2434
|
});
|
|
2398
2435
|
program.command("backends").description("Check available backends (SDK, CLI tools)").action(async () => {
|
|
2399
|
-
const { listBackends } = await import("../backends-
|
|
2436
|
+
const { listBackends } = await import("../backends-CoOMoMcP.mjs");
|
|
2400
2437
|
const backends = await listBackends();
|
|
2401
2438
|
console.log("Backend Status:\n");
|
|
2402
2439
|
for (const backend of backends) {
|
|
@@ -2426,7 +2463,7 @@ Examples:
|
|
|
2426
2463
|
$ agent-worker doc read @review:pr-123 # Read specific workflow:tag document
|
|
2427
2464
|
`).action(async (targetInput) => {
|
|
2428
2465
|
const dir = await resolveDir(targetInput);
|
|
2429
|
-
const { createFileContextProvider } = await import("../context-
|
|
2466
|
+
const { createFileContextProvider } = await import("../context-dgI2YCGG.mjs");
|
|
2430
2467
|
const content = await createFileContextProvider(dir, []).readDocument();
|
|
2431
2468
|
console.log(content || "(empty document)");
|
|
2432
2469
|
});
|
|
@@ -2444,7 +2481,7 @@ Examples:
|
|
|
2444
2481
|
process.exit(1);
|
|
2445
2482
|
}
|
|
2446
2483
|
const dir = await resolveDir(targetInput);
|
|
2447
|
-
const { createFileContextProvider } = await import("../context-
|
|
2484
|
+
const { createFileContextProvider } = await import("../context-dgI2YCGG.mjs");
|
|
2448
2485
|
await createFileContextProvider(dir, []).writeDocument(content);
|
|
2449
2486
|
console.log("Document written");
|
|
2450
2487
|
});
|
|
@@ -2462,7 +2499,7 @@ Examples:
|
|
|
2462
2499
|
process.exit(1);
|
|
2463
2500
|
}
|
|
2464
2501
|
const dir = await resolveDir(targetInput);
|
|
2465
|
-
const { createFileContextProvider } = await import("../context-
|
|
2502
|
+
const { createFileContextProvider } = await import("../context-dgI2YCGG.mjs");
|
|
2466
2503
|
await createFileContextProvider(dir, []).appendDocument(content);
|
|
2467
2504
|
console.log("Content appended");
|
|
2468
2505
|
});
|
|
@@ -2544,7 +2581,7 @@ Note: Requires agent to be created with --feedback flag
|
|
|
2544
2581
|
|
|
2545
2582
|
//#endregion
|
|
2546
2583
|
//#region package.json
|
|
2547
|
-
var version = "0.
|
|
2584
|
+
var version = "0.8.0";
|
|
2548
2585
|
|
|
2549
2586
|
//#endregion
|
|
2550
2587
|
//#region src/cli/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { _ as shouldUseResource, a as FileStorage, c as CONTEXT_DEFAULTS, d as RESOURCE_PREFIX, f as RESOURCE_SCHEME, g as generateResourceId, h as extractMentions, i as resolveContextDir, l as MENTION_PATTERN, m as createResourceRef, n as createFileContextProvider, o as MemoryStorage, p as calculatePriority, r as getDefaultContextDir, s as ContextProviderImpl, t as FileContextProvider, u as MESSAGE_LENGTH_THRESHOLD } from "./cli/index.mjs";
|
|
2
|
-
import { a as createMemoryContextProvider, i as MemoryContextProvider, n as formatProposal, r as formatProposalList, t as createContextMCPServer } from "./mcp-server-
|
|
2
|
+
import { a as createMemoryContextProvider, i as MemoryContextProvider, n as formatProposal, r as formatProposalList, t as createContextMCPServer } from "./mcp-server-BQCQxv2v.mjs";
|
|
3
3
|
|
|
4
4
|
export { createFileContextProvider };
|
package/dist/index.d.mts
CHANGED
|
@@ -94,7 +94,7 @@ interface SessionConfig {
|
|
|
94
94
|
approval?: Record<string, ApprovalCheck>;
|
|
95
95
|
/** Maximum tokens for response (default: 4096) */
|
|
96
96
|
maxTokens?: number;
|
|
97
|
-
/** Maximum tool call steps per turn (default:
|
|
97
|
+
/** Maximum tool call steps per turn (default: 200) */
|
|
98
98
|
maxSteps?: number;
|
|
99
99
|
}
|
|
100
100
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
import { a as createSkillsTool, c as createFeedbackTool, i as parseImportSpec, l as AgentSession, n as buildGitUrl, o as SkillsProvider, r as getSpecDisplayName, s as FEEDBACK_PROMPT, t as SkillImporter } from "./skills-
|
|
1
|
+
import { D as SUPPORTED_PROVIDERS, E as FRONTIER_MODELS, O as createModel, a as createMockBackend, c as CodexBackend, i as MockAIBackend, k as createModelAsync, l as ClaudeCodeBackend, n as createBackend, o as SdkBackend, r as listBackends, s as CursorBackend, t as checkBackends } from "./backends-rQZxF7Fl.mjs";
|
|
2
|
+
import { a as createSkillsTool, c as createFeedbackTool, i as parseImportSpec, l as AgentSession, n as buildGitUrl, o as SkillsProvider, r as getSpecDisplayName, s as FEEDBACK_PROMPT, t as SkillImporter } from "./skills-ks27oet6.mjs";
|
|
3
3
|
import { jsonSchema, tool } from "ai";
|
|
4
4
|
import { createBashTool } from "bash-tool";
|
|
5
5
|
|
|
@@ -121,7 +121,7 @@ function formatProposalList(proposals) {
|
|
|
121
121
|
* Tool Taxonomy:
|
|
122
122
|
* - Channel: channel_send, channel_read (public append-only log)
|
|
123
123
|
* - Team: team_members, team_doc_*, team_proposal_*, team_vote (shared workspace)
|
|
124
|
-
* - My: my_inbox, my_inbox_ack (personal agent tools)
|
|
124
|
+
* - My: my_inbox, my_inbox_ack, my_status_set (personal agent tools)
|
|
125
125
|
* - Resource: resource_create, resource_read (general-purpose reference mechanism)
|
|
126
126
|
* - Feedback: feedback_submit (agent observations about tools/workflows, opt-in)
|
|
127
127
|
*/
|
|
@@ -152,7 +152,7 @@ function formatInbox(messages) {
|
|
|
152
152
|
* - Team: team_members, team_doc_read, team_doc_write, team_doc_append,
|
|
153
153
|
* team_doc_list, team_doc_create, team_proposal_create, team_vote,
|
|
154
154
|
* team_proposal_status, team_proposal_cancel
|
|
155
|
-
* - My: my_inbox, my_inbox_ack
|
|
155
|
+
* - My: my_inbox, my_inbox_ack, my_status_set
|
|
156
156
|
* - Resource: resource_create, resource_read
|
|
157
157
|
*/
|
|
158
158
|
function createContextMCPServer(options) {
|
|
@@ -276,20 +276,44 @@ function createContextMCPServer(options) {
|
|
|
276
276
|
})
|
|
277
277
|
}] };
|
|
278
278
|
});
|
|
279
|
-
server.tool("
|
|
279
|
+
server.tool("my_status_set", "Update your status and current task. Call when starting or completing work.", {
|
|
280
|
+
task: z.string().optional().describe("Current task description (what you're working on)"),
|
|
281
|
+
state: z.enum(["idle", "running"]).optional().describe("Agent state (running = working, idle = available)"),
|
|
282
|
+
metadata: z.record(z.unknown()).optional().describe("Additional metadata (e.g., PR number, file path)")
|
|
283
|
+
}, async (args, extra) => {
|
|
284
|
+
const agent = getAgentId(extra) || "anonymous";
|
|
285
|
+
logTool("my_status_set", agent, args);
|
|
286
|
+
const status = {};
|
|
287
|
+
if (args.task !== void 0) status.task = args.task;
|
|
288
|
+
if (args.state !== void 0) status.state = args.state;
|
|
289
|
+
if (args.metadata !== void 0) status.metadata = args.metadata;
|
|
290
|
+
await provider.setAgentStatus(agent, status);
|
|
291
|
+
return { content: [{
|
|
292
|
+
type: "text",
|
|
293
|
+
text: JSON.stringify({
|
|
294
|
+
status: "updated",
|
|
295
|
+
agent,
|
|
296
|
+
...status
|
|
297
|
+
})
|
|
298
|
+
}] };
|
|
299
|
+
});
|
|
300
|
+
server.tool("team_members", "List all agents in this workflow. Use to discover who you can @mention. Optionally includes agent status (state, current task).", { includeStatus: z.boolean().optional().describe("Include agent status information") }, async (args, extra) => {
|
|
280
301
|
const currentAgent = getAgentId(extra) || "anonymous";
|
|
302
|
+
const includeStatus = args.includeStatus ?? false;
|
|
281
303
|
const agents = validAgents.map((name) => ({
|
|
282
304
|
name,
|
|
283
305
|
mention: `@${name}`,
|
|
284
306
|
isYou: name === currentAgent
|
|
285
307
|
}));
|
|
308
|
+
const result = {
|
|
309
|
+
agents,
|
|
310
|
+
count: agents.length,
|
|
311
|
+
hint: "Use @agent in channel_send to mention other agents"
|
|
312
|
+
};
|
|
313
|
+
if (includeStatus) result.status = await provider.listAgentStatus();
|
|
286
314
|
return { content: [{
|
|
287
315
|
type: "text",
|
|
288
|
-
text: JSON.stringify(
|
|
289
|
-
agents,
|
|
290
|
-
count: agents.length,
|
|
291
|
-
hint: "Use @agent in channel_send to mention other agents"
|
|
292
|
-
})
|
|
316
|
+
text: JSON.stringify(result)
|
|
293
317
|
}] };
|
|
294
318
|
});
|
|
295
319
|
server.tool("team_doc_read", "Read a shared team document.", { file: z.string().optional().describe("Document file path (default: notes.md)") }, async ({ file }, extra) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as createModelAsync } from "./backends-rQZxF7Fl.mjs";
|
|
2
2
|
import { ToolLoopAgent, jsonSchema, stepCountIs, tool } from "ai";
|
|
3
3
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
4
4
|
import { join, normalize } from "node:path";
|
|
@@ -70,7 +70,7 @@ var AgentSession = class {
|
|
|
70
70
|
this.tools = config.tools ? { ...config.tools } : {};
|
|
71
71
|
this.approval = config.approval ? { ...config.approval } : {};
|
|
72
72
|
this.maxTokens = config.maxTokens ?? 4096;
|
|
73
|
-
this.maxSteps = config.maxSteps ??
|
|
73
|
+
this.maxSteps = config.maxSteps ?? 200;
|
|
74
74
|
this.backend = config.backend ?? null;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -238,6 +238,7 @@ var AgentSession = class {
|
|
|
238
238
|
this.totalUsage.input += usage.input;
|
|
239
239
|
this.totalUsage.output += usage.output;
|
|
240
240
|
this.totalUsage.total += usage.total;
|
|
241
|
+
if (this.maxSteps > 0 && stepNumber >= this.maxSteps && allToolCalls.length > 0) console.warn(`⚠️ Agent reached maxSteps limit (${this.maxSteps}) but wanted to continue. Consider increasing maxSteps or removing the limit.`);
|
|
241
242
|
const currentPending = this.pendingApprovals.filter((p) => p.status === "pending");
|
|
242
243
|
return {
|
|
243
244
|
content: result.text,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as parseModel, a as createMockBackend, k as createModelAsync, n as createBackend } from "./backends-rQZxF7Fl.mjs";
|
|
2
2
|
import { c as CONTEXT_DEFAULTS, i as resolveContextDir, n as createFileContextProvider, t as FileContextProvider } from "./cli/index.mjs";
|
|
3
|
-
import { a as createMemoryContextProvider, t as createContextMCPServer } from "./mcp-server-
|
|
3
|
+
import { a as createMemoryContextProvider, t as createContextMCPServer } from "./mcp-server-BQCQxv2v.mjs";
|
|
4
4
|
import { createChannelLogger, createSilentLogger } from "./logger-C3ekEOzi.mjs";
|
|
5
5
|
import { generateText, jsonSchema, stepCountIs, tool } from "ai";
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
@@ -493,12 +493,13 @@ function buildAgentPrompt(ctx) {
|
|
|
493
493
|
sections.push("- **channel_read**: Read recent channel messages (DMs and logs are auto-filtered).");
|
|
494
494
|
sections.push("");
|
|
495
495
|
sections.push("### Team Tools");
|
|
496
|
-
sections.push("- **team_members**: List all agents you can @mention.");
|
|
496
|
+
sections.push("- **team_members**: List all agents you can @mention. Pass includeStatus=true to see their current state and tasks.");
|
|
497
497
|
sections.push("- **team_doc_read/write/append/list/create**: Shared team documents.");
|
|
498
498
|
sections.push("");
|
|
499
499
|
sections.push("### Personal Tools");
|
|
500
500
|
sections.push("- **my_inbox**: Check your unread messages.");
|
|
501
|
-
sections.push("- **my_inbox_ack**: Acknowledge messages after processing (pass the latest
|
|
501
|
+
sections.push("- **my_inbox_ack**: Acknowledge messages after processing (pass the latest message ID).");
|
|
502
|
+
sections.push("- **my_status_set**: Update your status. Call when starting work (state='running', task='...') or when done (state='idle').");
|
|
502
503
|
sections.push("");
|
|
503
504
|
sections.push("### Proposal & Voting Tools");
|
|
504
505
|
sections.push("- **team_proposal_create**: Create a proposal for team voting (types: election, decision, approval, assignment).");
|
|
@@ -809,7 +810,7 @@ async function runSdkAgent(ctx, debugLog) {
|
|
|
809
810
|
system: ctx.agent.resolvedSystemPrompt,
|
|
810
811
|
prompt,
|
|
811
812
|
maxOutputTokens: ctx.agent.max_tokens ?? 8192,
|
|
812
|
-
stopWhen: stepCountIs(ctx.agent.max_steps ??
|
|
813
|
+
stopWhen: stepCountIs(ctx.agent.max_steps ?? 200),
|
|
813
814
|
onStepFinish: (step) => {
|
|
814
815
|
_stepNum++;
|
|
815
816
|
if (step.toolCalls?.length) {
|
|
@@ -827,6 +828,12 @@ async function runSdkAgent(ctx, debugLog) {
|
|
|
827
828
|
}
|
|
828
829
|
});
|
|
829
830
|
const totalToolCalls = result.steps.reduce((n, s) => n + s.toolCalls.length, 0);
|
|
831
|
+
const lastStep = result.steps[result.steps.length - 1];
|
|
832
|
+
if (ctx.agent.max_steps && result.steps.length >= ctx.agent.max_steps && (lastStep?.toolCalls?.length ?? 0) > 0) {
|
|
833
|
+
const warning = `⚠️ Agent reached max_steps limit (${ctx.agent.max_steps}) but wanted to continue. Consider increasing max_steps or removing the limit.`;
|
|
834
|
+
log(warning);
|
|
835
|
+
await ctx.provider.appendChannel(ctx.name, warning, { kind: "log" }).catch(() => {});
|
|
836
|
+
}
|
|
830
837
|
await mcp.close();
|
|
831
838
|
return {
|
|
832
839
|
success: true,
|
|
@@ -895,6 +902,7 @@ function createAgentController(config) {
|
|
|
895
902
|
const inbox = await contextProvider.getInbox(name);
|
|
896
903
|
if (inbox.length === 0) {
|
|
897
904
|
state = "idle";
|
|
905
|
+
await contextProvider.setAgentStatus(name, { state: "idle" });
|
|
898
906
|
continue;
|
|
899
907
|
}
|
|
900
908
|
const senders = inbox.map((m) => m.entry.from);
|
|
@@ -910,6 +918,7 @@ function createAgentController(config) {
|
|
|
910
918
|
while (attempt < retryConfig.maxAttempts && shouldContinue(state)) {
|
|
911
919
|
attempt++;
|
|
912
920
|
state = "running";
|
|
921
|
+
await contextProvider.setAgentStatus(name, { state: "running" });
|
|
913
922
|
infoLog(`Running (attempt ${attempt}/${retryConfig.maxAttempts})`);
|
|
914
923
|
lastResult = await runAgent(backend, {
|
|
915
924
|
name,
|
|
@@ -931,6 +940,7 @@ function createAgentController(config) {
|
|
|
931
940
|
infoLog(`DONE ${lastResult.steps ? `${lastResult.steps} steps, ${lastResult.toolCalls} tool calls, ${lastResult.duration}ms` : `${lastResult.duration}ms`}`);
|
|
932
941
|
if (lastResult.content) await contextProvider.appendChannel(name, lastResult.content);
|
|
933
942
|
await contextProvider.ackInbox(name, latestId);
|
|
943
|
+
await contextProvider.setAgentStatus(name, { state: "idle" });
|
|
934
944
|
break;
|
|
935
945
|
}
|
|
936
946
|
errorLog(`ERROR ${lastResult.error}`);
|
|
@@ -946,6 +956,7 @@ function createAgentController(config) {
|
|
|
946
956
|
}
|
|
947
957
|
if (lastResult && onRunComplete) onRunComplete(lastResult);
|
|
948
958
|
state = "idle";
|
|
959
|
+
await contextProvider.setAgentStatus(name, { state: "idle" });
|
|
949
960
|
}
|
|
950
961
|
}
|
|
951
962
|
return {
|
|
@@ -958,15 +969,18 @@ function createAgentController(config) {
|
|
|
958
969
|
async start() {
|
|
959
970
|
if (state !== "stopped") throw new Error(`Controller ${name} is already running`);
|
|
960
971
|
state = "idle";
|
|
972
|
+
await contextProvider.setAgentStatus(name, { state: "idle" });
|
|
961
973
|
infoLog(`Starting`);
|
|
962
974
|
runLoop().catch((error) => {
|
|
963
975
|
errorLog(`ERROR ${error instanceof Error ? error.message : String(error)}`);
|
|
964
976
|
state = "stopped";
|
|
977
|
+
contextProvider.setAgentStatus(name, { state: "stopped" }).catch(() => {});
|
|
965
978
|
});
|
|
966
979
|
},
|
|
967
980
|
async stop() {
|
|
968
981
|
log(`Stopping`);
|
|
969
982
|
state = "stopped";
|
|
983
|
+
await contextProvider.setAgentStatus(name, { state: "stopped" });
|
|
970
984
|
if (backend.abort) backend.abort();
|
|
971
985
|
if (pollTimeout) {
|
|
972
986
|
clearTimeout(pollTimeout);
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { C as getModelForBackend, S as SDK_MODEL_ALIASES, _ as execWithIdleTimeout, a as createMockBackend, b as CODEX_MODEL_MAP, c as CodexBackend, d as codexAdapter, f as createStreamParser, g as IdleTimeoutError, h as formatEvent, i as MockAIBackend, l as ClaudeCodeBackend, m as extractCodexResult, n as createBackend, o as SdkBackend, p as extractClaudeResult, r as listBackends, s as CursorBackend, t as checkBackends, u as claudeAdapter, v as BACKEND_DEFAULT_MODELS, x as CURSOR_MODEL_MAP, y as CLAUDE_MODEL_MAP } from "./backends-Hclwb_Zp.mjs";
|
|
2
|
-
|
|
3
|
-
export { listBackends };
|