@wrongstack/core 0.2.0 → 0.3.1
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/{agent-bridge-DmBiCipY.d.ts → agent-bridge-C3DUGjSb.d.ts} +1 -1
- package/dist/{compactor-DSl2FK7a.d.ts → compactor-BUU6Zm_3.d.ts} +1 -1
- package/dist/{config-DXrqb41m.d.ts → config-CKLYPkCi.d.ts} +1 -1
- package/dist/{context-u0bryklF.d.ts → context-IovtuTf8.d.ts} +2 -0
- package/dist/coordination/index.d.ts +11 -11
- package/dist/coordination/index.js +24 -1
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +30 -15
- package/dist/defaults/index.js +321 -2
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-B6Q03pTu.d.ts → events-CNB9PALO.d.ts} +27 -1
- package/dist/execution/index.d.ts +12 -12
- package/dist/extension/index.d.ts +9 -0
- package/dist/extension/index.js +234 -0
- package/dist/extension/index.js.map +1 -0
- package/dist/{plugin-CoYYZKdn.d.ts → index-BDb0cAMP.d.ts} +370 -11
- package/dist/index.d.ts +75 -25
- package/dist/index.js +1864 -1347
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/kernel/index.d.ts +12 -9
- package/dist/kernel/index.js +73 -7
- package/dist/kernel/index.js.map +1 -1
- package/dist/{mcp-servers-BA1Ofmfj.d.ts → mcp-servers-DR35ojJZ.d.ts} +3 -3
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.js +24 -1
- package/dist/models/index.js.map +1 -1
- package/dist/{multi-agent-BDfkxL5C.d.ts → multi-agent-B9a6sflH.d.ts} +2 -2
- package/dist/observability/index.d.ts +2 -2
- package/dist/{path-resolver-Crkt8wTQ.d.ts → path-resolver-Cl_q0u-R.d.ts} +2 -2
- package/dist/provider-runner-BXuADQqQ.d.ts +36 -0
- package/dist/sdd/index.d.ts +3 -3
- package/dist/{secret-scrubber-3TLUkiCV.d.ts → secret-scrubber-CgG2tV2B.d.ts} +1 -1
- package/dist/{secret-scrubber-CwYliRWd.d.ts → secret-scrubber-Cuy5afaQ.d.ts} +1 -1
- package/dist/security/index.d.ts +3 -3
- package/dist/security/index.js +24 -1
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-BRqzvugb.d.ts → selector-wT2fv9Fg.d.ts} +1 -1
- package/dist/{session-reader-C3x96CDR.d.ts → session-reader-CcPi4BQ8.d.ts} +1 -1
- package/dist/{skill-Bx8jxznf.d.ts → skill-C_7znCIC.d.ts} +2 -2
- package/dist/storage/index.d.ts +5 -5
- package/dist/storage/index.js +24 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/{renderer-0A2ZEtca.d.ts → system-prompt-Dk1qm8ey.d.ts} +30 -2
- package/dist/{tool-executor-CYdZdtno.d.ts → tool-executor-DKu4A6nB.d.ts} +5 -5
- package/dist/types/index.d.ts +16 -16
- package/dist/types/index.js +24 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +24 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +5 -1
- package/dist/system-prompt-CG9jU5-5.d.ts +0 -31
package/dist/defaults/index.d.ts
CHANGED
|
@@ -1,34 +1,49 @@
|
|
|
1
1
|
export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-BH6AE0W9.js';
|
|
2
2
|
export { AbandonedSession, AttachmentStoreOptions, ConfigLoaderOptions, ConfigMigration, ConfigMigrationError, ConfigSource, DEFAULT_CONFIG_MIGRATIONS, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultMemoryStore, DefaultSessionStore, DirectorStateCheckpoint, DirectorStateSnapshot, DirectorSubagentState, DirectorTaskState, MemoryStoreOptions, MigrationContext, MigrationResult, PersistedQueueItem, PlanFile, PlanItem, QueueStore, RecoveryLock, RecoveryLockOptions, SessionAnalyzer, SessionStoreOptions, TodosCheckpointFile, addPlanItem, attachPlanCheckpoint, attachTodosCheckpoint, clearPlan, emptyPlan, formatPlan, loadDirectorState, loadPlan, loadTodosCheckpoint, removePlanItem, runConfigMigrations, savePlan, saveTodosCheckpoint, setPlanItemStatus } from '../storage/index.js';
|
|
3
|
-
export { D as DefaultSessionReader } from '../session-reader-
|
|
4
|
-
export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-scrubber-
|
|
3
|
+
export { D as DefaultSessionReader } from '../session-reader-CcPi4BQ8.js';
|
|
4
|
+
export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-scrubber-Cuy5afaQ.js';
|
|
5
5
|
export { AutoApprovePermissionPolicy, DefaultPermissionPolicy, PermissionPolicyOptions } from '../security/index.js';
|
|
6
|
-
export { C as CompactorOptions,
|
|
6
|
+
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-DKu4A6nB.js';
|
|
7
7
|
export { AutoCompactionMiddleware, AutonomousRunner, AutonomousRunnerOptions, DefaultSkillLoader, DoneCheckResult, DoneConditionChecker, IntelligentCompactor, IntelligentCompactorOptions, SelectiveCompactor, SelectiveCompactorOptions, SkillLoaderOptions } from '../execution/index.js';
|
|
8
|
+
import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-BXuADQqQ.js';
|
|
9
|
+
import { j as Response } from '../context-IovtuTf8.js';
|
|
8
10
|
export { ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, AgentFactory, AgentFactoryResult, AgentRunnerOptions, BUG_HUNTER_AGENT, CreateDelegateToolOptions, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultMultiAgentCoordinator, DelegateHost, Director, DirectorBudgetError, DirectorPromptParts, DirectorSessionFactory, DirectorSessionFactoryOptions, FLEET_ROSTER, FleetBus, FleetEvent, FleetHandler, FleetUsage, FleetUsageAggregator, MultiAgentCoordinatorOptions, REFACTOR_PLANNER_AGENT, SECURITY_SCANNER_AGENT, SubagentPromptParts, SubagentUsageSnapshot, composeDirectorPrompt, composeSubagentPrompt, createDelegateTool, makeAgentSubagentRunner, makeDirectorSessionFactory, rosterSummaryFromConfigs } from '../coordination/index.js';
|
|
9
|
-
export {
|
|
10
|
-
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-
|
|
11
|
+
export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, q as BudgetUsage, r as SubagentBudget } from '../multi-agent-B9a6sflH.js';
|
|
12
|
+
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-C3DUGjSb.js';
|
|
11
13
|
export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-DqzwpBQy.js';
|
|
12
14
|
export { DefaultModeStore, LLMSelector, LLMSelectorOptions, ModeLoaderOptions, loadProjectModes, loadUserModes } from '../models/index.js';
|
|
13
15
|
export { DefaultTaskStore, GeneratedTask, SpecDrivenDev, SpecDrivenDevOptions, SpecParser, TaskFlow, TaskFlowEventMap, TaskFlowEventName, TaskFlowExecutionContext, TaskFlowOptions, TaskFlowPhase, TaskGenerator, TaskGeneratorOptions, TaskStore, TaskTracker, TaskTrackerOptions, TaskTransition } from '../sdd/index.js';
|
|
14
16
|
export { DefaultHealthRegistry, InMemoryMetricsSink, MetricsServerHandle, MetricsServerOptions, NoopMetricsSink, NoopTracer, OTelTracer, OtlpMetricsExporterHandle, OtlpMetricsExporterOptions, OtlpTraceExporterHandle, OtlpTraceExporterOptions, PROMETHEUS_CONTENT_TYPE, buildOtlpMetricsRequest, buildOtlpTracesRequest, renderPrometheus, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents } from '../observability/index.js';
|
|
15
|
-
export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, s as sentinelServer, o as slackServer } from '../mcp-servers-
|
|
17
|
+
export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, s as sentinelServer, o as slackServer } from '../mcp-servers-DR35ojJZ.js';
|
|
16
18
|
import '../logger-BMQgxvdy.js';
|
|
17
|
-
import '../events-
|
|
18
|
-
import '../context-u0bryklF.js';
|
|
19
|
+
import '../events-CNB9PALO.js';
|
|
19
20
|
import '../memory-CEXuo7sz.js';
|
|
20
21
|
import '../wstack-paths-BGu2INTm.js';
|
|
21
|
-
import '../config-
|
|
22
|
+
import '../config-CKLYPkCi.js';
|
|
22
23
|
import '../models-registry-Y2xbog0E.js';
|
|
23
24
|
import '../secret-vault-DoISxaKO.js';
|
|
24
|
-
import '../secret-scrubber-
|
|
25
|
+
import '../secret-scrubber-CgG2tV2B.js';
|
|
25
26
|
import '../input-reader-E-ffP2ee.js';
|
|
26
|
-
import '../compactor-
|
|
27
|
-
import '../skill-
|
|
28
|
-
import '../
|
|
27
|
+
import '../compactor-BUU6Zm_3.js';
|
|
28
|
+
import '../skill-C_7znCIC.js';
|
|
29
|
+
import '../index-BDb0cAMP.js';
|
|
30
|
+
import '../system-prompt-Dk1qm8ey.js';
|
|
29
31
|
import '../observability-BhnVLBLS.js';
|
|
30
|
-
import '../
|
|
31
|
-
import '../selector-BRqzvugb.js';
|
|
32
|
+
import '../selector-wT2fv9Fg.js';
|
|
32
33
|
import 'node:events';
|
|
33
34
|
import '../mode-CV077NjV.js';
|
|
34
35
|
import '../task-graph-BITvWt4t.js';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Default ProviderRunner — thin adapter over `runProviderWithRetry`.
|
|
39
|
+
*
|
|
40
|
+
* This is bound to `TOKENS.ProviderRunner` by the CLI at boot.
|
|
41
|
+
* Consumers that want to replace the provider calling layer entirely
|
|
42
|
+
* can bind a different implementation to the same token before
|
|
43
|
+
* `Agent.run()`.
|
|
44
|
+
*/
|
|
45
|
+
declare class DefaultProviderRunner implements ProviderRunner {
|
|
46
|
+
run(opts: RunProviderOptions): Promise<Response>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { DefaultProviderRunner };
|
package/dist/defaults/index.js
CHANGED
|
@@ -156,7 +156,7 @@ async function atomicWrite(targetPath, content, opts = {}) {
|
|
|
156
156
|
if (mode !== void 0) {
|
|
157
157
|
await fsp.chmod(tmp, mode);
|
|
158
158
|
}
|
|
159
|
-
await
|
|
159
|
+
await renameWithRetry(tmp, targetPath);
|
|
160
160
|
} catch (err) {
|
|
161
161
|
try {
|
|
162
162
|
await fsp.unlink(tmp);
|
|
@@ -168,6 +168,29 @@ async function atomicWrite(targetPath, content, opts = {}) {
|
|
|
168
168
|
async function ensureDir(dir) {
|
|
169
169
|
await fsp.mkdir(dir, { recursive: true });
|
|
170
170
|
}
|
|
171
|
+
var TRANSIENT_RENAME_CODES = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES", "ENOTEMPTY"]);
|
|
172
|
+
async function renameWithRetry(from, to) {
|
|
173
|
+
if (process.platform !== "win32") {
|
|
174
|
+
await fsp.rename(from, to);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const delays = [10, 25, 60, 120, 250];
|
|
178
|
+
let lastErr;
|
|
179
|
+
for (let i = 0; i <= delays.length; i++) {
|
|
180
|
+
try {
|
|
181
|
+
await fsp.rename(from, to);
|
|
182
|
+
return;
|
|
183
|
+
} catch (err) {
|
|
184
|
+
lastErr = err;
|
|
185
|
+
const code = err?.code;
|
|
186
|
+
if (!code || !TRANSIENT_RENAME_CODES.has(code) || i === delays.length) {
|
|
187
|
+
throw err;
|
|
188
|
+
}
|
|
189
|
+
await new Promise((resolve2) => setTimeout(resolve2, delays[i]));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
throw lastErr;
|
|
193
|
+
}
|
|
171
194
|
|
|
172
195
|
// src/storage/session-store.ts
|
|
173
196
|
var DefaultSessionStore = class {
|
|
@@ -2718,6 +2741,302 @@ function parseDescription(raw) {
|
|
|
2718
2741
|
return { trigger, scope };
|
|
2719
2742
|
}
|
|
2720
2743
|
|
|
2744
|
+
// src/core/streaming-response-builder.ts
|
|
2745
|
+
function buildResponse(state) {
|
|
2746
|
+
const content = [];
|
|
2747
|
+
for (const b of state.blockOrder) {
|
|
2748
|
+
if (b.kind === "text") {
|
|
2749
|
+
const txt = state.textBuffers[b.idx] ?? "";
|
|
2750
|
+
if (txt) content.push({ type: "text", text: txt });
|
|
2751
|
+
} else if (b.kind === "thinking") {
|
|
2752
|
+
const t = state.thinking[b.idx];
|
|
2753
|
+
if (!t) continue;
|
|
2754
|
+
if (!t.textBuf && !t.signature) continue;
|
|
2755
|
+
const block = { type: "thinking", thinking: t.textBuf };
|
|
2756
|
+
if (t.signature) block.signature = t.signature;
|
|
2757
|
+
if (t.providerMeta && Object.keys(t.providerMeta).length > 0) {
|
|
2758
|
+
block.providerMeta = t.providerMeta;
|
|
2759
|
+
}
|
|
2760
|
+
content.push(block);
|
|
2761
|
+
} else {
|
|
2762
|
+
const tb = state.tools.get(b.id);
|
|
2763
|
+
if (tb) {
|
|
2764
|
+
const block = {
|
|
2765
|
+
type: "tool_use",
|
|
2766
|
+
id: b.id,
|
|
2767
|
+
name: tb.name,
|
|
2768
|
+
input: tb.input ?? {}
|
|
2769
|
+
};
|
|
2770
|
+
if (tb.providerMeta && Object.keys(tb.providerMeta).length > 0) {
|
|
2771
|
+
block.providerMeta = tb.providerMeta;
|
|
2772
|
+
}
|
|
2773
|
+
content.push(block);
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
if (content.length === 0) content.push({ type: "text", text: "" });
|
|
2778
|
+
return { content, stopReason: state.stopReason, usage: state.usage, model: state.model };
|
|
2779
|
+
}
|
|
2780
|
+
function createStreamingState(model) {
|
|
2781
|
+
return {
|
|
2782
|
+
model,
|
|
2783
|
+
stopReason: "end_turn",
|
|
2784
|
+
usage: { input: 0, output: 0 },
|
|
2785
|
+
textBuffers: [],
|
|
2786
|
+
currentTextIndex: -1,
|
|
2787
|
+
tools: /* @__PURE__ */ new Map(),
|
|
2788
|
+
thinking: [],
|
|
2789
|
+
currentThinkingIndex: -1,
|
|
2790
|
+
blockOrder: []
|
|
2791
|
+
};
|
|
2792
|
+
}
|
|
2793
|
+
function handleMessageStart(state, model) {
|
|
2794
|
+
state.model = model;
|
|
2795
|
+
}
|
|
2796
|
+
function handleContentBlockStart(state, ev) {
|
|
2797
|
+
const kind = ev.kind ?? "text";
|
|
2798
|
+
if (kind === "text") {
|
|
2799
|
+
state.currentTextIndex = state.textBuffers.length;
|
|
2800
|
+
state.textBuffers.push("");
|
|
2801
|
+
state.blockOrder.push({ kind: "text", idx: state.currentTextIndex });
|
|
2802
|
+
} else if (kind === "tool_use") {
|
|
2803
|
+
const id = ev.id ?? crypto.randomUUID();
|
|
2804
|
+
state.tools.set(id, { name: ev.name ?? "unknown", partial: "" });
|
|
2805
|
+
state.blockOrder.push({ kind: "tool", id });
|
|
2806
|
+
state.currentTextIndex = -1;
|
|
2807
|
+
} else if (kind === "thinking") {
|
|
2808
|
+
state.currentThinkingIndex = state.thinking.length;
|
|
2809
|
+
state.thinking.push({
|
|
2810
|
+
textBuf: "",
|
|
2811
|
+
...ev.providerMeta ? { providerMeta: ev.providerMeta } : {}
|
|
2812
|
+
});
|
|
2813
|
+
state.blockOrder.push({ kind: "thinking", idx: state.currentThinkingIndex });
|
|
2814
|
+
state.currentTextIndex = -1;
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
function handleContentBlockStop(state, ev) {
|
|
2818
|
+
}
|
|
2819
|
+
function handleTextDelta(state, text) {
|
|
2820
|
+
if (state.currentTextIndex === -1) {
|
|
2821
|
+
state.currentTextIndex = state.textBuffers.length;
|
|
2822
|
+
state.textBuffers.push("");
|
|
2823
|
+
state.blockOrder.push({ kind: "text", idx: state.currentTextIndex });
|
|
2824
|
+
}
|
|
2825
|
+
state.textBuffers[state.currentTextIndex] = (state.textBuffers[state.currentTextIndex] ?? "") + text;
|
|
2826
|
+
}
|
|
2827
|
+
function handleToolUseStart(state, ev) {
|
|
2828
|
+
state.currentTextIndex = -1;
|
|
2829
|
+
state.tools.set(ev.id, { name: ev.name, partial: "" });
|
|
2830
|
+
state.blockOrder.push({ kind: "tool", id: ev.id });
|
|
2831
|
+
}
|
|
2832
|
+
function handleToolUseInputDelta(state, ev) {
|
|
2833
|
+
const t = state.tools.get(ev.id);
|
|
2834
|
+
if (t) t.partial += ev.partial;
|
|
2835
|
+
}
|
|
2836
|
+
function safeJsonOrRaw(s) {
|
|
2837
|
+
if (!s) return {};
|
|
2838
|
+
try {
|
|
2839
|
+
return JSON.parse(s);
|
|
2840
|
+
} catch {
|
|
2841
|
+
return { _raw: s };
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
function handleToolUseStop(state, ev) {
|
|
2845
|
+
const t = state.tools.get(ev.id);
|
|
2846
|
+
if (t) {
|
|
2847
|
+
t.input = ev.input !== void 0 ? ev.input : safeJsonOrRaw(t.partial);
|
|
2848
|
+
if (ev.providerMeta) t.providerMeta = ev.providerMeta;
|
|
2849
|
+
}
|
|
2850
|
+
state.currentTextIndex = -1;
|
|
2851
|
+
}
|
|
2852
|
+
function handleThinkingStart(state, ev) {
|
|
2853
|
+
state.currentThinkingIndex = state.thinking.length;
|
|
2854
|
+
state.thinking.push({
|
|
2855
|
+
textBuf: "",
|
|
2856
|
+
...ev.providerMeta ? { providerMeta: ev.providerMeta } : {}
|
|
2857
|
+
});
|
|
2858
|
+
state.blockOrder.push({ kind: "thinking", idx: state.currentThinkingIndex });
|
|
2859
|
+
state.currentTextIndex = -1;
|
|
2860
|
+
}
|
|
2861
|
+
function handleThinkingDelta(state, text) {
|
|
2862
|
+
if (state.currentThinkingIndex === -1) {
|
|
2863
|
+
handleThinkingStart(state, {});
|
|
2864
|
+
}
|
|
2865
|
+
const t = state.thinking[state.currentThinkingIndex];
|
|
2866
|
+
if (t) t.textBuf += text;
|
|
2867
|
+
}
|
|
2868
|
+
function handleThinkingSignature(state, signature) {
|
|
2869
|
+
if (state.currentThinkingIndex === -1) {
|
|
2870
|
+
handleThinkingStart(state, {});
|
|
2871
|
+
}
|
|
2872
|
+
const t = state.thinking[state.currentThinkingIndex];
|
|
2873
|
+
if (t) t.signature = signature;
|
|
2874
|
+
}
|
|
2875
|
+
function handleThinkingStop(state) {
|
|
2876
|
+
state.currentThinkingIndex = -1;
|
|
2877
|
+
}
|
|
2878
|
+
function handleMessageStop(state, ev) {
|
|
2879
|
+
state.stopReason = ev.stopReason ?? "end_turn";
|
|
2880
|
+
state.usage = ev.usage ?? { input: 0, output: 0 };
|
|
2881
|
+
}
|
|
2882
|
+
async function streamProviderToResponse(provider, req, signal, ctx, events) {
|
|
2883
|
+
const state = createStreamingState(req.model);
|
|
2884
|
+
const iter = provider.stream(req, { signal })[Symbol.asyncIterator]();
|
|
2885
|
+
try {
|
|
2886
|
+
for (; ; ) {
|
|
2887
|
+
const next = await iter.next();
|
|
2888
|
+
if (next.done) break;
|
|
2889
|
+
const ev = next.value;
|
|
2890
|
+
switch (ev.type) {
|
|
2891
|
+
case "message_start":
|
|
2892
|
+
handleMessageStart(state, ev.model);
|
|
2893
|
+
break;
|
|
2894
|
+
case "content_block_start":
|
|
2895
|
+
handleContentBlockStart(state, ev);
|
|
2896
|
+
break;
|
|
2897
|
+
case "content_block_stop":
|
|
2898
|
+
handleContentBlockStop(state, ev);
|
|
2899
|
+
break;
|
|
2900
|
+
case "text_delta":
|
|
2901
|
+
handleTextDelta(state, ev.text);
|
|
2902
|
+
events.emit("provider.text_delta", { ctx, text: ev.text });
|
|
2903
|
+
break;
|
|
2904
|
+
case "tool_use_start":
|
|
2905
|
+
handleToolUseStart(state, ev);
|
|
2906
|
+
events.emit("provider.tool_use_start", { ctx, id: ev.id, name: ev.name });
|
|
2907
|
+
break;
|
|
2908
|
+
case "tool_use_input_delta":
|
|
2909
|
+
handleToolUseInputDelta(state, ev);
|
|
2910
|
+
break;
|
|
2911
|
+
case "tool_use_stop":
|
|
2912
|
+
handleToolUseStop(state, ev);
|
|
2913
|
+
events.emit("provider.tool_use_stop", { ctx, id: ev.id });
|
|
2914
|
+
break;
|
|
2915
|
+
case "thinking_start":
|
|
2916
|
+
handleThinkingStart(state, ev);
|
|
2917
|
+
break;
|
|
2918
|
+
case "thinking_delta":
|
|
2919
|
+
handleThinkingDelta(state, ev.text);
|
|
2920
|
+
events.emit("provider.thinking_delta", { ctx, text: ev.text });
|
|
2921
|
+
break;
|
|
2922
|
+
case "thinking_signature":
|
|
2923
|
+
handleThinkingSignature(state, ev.signature);
|
|
2924
|
+
break;
|
|
2925
|
+
case "thinking_stop":
|
|
2926
|
+
handleThinkingStop(state);
|
|
2927
|
+
break;
|
|
2928
|
+
case "message_stop":
|
|
2929
|
+
handleMessageStop(state, ev);
|
|
2930
|
+
break;
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
} catch (err) {
|
|
2934
|
+
if (signal.aborted) {
|
|
2935
|
+
state.stopReason = "end_turn";
|
|
2936
|
+
return buildResponse(state);
|
|
2937
|
+
}
|
|
2938
|
+
throw err;
|
|
2939
|
+
} finally {
|
|
2940
|
+
try {
|
|
2941
|
+
let drainTimer = null;
|
|
2942
|
+
try {
|
|
2943
|
+
await Promise.race([
|
|
2944
|
+
Promise.resolve(iter.return?.()),
|
|
2945
|
+
new Promise((resolve2) => {
|
|
2946
|
+
drainTimer = setTimeout(resolve2, 500);
|
|
2947
|
+
})
|
|
2948
|
+
]);
|
|
2949
|
+
} finally {
|
|
2950
|
+
if (drainTimer) clearTimeout(drainTimer);
|
|
2951
|
+
}
|
|
2952
|
+
} catch {
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
return buildResponse(state);
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
// src/core/provider-runner.ts
|
|
2959
|
+
async function runProviderWithRetry(opts) {
|
|
2960
|
+
const { provider, request, signal, ctx, events, retry, logger, tracer } = opts;
|
|
2961
|
+
let attempt = 0;
|
|
2962
|
+
for (; ; ) {
|
|
2963
|
+
const span = tracer?.startSpan("provider.complete", {
|
|
2964
|
+
"provider.id": provider.id,
|
|
2965
|
+
"provider.model": request.model,
|
|
2966
|
+
"provider.streaming": provider.capabilities.streaming,
|
|
2967
|
+
"provider.attempt": attempt
|
|
2968
|
+
});
|
|
2969
|
+
try {
|
|
2970
|
+
const res = provider.capabilities.streaming ? await streamProviderToResponse(provider, request, signal, ctx, events) : await provider.complete(request, { signal });
|
|
2971
|
+
span?.setAttribute("provider.stopReason", res.stopReason);
|
|
2972
|
+
span?.setAttribute("provider.usage_in", res.usage.input);
|
|
2973
|
+
span?.setAttribute("provider.usage_out", res.usage.output);
|
|
2974
|
+
span?.end();
|
|
2975
|
+
return res;
|
|
2976
|
+
} catch (err) {
|
|
2977
|
+
if (err instanceof Error) span?.recordError(err);
|
|
2978
|
+
span?.end();
|
|
2979
|
+
if (signal.aborted) throw err;
|
|
2980
|
+
const isProviderErr = err instanceof ProviderError;
|
|
2981
|
+
const errAsErr = err instanceof Error ? err : new Error(String(err));
|
|
2982
|
+
const canRetry = retry.shouldRetry(isProviderErr ? err : errAsErr, attempt);
|
|
2983
|
+
const description = isProviderErr ? err.describe() : errAsErr.message;
|
|
2984
|
+
if (!canRetry) {
|
|
2985
|
+
if (isProviderErr) {
|
|
2986
|
+
events.emit("provider.error", {
|
|
2987
|
+
providerId: err.providerId,
|
|
2988
|
+
status: err.status,
|
|
2989
|
+
description,
|
|
2990
|
+
retryable: false
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
throw err;
|
|
2994
|
+
}
|
|
2995
|
+
const delay = Math.round(retry.delayMs(attempt));
|
|
2996
|
+
const attemptNum = attempt + 1;
|
|
2997
|
+
logger.warn(`Provider retry ${attemptNum} in ${delay}ms \u2014 ${description}`);
|
|
2998
|
+
if (isProviderErr) {
|
|
2999
|
+
events.emit("provider.retry", {
|
|
3000
|
+
providerId: err.providerId,
|
|
3001
|
+
attempt: attemptNum,
|
|
3002
|
+
delayMs: delay,
|
|
3003
|
+
status: err.status,
|
|
3004
|
+
description
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
3007
|
+
await new Promise((resolve2, reject) => {
|
|
3008
|
+
let settled = false;
|
|
3009
|
+
const onAbort = () => {
|
|
3010
|
+
if (settled) return;
|
|
3011
|
+
settled = true;
|
|
3012
|
+
clearTimeout(t);
|
|
3013
|
+
reject(new Error("aborted"));
|
|
3014
|
+
};
|
|
3015
|
+
const t = setTimeout(() => {
|
|
3016
|
+
if (settled) return;
|
|
3017
|
+
settled = true;
|
|
3018
|
+
clearTimeout(t);
|
|
3019
|
+
signal.removeEventListener("abort", onAbort);
|
|
3020
|
+
resolve2();
|
|
3021
|
+
}, delay);
|
|
3022
|
+
if (signal.aborted) {
|
|
3023
|
+
onAbort();
|
|
3024
|
+
return;
|
|
3025
|
+
}
|
|
3026
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
3027
|
+
});
|
|
3028
|
+
attempt++;
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
// src/execution/provider-runner-impl.ts
|
|
3034
|
+
var DefaultProviderRunner = class {
|
|
3035
|
+
async run(opts) {
|
|
3036
|
+
return runProviderWithRetry(opts);
|
|
3037
|
+
}
|
|
3038
|
+
};
|
|
3039
|
+
|
|
2721
3040
|
// src/utils/token-estimate.ts
|
|
2722
3041
|
var RoughTokenEstimate = (text) => Math.max(1, Math.ceil(text.length / 4));
|
|
2723
3042
|
var ESTIMATE_CACHE = /* @__PURE__ */ new Map();
|
|
@@ -8491,6 +8810,6 @@ var allServers = () => ({
|
|
|
8491
8810
|
sentinel: { ...sentinelServer(), enabled: false }
|
|
8492
8811
|
});
|
|
8493
8812
|
|
|
8494
|
-
export { ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPermissionPolicy, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultTaskStore, Director, DirectorBudgetError, DirectorStateCheckpoint, DoneConditionChecker, FLEET_ROSTER, FleetBus, FleetUsageAggregator, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, IntelligentCompactor, LLMSelector, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, SECURITY_SCANNER_AGENT, SelectiveCompactor, SessionAnalyzer, SpecDrivenDev, SpecParser, SubagentBudget, TaskFlow, TaskGenerator, TaskTracker, ToolExecutor, addPlanItem, allServers, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildOtlpMetricsRequest, buildOtlpTracesRequest, classifyFamily, clearPlan, composeDirectorPrompt, composeSubagentPrompt, context7Server, contextManagerTool, createContextManagerTool, createDelegateTool, createMessage, decryptConfigSecrets, emptyPlan, encryptConfigSecrets, everArtServer, filesystemServer, formatPlan, githubServer, googleMapsServer, loadDirectorState, loadPlan, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, migratePlaintextSecrets, removePlanItem, renderPrometheus, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, savePlan, saveTodosCheckpoint, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents };
|
|
8813
|
+
export { ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPermissionPolicy, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultTaskStore, Director, DirectorBudgetError, DirectorStateCheckpoint, DoneConditionChecker, FLEET_ROSTER, FleetBus, FleetUsageAggregator, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, IntelligentCompactor, LLMSelector, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, SECURITY_SCANNER_AGENT, SelectiveCompactor, SessionAnalyzer, SpecDrivenDev, SpecParser, SubagentBudget, TaskFlow, TaskGenerator, TaskTracker, ToolExecutor, addPlanItem, allServers, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildOtlpMetricsRequest, buildOtlpTracesRequest, classifyFamily, clearPlan, composeDirectorPrompt, composeSubagentPrompt, context7Server, contextManagerTool, createContextManagerTool, createDelegateTool, createMessage, decryptConfigSecrets, emptyPlan, encryptConfigSecrets, everArtServer, filesystemServer, formatPlan, githubServer, googleMapsServer, loadDirectorState, loadPlan, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, migratePlaintextSecrets, removePlanItem, renderPrometheus, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, savePlan, saveTodosCheckpoint, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents };
|
|
8495
8814
|
//# sourceMappingURL=index.js.map
|
|
8496
8815
|
//# sourceMappingURL=index.js.map
|