@atlasharness/atlascode 0.1.8 → 0.1.10
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/cli.js +61 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -791,6 +791,7 @@ async function executeToolUse(tu, assistantMsg, deps) {
|
|
|
791
791
|
isError: true
|
|
792
792
|
};
|
|
793
793
|
}
|
|
794
|
+
const toolCallContext = deps.toolContext !== undefined ? { ...deps.toolContext, signal: deps.signal, checkPermission: deps.checkPermission } : { signal: deps.signal, checkPermission: deps.checkPermission };
|
|
794
795
|
const schemaResult = validateInputBySchema(tu.input, tool.inputSchema);
|
|
795
796
|
if (schemaResult.valid === false) {
|
|
796
797
|
const discovered = deps.discoveredToolNames ?? new Set(deps.tools.map((t) => t.name));
|
|
@@ -806,7 +807,7 @@ async function executeToolUse(tu, assistantMsg, deps) {
|
|
|
806
807
|
isError: true
|
|
807
808
|
};
|
|
808
809
|
}
|
|
809
|
-
const validation = await tool.validateInput?.(tu.input,
|
|
810
|
+
const validation = await tool.validateInput?.(tu.input, toolCallContext);
|
|
810
811
|
if (validation && validation.result === false) {
|
|
811
812
|
return {
|
|
812
813
|
block: {
|
|
@@ -863,7 +864,7 @@ async function executeToolUse(tu, assistantMsg, deps) {
|
|
|
863
864
|
let block;
|
|
864
865
|
let isError = false;
|
|
865
866
|
try {
|
|
866
|
-
const res = await tool.call(callInput,
|
|
867
|
+
const res = await tool.call(callInput, toolCallContext, undefined, assistantMsg);
|
|
867
868
|
block = tool.mapToolResultToToolResultBlockParam(res.data, tu.id);
|
|
868
869
|
} catch (error) {
|
|
869
870
|
block = {
|
|
@@ -80437,7 +80438,7 @@ var init_context = __esm(() => {
|
|
|
80437
80438
|
// src/engine/query/loop.ts
|
|
80438
80439
|
import { randomUUID as randomUUID18 } from "crypto";
|
|
80439
80440
|
async function queryOneRound(deps, tools, messages) {
|
|
80440
|
-
const
|
|
80441
|
+
const chatArgs = {
|
|
80441
80442
|
messages,
|
|
80442
80443
|
role: deps.role,
|
|
80443
80444
|
sessionModel: deps.sessionModel,
|
|
@@ -80448,8 +80449,30 @@ async function queryOneRound(deps, tools, messages) {
|
|
|
80448
80449
|
responseFormat: deps.responseFormat,
|
|
80449
80450
|
fallbackModel: deps.fallbackModel,
|
|
80450
80451
|
options: deps.effortValue !== undefined ? { effortValue: deps.effortValue } : undefined
|
|
80451
|
-
}
|
|
80452
|
-
|
|
80452
|
+
};
|
|
80453
|
+
let resp = await deps.modelProvider.chat(chatArgs);
|
|
80454
|
+
let assistantContent = resp.message.content ?? [];
|
|
80455
|
+
const isEmptyContent = (content) => {
|
|
80456
|
+
if (!Array.isArray(content))
|
|
80457
|
+
return true;
|
|
80458
|
+
return !content.some((block) => {
|
|
80459
|
+
const b = block;
|
|
80460
|
+
if (!b)
|
|
80461
|
+
return false;
|
|
80462
|
+
if (b.type === "tool_use")
|
|
80463
|
+
return true;
|
|
80464
|
+
return b.type === "text" && String(b.text ?? "").trim() !== "";
|
|
80465
|
+
});
|
|
80466
|
+
};
|
|
80467
|
+
if (isEmptyContent(assistantContent) && !deps.signal?.aborted) {
|
|
80468
|
+
const retried = await deps.modelProvider.chat(chatArgs);
|
|
80469
|
+
const retriedContent = retried.message.content ?? [];
|
|
80470
|
+
if (!isEmptyContent(retriedContent)) {
|
|
80471
|
+
resp = retried;
|
|
80472
|
+
assistantContent = retriedContent;
|
|
80473
|
+
}
|
|
80474
|
+
}
|
|
80475
|
+
const empty = isEmptyContent(assistantContent);
|
|
80453
80476
|
const assistantMsg = {
|
|
80454
80477
|
type: "assistant",
|
|
80455
80478
|
role: "assistant",
|
|
@@ -80463,7 +80486,8 @@ async function queryOneRound(deps, tools, messages) {
|
|
|
80463
80486
|
tools,
|
|
80464
80487
|
signal: deps.signal,
|
|
80465
80488
|
checkPermission: deps.checkPermission,
|
|
80466
|
-
hooks: deps.hooks?.toolHooks
|
|
80489
|
+
hooks: deps.hooks?.toolHooks,
|
|
80490
|
+
toolContext: deps.toolContext
|
|
80467
80491
|
});
|
|
80468
80492
|
const toolResults = outcomes.map((o) => ({
|
|
80469
80493
|
toolUseId: o.toolUseId,
|
|
@@ -80485,7 +80509,8 @@ async function queryOneRound(deps, tools, messages) {
|
|
|
80485
80509
|
messages: [...messages, assistantMsg, ...resultMessages],
|
|
80486
80510
|
toolResults,
|
|
80487
80511
|
assistantContent,
|
|
80488
|
-
stopReason: resp.message.stop_reason
|
|
80512
|
+
stopReason: resp.message.stop_reason,
|
|
80513
|
+
empty
|
|
80489
80514
|
};
|
|
80490
80515
|
}
|
|
80491
80516
|
async function queryAgentLoop(deps, args) {
|
|
@@ -80556,7 +80581,15 @@ async function queryAgentLoop(deps, args) {
|
|
|
80556
80581
|
tracking = { ...tracking, turnCounter: tracking.turnCounter + 1 };
|
|
80557
80582
|
}
|
|
80558
80583
|
}
|
|
80559
|
-
const
|
|
80584
|
+
const emptyTerminated = lastRound?.empty === true;
|
|
80585
|
+
const result = {
|
|
80586
|
+
messages,
|
|
80587
|
+
turns,
|
|
80588
|
+
terminated,
|
|
80589
|
+
tracking,
|
|
80590
|
+
lastRound,
|
|
80591
|
+
emptyTerminated
|
|
80592
|
+
};
|
|
80560
80593
|
deps.emit?.({ type: "loop_end", result });
|
|
80561
80594
|
return result;
|
|
80562
80595
|
}
|
|
@@ -178813,6 +178846,7 @@ function getSimpleDoingTasksSection() {
|
|
|
178813
178846
|
];
|
|
178814
178847
|
const items = [
|
|
178815
178848
|
`The user will primarily request you to perform software engineering tasks. These may include solving bugs, adding new functionality, refactoring code, explaining code, and more. When given an unclear or generic instruction, consider it in the context of these software engineering tasks and the current working directory. For example, if the user asks you to change "methodName" to snake case, do not reply with just "method_name", instead find the method in the code and modify the code.`,
|
|
178849
|
+
`When the working directory is empty or the target file does not yet exist, proceed directly to creating or writing what the task needs — do not spend turns probing the environment (ls, tool version checks, etc.) first. Only run a probe when you genuinely need its output to decide the next step.`,
|
|
178816
178850
|
`You are highly capable and often allow users to complete ambitious tasks that would otherwise be too complex or take too long. You should defer to user judgement about whether a task is too large to attempt.`,
|
|
178817
178851
|
`In general, do not propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.`,
|
|
178818
178852
|
`Do not create files unless they're absolutely necessary for achieving your goal. Generally prefer editing an existing file to creating a new one, as this prevents file bloat and builds on existing work more effectively.`,
|
|
@@ -270014,9 +270048,6 @@ function AssistantMessageBlock(t0) {
|
|
|
270014
270048
|
return t1;
|
|
270015
270049
|
}
|
|
270016
270050
|
case "thinking": {
|
|
270017
|
-
if (!isTranscriptMode && !verbose) {
|
|
270018
|
-
return null;
|
|
270019
|
-
}
|
|
270020
270051
|
const isLastThinking = !lastThinkingBlockId || thinkingBlockId === lastThinkingBlockId;
|
|
270021
270052
|
const t1 = isTranscriptMode && !isLastThinking;
|
|
270022
270053
|
let t2;
|
|
@@ -318883,6 +318914,7 @@ function buildAgentLoopParams(m) {
|
|
|
318883
318914
|
canUseTool: m.canUseTool,
|
|
318884
318915
|
toolUseContext: m.toolUseContext
|
|
318885
318916
|
}),
|
|
318917
|
+
toolContext: m.toolUseContext,
|
|
318886
318918
|
hooks: createLoopHooks({
|
|
318887
318919
|
options: {
|
|
318888
318920
|
sessionId: getSessionId(),
|
|
@@ -475546,11 +475578,21 @@ Error: sandbox required but unavailable: ${reason}
|
|
|
475546
475578
|
toolUseContext,
|
|
475547
475579
|
querySource: getQuerySourceForREPL()
|
|
475548
475580
|
});
|
|
475549
|
-
|
|
475581
|
+
const loopGen = queryEngineLoopStream({
|
|
475550
475582
|
deps: loopDeps,
|
|
475551
475583
|
args: loopArgs
|
|
475552
|
-
})
|
|
475553
|
-
|
|
475584
|
+
});
|
|
475585
|
+
let loopResult;
|
|
475586
|
+
{
|
|
475587
|
+
let iter = await loopGen.next();
|
|
475588
|
+
while (!iter.done) {
|
|
475589
|
+
onQueryEvent(iter.value);
|
|
475590
|
+
iter = await loopGen.next();
|
|
475591
|
+
}
|
|
475592
|
+
loopResult = iter.value;
|
|
475593
|
+
}
|
|
475594
|
+
if (loopResult?.emptyTerminated) {
|
|
475595
|
+
setMessages((prev) => [...prev, createSystemMessage("本轮未产生任何响应(模型空输出,已重试仍为空)。请重试,或检查网关连接与模型配置。", "warning")]);
|
|
475554
475596
|
}
|
|
475555
475597
|
queryCheckpoint("query_end");
|
|
475556
475598
|
resetLoadingState();
|
|
@@ -475598,6 +475640,9 @@ Error: sandbox required but unavailable: ${reason}
|
|
|
475598
475640
|
}
|
|
475599
475641
|
}
|
|
475600
475642
|
await onQueryImpl(latestMessages, newMessages, abortController, shouldQuery, additionalAllowedTools, mainLoopModelParam, effort);
|
|
475643
|
+
} catch (error) {
|
|
475644
|
+
logError3(error);
|
|
475645
|
+
setMessages((prev) => [...prev, createSystemMessage(`本轮执行出错:${errorMessage2(error)}。请重试。`, "error")]);
|
|
475601
475646
|
} finally {
|
|
475602
475647
|
if (queryGuard.end(thisGeneration)) {
|
|
475603
475648
|
setLastQueryCompletionTime(Date.now());
|
|
@@ -493576,7 +493621,8 @@ async function binMain() {
|
|
|
493576
493621
|
await runDevCli();
|
|
493577
493622
|
return;
|
|
493578
493623
|
}
|
|
493579
|
-
const
|
|
493624
|
+
const hasPrintFlag = argv.includes("-p") || argv.includes("--print");
|
|
493625
|
+
const isTuiInvocation = argv.length === 0 || argv[0] === "code" || argv[0].startsWith("-") && !hasPrintFlag;
|
|
493580
493626
|
if (isTuiInvocation) {
|
|
493581
493627
|
if (argv[0] === "code") {
|
|
493582
493628
|
process.argv = [process.argv[0], process.argv[1], ...argv.slice(1)];
|
package/package.json
CHANGED