@blade-hq/agent-client 2610.0.0-beta.27 → 2610.0.0-beta.28
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/index.js
CHANGED
|
@@ -472,6 +472,7 @@ var SessionInfo = type({
|
|
|
472
472
|
"disable_tools?": "string[]",
|
|
473
473
|
"runtime_type?": "string | null",
|
|
474
474
|
"daemon_id?": "string | null",
|
|
475
|
+
"agent_runtime_id?": "string | null",
|
|
475
476
|
"workspace_path?": "string | null",
|
|
476
477
|
"match?": "unknown"
|
|
477
478
|
});
|
|
@@ -1566,7 +1567,10 @@ var ClientProjectionBuilder = class {
|
|
|
1566
1567
|
);
|
|
1567
1568
|
}
|
|
1568
1569
|
}
|
|
1569
|
-
|
|
1570
|
+
const isNativeProviderResponse = typeof payload.provider === "string" && payload.provider !== "";
|
|
1571
|
+
if (state.toolCalls.length === 0 || isNativeProviderResponse && state.toolCalls.every(
|
|
1572
|
+
(toolCall) => toolCall.status !== "pending" && toolCall.status !== "awaiting_answer"
|
|
1573
|
+
)) {
|
|
1570
1574
|
return this.finalize(loopId, "completed");
|
|
1571
1575
|
}
|
|
1572
1576
|
return this.syncPatch(state);
|
|
@@ -1580,7 +1584,8 @@ var ClientProjectionBuilder = class {
|
|
|
1580
1584
|
const durationMs = typeof rawDuration === "number" && rawDuration >= 0 ? Math.round(rawDuration) : null;
|
|
1581
1585
|
const sl = sourceLoopFor(state.loopId, this.loopDescriptions);
|
|
1582
1586
|
applyToolResult(state, toolCallId, content, status, durationMs, sl);
|
|
1583
|
-
|
|
1587
|
+
const isNativeProviderResult = typeof payload.provider === "string" && payload.provider !== "";
|
|
1588
|
+
if (!isNativeProviderResult && this.shouldFinalizeAfterToolResults(state)) {
|
|
1584
1589
|
return this.finalize(loopId, "completed");
|
|
1585
1590
|
}
|
|
1586
1591
|
return this.syncPatch(state);
|
|
@@ -1621,6 +1626,11 @@ var ClientProjectionBuilder = class {
|
|
|
1621
1626
|
const toolName = String(payload.tool_name ?? "");
|
|
1622
1627
|
const displayName = this.displayNameResolver(toolName);
|
|
1623
1628
|
upsertToolCall(state, toolCallId, toolName, displayName, "");
|
|
1629
|
+
const relatedToolCallId = String(payload.related_tool_call_id ?? "");
|
|
1630
|
+
if (relatedToolCallId && relatedToolCallId !== toolCallId) {
|
|
1631
|
+
const related = state.toolCalls.find((toolCall) => toolCall.id === relatedToolCallId);
|
|
1632
|
+
if (related) related.status = "awaiting_answer";
|
|
1633
|
+
}
|
|
1624
1634
|
return this.syncPatch(state);
|
|
1625
1635
|
}
|
|
1626
1636
|
onChildPause(state, loopId, payload) {
|
|
@@ -1877,6 +1887,7 @@ function projectHistory(entries) {
|
|
|
1877
1887
|
const latestAssistantByLoop = /* @__PURE__ */ new Map();
|
|
1878
1888
|
const pendingChildPauses = /* @__PURE__ */ new Map();
|
|
1879
1889
|
const answeredToolCallIds = /* @__PURE__ */ new Set();
|
|
1890
|
+
const nativeToolTurns = /* @__PURE__ */ new Set();
|
|
1880
1891
|
let latestRootMessage = null;
|
|
1881
1892
|
let latestRootAssistant = null;
|
|
1882
1893
|
let sequence = 0;
|
|
@@ -1936,10 +1947,27 @@ function projectHistory(entries) {
|
|
|
1936
1947
|
duration_ms: numberOrZero(message._duration_ms),
|
|
1937
1948
|
started_at: typeof entry.timestamp === "string" ? entry.timestamp : void 0
|
|
1938
1949
|
};
|
|
1950
|
+
const isNativeToolEntry = role === "assistant" && Array.isArray(message.tool_calls) && message.tool_calls.some(
|
|
1951
|
+
(toolCall) => isRecord4(toolCall) && typeof toolCall.provider === "string"
|
|
1952
|
+
);
|
|
1953
|
+
const previousTurn = turns[turns.length - 1];
|
|
1954
|
+
if (role === "assistant" && previousTurn?.role === "assistant" && previousTurn.loop_id === loopId && nativeToolTurns.has(previousTurn)) {
|
|
1955
|
+
previousTurn.blocks.push(...turn.blocks);
|
|
1956
|
+
previousTurn.tool_calls.push(...turn.tool_calls);
|
|
1957
|
+
previousTurn.status = turn.status;
|
|
1958
|
+
previousTurn.model = turn.model ?? previousTurn.model;
|
|
1959
|
+
previousTurn.usage = turn.usage ?? previousTurn.usage;
|
|
1960
|
+
previousTurn.duration_ms = turn.duration_ms || previousTurn.duration_ms;
|
|
1961
|
+
if (turn.started_at) previousTurn.started_at = turn.started_at;
|
|
1962
|
+
if (loopId === "root") latestRootMessage = previousTurn;
|
|
1963
|
+
latestAssistantByLoop.set(loopId, previousTurn);
|
|
1964
|
+
continue;
|
|
1965
|
+
}
|
|
1939
1966
|
if (loopId === "root" && (role === "user" || role === "assistant")) {
|
|
1940
1967
|
latestRootMessage = turn;
|
|
1941
1968
|
}
|
|
1942
1969
|
turns.push(turn);
|
|
1970
|
+
if (isNativeToolEntry) nativeToolTurns.add(turn);
|
|
1943
1971
|
if (role === "assistant") latestAssistantByLoop.set(loopId, turn);
|
|
1944
1972
|
if (loopId === "root") {
|
|
1945
1973
|
if (role === "assistant") latestRootAssistant = turn;
|
|
@@ -1948,6 +1976,21 @@ function projectHistory(entries) {
|
|
|
1948
1976
|
for (const toolCall of toolCalls) toolOwners.set(toolCall.id, turn);
|
|
1949
1977
|
continue;
|
|
1950
1978
|
}
|
|
1979
|
+
if (kind === "tool_result") {
|
|
1980
|
+
const data = entry.data ?? {};
|
|
1981
|
+
const toolCallId = String(data.tool_call_id ?? "");
|
|
1982
|
+
const owner = toolOwners.get(toolCallId) ?? findLatestAssistant(turns, loopId);
|
|
1983
|
+
if (owner && toolCallId) {
|
|
1984
|
+
const rawContent = data.content;
|
|
1985
|
+
const content = typeof rawContent === "string" ? rawContent : Array.isArray(rawContent) ? rawContent : String(rawContent ?? "");
|
|
1986
|
+
const status = data.is_error === true ? "error" : inferToolStatus(typeof content === "string" ? content : JSON.stringify(content));
|
|
1987
|
+
setToolCallStatus(owner, toolCallId, status, content, null);
|
|
1988
|
+
if (!owner.blocks.some((block) => block.type === "tool_result" && block.tool_call_id === toolCallId)) {
|
|
1989
|
+
owner.blocks.push({ type: "tool_result", content, tool_call_id: toolCallId });
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
continue;
|
|
1993
|
+
}
|
|
1951
1994
|
if (kind === "mode_change") {
|
|
1952
1995
|
turns.push(markerTurn(id, ++sequence, loopId, "mode_change", entry.data ?? {}));
|
|
1953
1996
|
} else if (kind === "workspace_change") {
|
|
@@ -2196,7 +2239,8 @@ function toCreateSessionPayload(request) {
|
|
|
2196
2239
|
solution_snapshot_session_id: request.solution_snapshot_session_id ?? null,
|
|
2197
2240
|
compaction_ratio: request.compaction_ratio ?? null,
|
|
2198
2241
|
...request.runtime_type ? { runtime_type: request.runtime_type } : {},
|
|
2199
|
-
...request.daemon_id ? { daemon_id: request.daemon_id } : {}
|
|
2242
|
+
...request.daemon_id ? { daemon_id: request.daemon_id } : {},
|
|
2243
|
+
...request.agent_runtime_id ? { agent_runtime_id: request.agent_runtime_id } : {}
|
|
2200
2244
|
};
|
|
2201
2245
|
}
|
|
2202
2246
|
var builtinSolutionIds = /* @__PURE__ */ new Set([
|
|
@@ -3519,6 +3563,7 @@ var AgentSession = class _AgentSession {
|
|
|
3519
3563
|
replayQueue = Promise.resolve();
|
|
3520
3564
|
pendingReplayMessage = null;
|
|
3521
3565
|
pendingReplayMode;
|
|
3566
|
+
pendingReplayKbIds;
|
|
3522
3567
|
recentChatEndAt = 0;
|
|
3523
3568
|
disposed = false;
|
|
3524
3569
|
getAppContext = null;
|
|
@@ -3687,6 +3732,7 @@ var AgentSession = class _AgentSession {
|
|
|
3687
3732
|
if (!options.replayDecision) {
|
|
3688
3733
|
this.pendingReplayMessage = content;
|
|
3689
3734
|
this.pendingReplayMode = options.mode;
|
|
3735
|
+
this.pendingReplayKbIds = options.kbIds;
|
|
3690
3736
|
}
|
|
3691
3737
|
const payload = {
|
|
3692
3738
|
session_id: this.sessionId,
|
|
@@ -3697,7 +3743,8 @@ var AgentSession = class _AgentSession {
|
|
|
3697
3743
|
thinking_override: options.thinkingOverride,
|
|
3698
3744
|
whatif: options.whatif,
|
|
3699
3745
|
replay_decision: options.replayDecision,
|
|
3700
|
-
app_context: appContext
|
|
3746
|
+
app_context: appContext,
|
|
3747
|
+
kb_ids: options.kbIds && options.kbIds.length > 0 ? options.kbIds : void 0
|
|
3701
3748
|
};
|
|
3702
3749
|
try {
|
|
3703
3750
|
await this.ensureJoined();
|
|
@@ -3733,6 +3780,7 @@ var AgentSession = class _AgentSession {
|
|
|
3733
3780
|
rollbackOptimisticSend(optimisticTurnId, askUserAnswer, optimisticAskAnswer, previousAskAnswer, message) {
|
|
3734
3781
|
this.pendingReplayMessage = null;
|
|
3735
3782
|
this.pendingReplayMode = void 0;
|
|
3783
|
+
this.pendingReplayKbIds = void 0;
|
|
3736
3784
|
this.update((current) => {
|
|
3737
3785
|
let next = optimisticTurnId ? withTurns(
|
|
3738
3786
|
current,
|
|
@@ -3914,7 +3962,7 @@ var AgentSession = class _AgentSession {
|
|
|
3914
3962
|
_handleTurnEvents(events) {
|
|
3915
3963
|
if (!events.length) return;
|
|
3916
3964
|
const terminalChatEndStatus = extractTerminalChatEndStatus(events);
|
|
3917
|
-
if (!terminalChatEndStatus && hasChatRunEvent2(events)) {
|
|
3965
|
+
if (!terminalChatEndStatus && hasChatRunEvent2(events) && this.state.status !== "waiting_for_input") {
|
|
3918
3966
|
this.markRunningIfIdle();
|
|
3919
3967
|
}
|
|
3920
3968
|
if (this.state.turns.length) {
|
|
@@ -3986,8 +4034,10 @@ var AgentSession = class _AgentSession {
|
|
|
3986
4034
|
_handleReplayMismatch(data) {
|
|
3987
4035
|
const message = this.pendingReplayMessage ?? data.actual_message ?? "";
|
|
3988
4036
|
const mode = this.pendingReplayMode;
|
|
4037
|
+
const kbIds = this.pendingReplayKbIds;
|
|
3989
4038
|
this.pendingReplayMessage = null;
|
|
3990
4039
|
this.pendingReplayMode = void 0;
|
|
4040
|
+
this.pendingReplayKbIds = void 0;
|
|
3991
4041
|
const respond = (decision) => {
|
|
3992
4042
|
void this.runtime.emitWithAck(
|
|
3993
4043
|
"chat:send",
|
|
@@ -3995,7 +4045,8 @@ var AgentSession = class _AgentSession {
|
|
|
3995
4045
|
session_id: this.sessionId,
|
|
3996
4046
|
message,
|
|
3997
4047
|
mode,
|
|
3998
|
-
replay_decision: decision
|
|
4048
|
+
replay_decision: decision,
|
|
4049
|
+
kb_ids: kbIds && kbIds.length > 0 ? kbIds : void 0
|
|
3999
4050
|
},
|
|
4000
4051
|
3e4
|
|
4001
4052
|
).then((response) => {
|
|
@@ -4650,7 +4701,7 @@ function resolveAuthToken(options) {
|
|
|
4650
4701
|
|
|
4651
4702
|
// src/version.ts
|
|
4652
4703
|
var SDK_NAME = "agent-client";
|
|
4653
|
-
var SDK_VERSION = true ? "2610.0.0-beta.
|
|
4704
|
+
var SDK_VERSION = true ? "2610.0.0-beta.28" : "1.1.1";
|
|
4654
4705
|
|
|
4655
4706
|
// src/socket.ts
|
|
4656
4707
|
function withSdkIdentity(auth) {
|