@sema-agent/core 5.7.0 → 5.9.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/CHANGELOG.md +79 -0
- package/dist/agents/cascade.d.ts +1 -1
- package/dist/agents/cascade.js +24 -0
- package/dist/agents/subagent.d.ts +7 -7
- package/dist/agents/subagent.js +74 -33
- package/dist/agents/teacher.js +3 -3
- package/dist/agents/team.d.ts +1 -1
- package/dist/agents/team.js +1 -1
- package/dist/agents/verify.js +1 -1
- package/dist/brain/anthropic.js +24 -35
- package/dist/brain/open-responses.d.ts +11 -0
- package/dist/brain/open-responses.js +721 -0
- package/dist/brain/openai.js +22 -33
- package/dist/brain/request-params.d.ts +1 -0
- package/dist/brain/request-params.js +16 -0
- package/dist/brain/stream-engine.d.ts +0 -2
- package/dist/brain/stream-engine.js +5 -47
- package/dist/brain/stream-shared.d.ts +0 -10
- package/dist/brain/stream-shared.js +0 -23
- package/dist/brain/terminal-cause.d.ts +0 -1
- package/dist/brain/terminal-cause.js +0 -3
- package/dist/brain/timeout.d.ts +4 -2
- package/dist/brain/timeout.js +4 -14
- package/dist/config/catalog.d.ts +3 -11
- package/dist/config/catalog.js +30 -69
- package/dist/config/defaults.d.ts +0 -3
- package/dist/config/defaults.js +0 -3
- package/dist/core/auto-compaction.d.ts +2 -11
- package/dist/core/auto-compaction.js +3 -67
- package/dist/core/checkpoint-store.d.ts +10 -8
- package/dist/core/checkpoint-store.js +7 -7
- package/dist/core/fs-write-gate-policy.js +2 -2
- package/dist/core/lsp-diagnostics.d.ts +3 -2
- package/dist/core/lsp-diagnostics.js +20 -7
- package/dist/core/memory-engine/file-backend.js +20 -17
- package/dist/core/memory-engine/layout.d.ts +5 -0
- package/dist/core/memory-engine/layout.js +72 -47
- package/dist/core/runner/assemble-result.d.ts +3 -8
- package/dist/core/runner/assemble-result.js +24 -18
- package/dist/core/runner/prepare-task.d.ts +27 -6
- package/dist/core/runner/prepare-task.js +209 -144
- package/dist/core/runner/runtask.d.ts +0 -2
- package/dist/core/runner/runtask.js +228 -266
- package/dist/core/runner/session-rule-policy.d.ts +1 -0
- package/dist/core/runner/session-rule-policy.js +4 -3
- package/dist/core/session-policy-store.d.ts +5 -0
- package/dist/core/session-policy-store.js +3 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +2 -2
- package/dist/core/task-registry-agent.d.ts +2 -0
- package/dist/core/task-registry-agent.js +33 -1
- package/dist/core/task-registry-shared.d.ts +0 -1
- package/dist/core/task-registry.d.ts +2 -0
- package/dist/core/task-registry.js +9 -1
- package/dist/core/tool-errors.js +10 -2
- package/dist/core/tool-policy.d.ts +8 -0
- package/dist/core/tool-policy.js +11 -0
- package/dist/core/trace.d.ts +1 -10
- package/dist/core/types.d.ts +27 -30
- package/dist/core/usage-window-store.d.ts +39 -0
- package/dist/core/usage-window-store.js +115 -0
- package/dist/engine/execution-env/node-execution-env.js +0 -22
- package/dist/engine/harness/agent-harness.d.ts +1 -7
- package/dist/engine/harness/agent-harness.js +16 -53
- package/dist/engine/harness/types.d.ts +3 -15
- package/dist/engine/llm/types.d.ts +3 -75
- package/dist/engine/loop/agent-loop.d.ts +1 -1
- package/dist/engine/loop/agent-loop.js +7 -173
- package/dist/engine/loop/types.d.ts +1 -18
- package/dist/engine/session/repo-utils.d.ts +1 -2
- package/dist/engine/session/repo-utils.js +0 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +10 -5
- package/dist/internal/llm.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -5
- package/dist/orchestration/run-workflow-tool.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.js +1 -2
- package/dist/orchestration/workflow-governance.d.ts +6 -6
- package/dist/orchestration/workflow-governance.js +33 -47
- package/dist/orchestration/workflow.js +14 -5
- package/dist/prompt-assembly/event-registry.js +2 -3
- package/dist/stores/cc/lockfile.js +9 -11
- package/dist/stores/cc/mailbox-store.js +49 -38
- package/dist/stores/file/index.d.ts +3 -0
- package/dist/stores/file/index.js +4 -0
- package/dist/stores/file/usage-window-store.d.ts +9 -0
- package/dist/stores/file/usage-window-store.js +86 -0
- package/dist/tools/fs/fs-bash.d.ts +1 -10
- package/dist/tools/fs/fs-bash.js +20 -60
- package/dist/tools/fs/index.d.ts +0 -2
- package/dist/tools/fs/index.js +1 -2
- package/dist/tools/web.js +20 -19
- package/package.json +4 -5
- package/dist/bin/sema-tb.d.ts +0 -31
- package/dist/bin/sema-tb.js +0 -448
- package/dist/bin/tb-env.d.ts +0 -2
- package/dist/bin/tb-env.js +0 -17
- package/dist/brain/walltime.d.ts +0 -1
- package/dist/brain/walltime.js +0 -1
- package/dist/core/runner/call-cap.d.ts +0 -67
- package/dist/core/runner/call-cap.js +0 -145
- package/dist/core/runner/cut-kill.d.ts +0 -10
- package/dist/core/runner/cut-kill.js +0 -37
package/dist/brain/anthropic.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {} from "../internal/llm.js";
|
|
2
2
|
import { BrainError } from "./errors.js";
|
|
3
3
|
import { DEGENERATE_MESSAGE, trimDegenerateTail } from "./repetition.js";
|
|
4
|
-
import { createRepetitionPoll,
|
|
4
|
+
import { createRepetitionPoll, parseStreamedToolArgs } from "./stream-shared.js";
|
|
5
5
|
import { mintFallbackToolCallId } from "./tool-call-id.js";
|
|
6
|
-
import { WALLTIME_CUTOFF_MESSAGE } from "./walltime.js";
|
|
7
6
|
import { emitBrainTelemetry } from "./status-sink.js";
|
|
8
7
|
import { errorResultMediaNote, IMAGE_OMITTED_NO_VISION, modelSupportsVision, sendableImages } from "./media-degrade.js";
|
|
9
8
|
import { ANTHROPIC_RESERVED, applyExtraBody, stripAuthHeaders } from "./request-params.js";
|
|
@@ -233,7 +232,6 @@ export function createAnthropicBrain(config = {}) {
|
|
|
233
232
|
signal: options?.signal,
|
|
234
233
|
config,
|
|
235
234
|
httpLabel: "anthropic",
|
|
236
|
-
callDeadlineMs: options?.callDeadlineMs,
|
|
237
235
|
stallTimeouts: options?.stallTimeouts,
|
|
238
236
|
buildRequest: () => {
|
|
239
237
|
const apiKey = options?.apiKey ?? config.apiKey;
|
|
@@ -342,7 +340,6 @@ export function createAnthropicBrain(config = {}) {
|
|
|
342
340
|
let degenerate = false;
|
|
343
341
|
let degenTextBlock;
|
|
344
342
|
const rep = createRepetitionPoll();
|
|
345
|
-
const walltime = createWalltimeGate({ callDeadlineMs: options?.callDeadlineMs, isDegenerate: () => degenerate, cancel: () => ctrl.cancel() });
|
|
346
343
|
let lastDegenCheck = 0;
|
|
347
344
|
let lastDegenCheckThinking = 0;
|
|
348
345
|
const detectRep = config.detectRepetition !== false;
|
|
@@ -497,10 +494,7 @@ export function createAnthropicBrain(config = {}) {
|
|
|
497
494
|
}
|
|
498
495
|
}
|
|
499
496
|
},
|
|
500
|
-
onDeadline: () => walltime.onDeadline(),
|
|
501
497
|
onLine(rawLine) {
|
|
502
|
-
if (walltime.shouldDropLine())
|
|
503
|
-
return;
|
|
504
498
|
const line = rawLine.trim();
|
|
505
499
|
if (!line.startsWith("data:"))
|
|
506
500
|
return;
|
|
@@ -576,40 +570,35 @@ export function createAnthropicBrain(config = {}) {
|
|
|
576
570
|
const staticReasoningCut = truncatedEmpty && !dynamicCut && reasoningSeen && options?.staticReasoningCutDowngrade === true;
|
|
577
571
|
const safetyCut = stopReason === "refusal";
|
|
578
572
|
const contextWindowExceeded = stopReason === "model_context_window_exceeded";
|
|
579
|
-
const emptyNoFinish = noUsableContent && stopReason == null && !degenerate
|
|
573
|
+
const emptyNoFinish = noUsableContent && stopReason == null && !degenerate;
|
|
580
574
|
const maxTokensNote = `effective max_tokens=${sentMaxTokens ?? "?"} (from ${sentMaxTokensLane === "options" ? "options.maxTokens" : sentMaxTokensLane === "model" ? "model.maxTokens" : "config default"})`;
|
|
581
|
-
const errorMessage =
|
|
582
|
-
?
|
|
583
|
-
:
|
|
584
|
-
?
|
|
585
|
-
:
|
|
586
|
-
? `[
|
|
587
|
-
:
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
? `[length_empty] response truncated at max_tokens with no answer text (${maxTokensNote}) —
|
|
593
|
-
:
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
:
|
|
597
|
-
|
|
598
|
-
: undefined));
|
|
599
|
-
const errored = walltime.cut ||
|
|
600
|
-
degenerate ||
|
|
575
|
+
const errorMessage = degenerate
|
|
576
|
+
? DEGENERATE_MESSAGE
|
|
577
|
+
: safetyCut
|
|
578
|
+
? `[refusal] response refused by the model (stop_reason="refusal"${stopDetails?.category ? `, category="${stopDetails.category}"` : ""}) — ${stopDetails?.explanation ?? "the output was withheld for policy and is unreliable"}`
|
|
579
|
+
: contextWindowExceeded
|
|
580
|
+
? `[invalid_request] model context window exceeded (stop_reason="model_context_window_exceeded") — the conversation no longer fits the model's context window`
|
|
581
|
+
: (toolError ??
|
|
582
|
+
(truncatedEmpty && !dynamicCut && !staticReasoningCut
|
|
583
|
+
? thinkingRequested
|
|
584
|
+
? `[length_empty] response truncated at max_tokens with no answer text (${maxTokensNote}) — extended thinking likely consumed the entire budget; raise max_tokens or lower thinkingBudgetShare`
|
|
585
|
+
: reasoningSeen
|
|
586
|
+
? `[length_empty] response truncated at max_tokens with no answer text (${maxTokensNote}) — the model emitted reasoning although no thinking was requested (a budget-ignoring gateway?) and it consumed the entire output budget; raise max_tokens`
|
|
587
|
+
: `[length_empty] response truncated at max_tokens with no answer text (${maxTokensNote}); raise max_tokens`
|
|
588
|
+
: emptyNoFinish
|
|
589
|
+
? `[stream_torn] model stream ended with no content and no stop_reason — the response was lost (a torn stream or an in-band provider error frame)${malformedFrames > 0 ? ` — ${malformedFrames} unparseable data frame(s) were dropped on this stream (first sample: ${JSON.stringify(malformedSample)})` : ""}`
|
|
590
|
+
: undefined));
|
|
591
|
+
const errored = degenerate ||
|
|
601
592
|
safetyCut ||
|
|
602
593
|
contextWindowExceeded ||
|
|
603
594
|
emptyNoFinish ||
|
|
604
595
|
(toolError !== undefined && noUsableContent) ||
|
|
605
596
|
(truncatedEmpty && !dynamicCut && !staticReasoningCut);
|
|
606
|
-
const errorKind =
|
|
607
|
-
? "
|
|
608
|
-
:
|
|
609
|
-
? "
|
|
610
|
-
:
|
|
611
|
-
? "length_empty"
|
|
612
|
-
: undefined;
|
|
597
|
+
const errorKind = degenerate
|
|
598
|
+
? "degenerate"
|
|
599
|
+
: !safetyCut && toolError === undefined && truncatedEmpty && !dynamicCut && !staticReasoningCut
|
|
600
|
+
? "length_empty"
|
|
601
|
+
: undefined;
|
|
613
602
|
const finalMessage = {
|
|
614
603
|
...partial,
|
|
615
604
|
content: finalContent.length > 0 ? finalContent : [{ type: "text", text: "" }],
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Brain } from "../core/types.js";
|
|
2
|
+
import { type StreamEngineConfig } from "./stream-engine.js";
|
|
3
|
+
export interface OpenResponsesBrainConfig extends StreamEngineConfig {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
fetchImpl?: typeof fetch;
|
|
8
|
+
replayReasoning?: boolean;
|
|
9
|
+
detectRepetition?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function createOpenResponsesBrain(config?: OpenResponsesBrainConfig): Brain;
|