@bluecopa/harness 2.0.1-snapshot.3 → 2.0.1-snapshot.4
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/arc/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AnyTool, T as ToolProvider, a as ToolResult, M as ModelFactory, b as ToolResultArtifact } from '../shared-types-
|
|
2
|
-
export {
|
|
1
|
+
import { A as AnyTool, T as ToolProvider, a as ToolResult, M as ModelFactory, b as ToolResultArtifact, c as ToolProviderCapabilities, B as BashOptions, R as ReadOptions, G as GlobOptions, d as GrepOptions, e as BatchOp, f as BatchResult } from '../shared-types-D89hqST8.js';
|
|
2
|
+
export { g as ActionType, h as TextEditorRequest, i as ThreadStatus, W as WebFetchOptions } from '../shared-types-D89hqST8.js';
|
|
3
3
|
import { HarnessTelemetry } from '../observability/otel.js';
|
|
4
4
|
export { MetricRecord, SpanHandle, SpanRecord } from '../observability/otel.js';
|
|
5
5
|
import 'ai';
|
|
@@ -1006,6 +1006,64 @@ declare const ABSOLUTE_MAX_WORKER_STEPS = 60;
|
|
|
1006
1006
|
/** Recommended extension size when workers need to keep their current context. */
|
|
1007
1007
|
declare const REQUEST_MORE_STEPS_INCREMENT = 15;
|
|
1008
1008
|
|
|
1009
|
+
interface Episode {
|
|
1010
|
+
id: string;
|
|
1011
|
+
taskId: string;
|
|
1012
|
+
sessionId: string;
|
|
1013
|
+
tupleId?: string;
|
|
1014
|
+
summary: string;
|
|
1015
|
+
createdAt: number;
|
|
1016
|
+
completedAt?: number;
|
|
1017
|
+
/** Arbitrary metadata for routing/display */
|
|
1018
|
+
metadata?: Record<string, unknown>;
|
|
1019
|
+
}
|
|
1020
|
+
interface EpisodeTrace {
|
|
1021
|
+
episodeId: string;
|
|
1022
|
+
messages: Array<{
|
|
1023
|
+
role: string;
|
|
1024
|
+
content: string;
|
|
1025
|
+
[key: string]: unknown;
|
|
1026
|
+
}>;
|
|
1027
|
+
createdAt: number;
|
|
1028
|
+
}
|
|
1029
|
+
interface EpisodeStore {
|
|
1030
|
+
addEpisode(episode: Episode): Promise<void>;
|
|
1031
|
+
addTrace(trace: EpisodeTrace): Promise<void>;
|
|
1032
|
+
getEpisode(id: string): Promise<Episode | null>;
|
|
1033
|
+
getTrace(episodeId: string): Promise<EpisodeTrace | null>;
|
|
1034
|
+
getEpisodesByTask(taskId: string): Promise<Episode[]>;
|
|
1035
|
+
getEpisodesBySession(sessionId: string): Promise<Episode[]>;
|
|
1036
|
+
getRecentEpisodes(limit: number): Promise<Episode[]>;
|
|
1037
|
+
evictTraces(olderThan: number): Promise<number>;
|
|
1038
|
+
}
|
|
1039
|
+
interface SessionMemo {
|
|
1040
|
+
id: string;
|
|
1041
|
+
sessionId: string;
|
|
1042
|
+
content: string;
|
|
1043
|
+
sourceEpisodeIds?: string[];
|
|
1044
|
+
createdAt: number;
|
|
1045
|
+
}
|
|
1046
|
+
interface SessionMemoStore {
|
|
1047
|
+
addMemo(memo: SessionMemo): Promise<void>;
|
|
1048
|
+
getMemo(id: string): Promise<SessionMemo | null>;
|
|
1049
|
+
getMemosBySession(sessionId: string): Promise<SessionMemo[]>;
|
|
1050
|
+
getRecentMemos(limit: number): Promise<SessionMemo[]>;
|
|
1051
|
+
}
|
|
1052
|
+
interface LongTermMemory {
|
|
1053
|
+
id: string;
|
|
1054
|
+
content: string;
|
|
1055
|
+
category: string;
|
|
1056
|
+
createdAt: number;
|
|
1057
|
+
updatedAt: number;
|
|
1058
|
+
}
|
|
1059
|
+
interface LongTermStore {
|
|
1060
|
+
addMemory(memory: LongTermMemory): Promise<void>;
|
|
1061
|
+
getMemory(id: string): Promise<LongTermMemory | null>;
|
|
1062
|
+
getAllMemories(): Promise<LongTermMemory[]>;
|
|
1063
|
+
getMemoriesByCategory(category: string): Promise<LongTermMemory[]>;
|
|
1064
|
+
updateMemory(id: string, updates: Partial<Pick<LongTermMemory, 'content' | 'category' | 'updatedAt'>>): Promise<void>;
|
|
1065
|
+
deleteMemory(id: string): Promise<void>;
|
|
1066
|
+
}
|
|
1009
1067
|
/** In-memory transcript store for testing */
|
|
1010
1068
|
declare class MemoryTranscriptStore implements TranscriptStore {
|
|
1011
1069
|
private transcripts;
|
|
@@ -1048,6 +1106,37 @@ declare class MemorySessionStore implements SessionStore {
|
|
|
1048
1106
|
saveMeta(id: string, meta: SessionMeta): Promise<void>;
|
|
1049
1107
|
list(): Promise<SessionMeta[]>;
|
|
1050
1108
|
}
|
|
1109
|
+
/** In-memory episode store */
|
|
1110
|
+
declare class InMemoryEpisodeStore implements EpisodeStore {
|
|
1111
|
+
private episodes;
|
|
1112
|
+
private traces;
|
|
1113
|
+
addEpisode(episode: Episode): Promise<void>;
|
|
1114
|
+
addTrace(trace: EpisodeTrace): Promise<void>;
|
|
1115
|
+
getEpisode(id: string): Promise<Episode | null>;
|
|
1116
|
+
getTrace(episodeId: string): Promise<EpisodeTrace | null>;
|
|
1117
|
+
getEpisodesByTask(taskId: string): Promise<Episode[]>;
|
|
1118
|
+
getEpisodesBySession(sessionId: string): Promise<Episode[]>;
|
|
1119
|
+
getRecentEpisodes(limit: number): Promise<Episode[]>;
|
|
1120
|
+
evictTraces(_olderThan: number): Promise<number>;
|
|
1121
|
+
}
|
|
1122
|
+
/** In-memory session memo store */
|
|
1123
|
+
declare class InMemorySessionMemoStore implements SessionMemoStore {
|
|
1124
|
+
private memos;
|
|
1125
|
+
addMemo(memo: SessionMemo): Promise<void>;
|
|
1126
|
+
getMemo(id: string): Promise<SessionMemo | null>;
|
|
1127
|
+
getMemosBySession(sessionId: string): Promise<SessionMemo[]>;
|
|
1128
|
+
getRecentMemos(limit: number): Promise<SessionMemo[]>;
|
|
1129
|
+
}
|
|
1130
|
+
/** In-memory long-term store */
|
|
1131
|
+
declare class InMemoryLongTermStore implements LongTermStore {
|
|
1132
|
+
private memories;
|
|
1133
|
+
addMemory(memory: LongTermMemory): Promise<void>;
|
|
1134
|
+
getMemory(id: string): Promise<LongTermMemory | null>;
|
|
1135
|
+
getAllMemories(): Promise<LongTermMemory[]>;
|
|
1136
|
+
getMemoriesByCategory(category: string): Promise<LongTermMemory[]>;
|
|
1137
|
+
updateMemory(id: string, updates: Partial<Pick<LongTermMemory, 'content' | 'category' | 'updatedAt'>>): Promise<void>;
|
|
1138
|
+
deleteMemory(id: string): Promise<void>;
|
|
1139
|
+
}
|
|
1051
1140
|
|
|
1052
1141
|
/**
|
|
1053
1142
|
* File-based transcript store.
|
|
@@ -1080,6 +1169,169 @@ declare class FsArtifactStore implements ArtifactStore {
|
|
|
1080
1169
|
private save;
|
|
1081
1170
|
}
|
|
1082
1171
|
|
|
1172
|
+
/**
|
|
1173
|
+
* CompositeToolProvider delegates to the first provider with matching capabilities.
|
|
1174
|
+
*
|
|
1175
|
+
* Useful when multiple tool providers exist (e.g., a sandbox executor + a local
|
|
1176
|
+
* file-system executor) and you want to route tool calls based on capability.
|
|
1177
|
+
*/
|
|
1178
|
+
declare class CompositeToolProvider implements ToolProvider {
|
|
1179
|
+
private providers;
|
|
1180
|
+
constructor(providers: ToolProvider[]);
|
|
1181
|
+
capabilities(): ToolProviderCapabilities;
|
|
1182
|
+
/** Pick the first provider that supports the requested capability. */
|
|
1183
|
+
private pick;
|
|
1184
|
+
bash(command: string, options?: BashOptions): Promise<ToolResult>;
|
|
1185
|
+
readFile(path: string, options?: ReadOptions): Promise<ToolResult>;
|
|
1186
|
+
writeFile(path: string, content: string): Promise<ToolResult>;
|
|
1187
|
+
editFile(path: string, oldText: string, newText: string): Promise<ToolResult>;
|
|
1188
|
+
glob(pattern: string, options?: GlobOptions): Promise<ToolResult>;
|
|
1189
|
+
grep(pattern: string, path?: string, options?: GrepOptions): Promise<ToolResult>;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* Executor interface for sandboxed code execution (e.g., E2B sandbox).
|
|
1194
|
+
*
|
|
1195
|
+
* Implementations wrap sandbox APIs into a uniform shape that
|
|
1196
|
+
* E2BToolProvider can delegate to.
|
|
1197
|
+
*/
|
|
1198
|
+
interface E2BExecutor {
|
|
1199
|
+
bash(command: string, options?: BashOptions): Promise<ToolResult>;
|
|
1200
|
+
readFile(path: string, options?: ReadOptions): Promise<ToolResult>;
|
|
1201
|
+
writeFile(path: string, content: string): Promise<ToolResult>;
|
|
1202
|
+
editFile(path: string, oldText: string, newText: string): Promise<ToolResult>;
|
|
1203
|
+
glob(pattern: string, options?: GlobOptions): Promise<ToolResult>;
|
|
1204
|
+
grep(pattern: string, path?: string, options?: GrepOptions): Promise<ToolResult>;
|
|
1205
|
+
batch?(ops: BatchOp[]): Promise<BatchResult[]>;
|
|
1206
|
+
destroy(): Promise<void>;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* E2BToolProvider wraps an E2BExecutor into a ToolProvider interface
|
|
1210
|
+
* suitable for use with the harness agent loop.
|
|
1211
|
+
*/
|
|
1212
|
+
declare class E2BToolProvider {
|
|
1213
|
+
private executor;
|
|
1214
|
+
constructor(executor: E2BExecutor);
|
|
1215
|
+
capabilities(): ToolProviderCapabilities;
|
|
1216
|
+
bash(command: string, options?: BashOptions): Promise<ToolResult>;
|
|
1217
|
+
readFile(path: string, options?: ReadOptions): Promise<ToolResult>;
|
|
1218
|
+
writeFile(path: string, content: string): Promise<ToolResult>;
|
|
1219
|
+
editFile(path: string, oldText: string, newText: string): Promise<ToolResult>;
|
|
1220
|
+
glob(pattern: string, options?: GlobOptions): Promise<ToolResult>;
|
|
1221
|
+
grep(pattern: string, path?: string, options?: GrepOptions): Promise<ToolResult>;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
/** Options for constructing a ControlPlaneE2BExecutor. */
|
|
1225
|
+
interface ControlPlaneE2BExecutorOptions {
|
|
1226
|
+
baseUrl: string;
|
|
1227
|
+
apiKey: string;
|
|
1228
|
+
templateId?: string;
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Base class for control-plane E2B sandbox executors.
|
|
1232
|
+
*
|
|
1233
|
+
* Provides the configuration surface and stubs that concrete implementations
|
|
1234
|
+
* (e.g., Samyx control-plane API) extend. Subclasses must override the
|
|
1235
|
+
* tool-execution methods with actual sandbox API calls.
|
|
1236
|
+
*/
|
|
1237
|
+
declare class ControlPlaneE2BExecutor implements E2BExecutor {
|
|
1238
|
+
protected baseUrl: string;
|
|
1239
|
+
protected apiKey: string;
|
|
1240
|
+
protected templateId: string;
|
|
1241
|
+
constructor(options: ControlPlaneE2BExecutorOptions);
|
|
1242
|
+
bash(_command: string, _options?: BashOptions): Promise<ToolResult>;
|
|
1243
|
+
readFile(_path: string, _options?: ReadOptions): Promise<ToolResult>;
|
|
1244
|
+
writeFile(_path: string, _content: string): Promise<ToolResult>;
|
|
1245
|
+
editFile(_path: string, _oldText: string, _newText: string): Promise<ToolResult>;
|
|
1246
|
+
glob(_pattern: string, _options?: GlobOptions): Promise<ToolResult>;
|
|
1247
|
+
grep(_pattern: string, _path?: string, _options?: GrepOptions): Promise<ToolResult>;
|
|
1248
|
+
writeFileBytes(_path: string, _data: Uint8Array): Promise<void>;
|
|
1249
|
+
readFileBytes(_path: string): Promise<Uint8Array>;
|
|
1250
|
+
get activeSandboxId(): string | undefined;
|
|
1251
|
+
destroy(): Promise<void>;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* Permission request sent to the resolver for each tool call.
|
|
1256
|
+
*
|
|
1257
|
+
* The `toolName` key is always present. Additional tool arguments
|
|
1258
|
+
* are forwarded as-is for context-sensitive permission decisions.
|
|
1259
|
+
*/
|
|
1260
|
+
interface PermissionRequest {
|
|
1261
|
+
toolName: string;
|
|
1262
|
+
[toolArg: string]: unknown;
|
|
1263
|
+
}
|
|
1264
|
+
/** Resolver function that decides whether a tool call is permitted. */
|
|
1265
|
+
type PermissionResolver = (request: PermissionRequest) => Promise<boolean>;
|
|
1266
|
+
/** Permission mode for the manager. */
|
|
1267
|
+
type PermissionMode = "deny_all" | "allow_all" | "ask";
|
|
1268
|
+
/**
|
|
1269
|
+
* PermissionManager controls whether tool calls are allowed.
|
|
1270
|
+
*
|
|
1271
|
+
* Three modes:
|
|
1272
|
+
* - `deny_all`: reject everything
|
|
1273
|
+
* - `allow_all`: accept everything
|
|
1274
|
+
* - `ask`: delegate to a resolver function
|
|
1275
|
+
*/
|
|
1276
|
+
declare class PermissionManager {
|
|
1277
|
+
private mode;
|
|
1278
|
+
private resolver;
|
|
1279
|
+
constructor(mode: PermissionMode, resolver?: PermissionResolver);
|
|
1280
|
+
/** Check whether a tool call is permitted. */
|
|
1281
|
+
canExecute(request: PermissionRequest): Promise<boolean>;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
interface ExecutionContext {
|
|
1285
|
+
attempt: number;
|
|
1286
|
+
totalAttempts: number;
|
|
1287
|
+
startTime: number;
|
|
1288
|
+
signal: AbortSignal;
|
|
1289
|
+
}
|
|
1290
|
+
interface PipelineOptions {
|
|
1291
|
+
timeout?: number;
|
|
1292
|
+
retryCount?: number;
|
|
1293
|
+
}
|
|
1294
|
+
declare class ResiliencePipeline {
|
|
1295
|
+
private options;
|
|
1296
|
+
constructor(options?: PipelineOptions);
|
|
1297
|
+
/** Set a timeout in milliseconds for execution. */
|
|
1298
|
+
timeout(ms: number): ResiliencePipeline;
|
|
1299
|
+
/** Set retry count. */
|
|
1300
|
+
retries(count: number): ResiliencePipeline;
|
|
1301
|
+
/** Build the executable pipeline. */
|
|
1302
|
+
build(): {
|
|
1303
|
+
execute: <T>(fn: () => Promise<T>, ctx: ExecutionContext) => Promise<T>;
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
/** Create a new resilience pipeline builder. */
|
|
1307
|
+
declare function resilience(): ResiliencePipeline;
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* Profile types for ArcLoop thread configuration.
|
|
1311
|
+
*
|
|
1312
|
+
* Profiles control which tools a worker thread can use and which
|
|
1313
|
+
* model tier it runs at.
|
|
1314
|
+
*/
|
|
1315
|
+
/** Declaration of a worker profile — matched by name in process context. */
|
|
1316
|
+
interface ProfileDeclaration {
|
|
1317
|
+
name: string;
|
|
1318
|
+
/** Descriptive signature for the orchestrator (e.g., "question:string -> evidence:string[]") */
|
|
1319
|
+
signature: string;
|
|
1320
|
+
/** Tool names available to workers with this profile */
|
|
1321
|
+
tools: string[];
|
|
1322
|
+
/** Worker model tier */
|
|
1323
|
+
model: "fast" | "medium" | "strong";
|
|
1324
|
+
/** Worker step budget */
|
|
1325
|
+
maxSteps: number;
|
|
1326
|
+
/** Background/injection context for the worker system prompt */
|
|
1327
|
+
background: string;
|
|
1328
|
+
}
|
|
1329
|
+
/** A profile bound to a process, with its declaration. */
|
|
1330
|
+
interface ProcessProfile {
|
|
1331
|
+
name: string;
|
|
1332
|
+
declaration: ProfileDeclaration;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1083
1335
|
/**
|
|
1084
1336
|
* In-memory reference implementation of JobRegistry.
|
|
1085
1337
|
*
|
|
@@ -1105,4 +1357,4 @@ declare class MemoryJobRegistry implements JobRegistry {
|
|
|
1105
1357
|
private emit;
|
|
1106
1358
|
}
|
|
1107
1359
|
|
|
1108
|
-
export { ABSOLUTE_MAX_WORKER_STEPS, AnyTool, type ArcConfig, type ArcEvent, ArcLoop, type ArcRunResult, type ArcTraceEvent, type Artifact, type ArtifactStore, DEFAULT_MAX_STEPS_PER_WORKER, DEFAULT_WORKER_STEP_BUDGETS, type DispatchRecord, type DispatchTier, type ExpectedArtifact, type ExpectedOutputContract, FsArtifactStore, FsTranscriptStore, HarnessTelemetry, type HookCallback, type HookContext, type HookDecision, type HookEventName, HookRunner, type JobEvent, type JobKind, type JobRegistry, type JobSpec, type JobStartOptions, type JobState, type JobStatus, type JobTransport, MemoryArtifactStore, MemoryJobRegistry, MemoryMessageStore, MemoryScratchPad, MemorySessionStore, MemorySummaryDAG, MemoryTranscriptStore, MemoryVectorIndex, type MessageStore, ModelFactory, type OodaSnapshot, type OrchestratorContext, type PushResult, REQUEST_MORE_STEPS_INCREMENT, type ReadEpisodeArgs, type ReadEpisodeDetail, type RunWorkerConfig, type ScratchPad, type SessionMeta, type SessionSnapshot, type SessionStore, type StoredAttachment, type StoredMessage, type SummaryDAG, type SummaryNode, type Tool, type ToolExecutionMode, ToolProvider, ToolResult, ToolResultArtifact, type TraceToolCall, type Transcript, type TranscriptStore, type Tuple, type VectorIndex, type WorkerProgressEvent, type WorkerResult, cloneForTrace, formatDispatchForPrompt };
|
|
1360
|
+
export { ABSOLUTE_MAX_WORKER_STEPS, AnyTool, type ArcConfig, type ArcEvent, ArcLoop, type ArcRunResult, type ArcTraceEvent, type Artifact, type ArtifactStore, BashOptions, BatchOp, BatchResult, CompositeToolProvider, ControlPlaneE2BExecutor, type ControlPlaneE2BExecutorOptions, DEFAULT_MAX_STEPS_PER_WORKER, DEFAULT_WORKER_STEP_BUDGETS, type DispatchRecord, type DispatchTier, type E2BExecutor, E2BToolProvider, type Episode, type EpisodeStore, type EpisodeTrace, type ExecutionContext, type ExpectedArtifact, type ExpectedOutputContract, FsArtifactStore, FsTranscriptStore, GlobOptions, GrepOptions, HarnessTelemetry, type HookCallback, type HookContext, type HookDecision, type HookEventName, HookRunner, InMemoryEpisodeStore, InMemoryLongTermStore, InMemorySessionMemoStore, type JobEvent, type JobKind, type JobRegistry, type JobSpec, type JobStartOptions, type JobState, type JobStatus, type JobTransport, type LongTermMemory, type LongTermStore, MemoryArtifactStore, MemoryJobRegistry, MemoryMessageStore, MemoryScratchPad, MemorySessionStore, MemorySummaryDAG, MemoryTranscriptStore, MemoryVectorIndex, type MessageStore, ModelFactory, type OodaSnapshot, type OrchestratorContext, PermissionManager, type PermissionMode, type PermissionRequest, type PermissionResolver, type ProcessProfile, type ProfileDeclaration, type PushResult, REQUEST_MORE_STEPS_INCREMENT, type ReadEpisodeArgs, type ReadEpisodeDetail, ReadOptions, type RunWorkerConfig, type ScratchPad, type SessionMemo, type SessionMemoStore, type SessionMeta, type SessionSnapshot, type SessionStore, type StoredAttachment, type StoredMessage, type SummaryDAG, type SummaryNode, type Tool, type ToolExecutionMode, ToolProvider, ToolProviderCapabilities, ToolResult, ToolResultArtifact, type TraceToolCall, type Transcript, type TranscriptStore, type Tuple, type VectorIndex, type WorkerProgressEvent, type WorkerResult, cloneForTrace, formatDispatchForPrompt, resilience };
|
package/dist/arc/index.js
CHANGED
|
@@ -2141,6 +2141,73 @@ var MemorySessionStore = class {
|
|
|
2141
2141
|
return [...this.metas.values()].sort((a, b) => b.lastActiveAt - a.lastActiveAt);
|
|
2142
2142
|
}
|
|
2143
2143
|
};
|
|
2144
|
+
var InMemoryEpisodeStore = class {
|
|
2145
|
+
episodes = /* @__PURE__ */ new Map();
|
|
2146
|
+
traces = /* @__PURE__ */ new Map();
|
|
2147
|
+
async addEpisode(episode) {
|
|
2148
|
+
this.episodes.set(episode.id, episode);
|
|
2149
|
+
}
|
|
2150
|
+
async addTrace(trace) {
|
|
2151
|
+
this.traces.set(trace.episodeId, trace);
|
|
2152
|
+
}
|
|
2153
|
+
async getEpisode(id) {
|
|
2154
|
+
return this.episodes.get(id) ?? null;
|
|
2155
|
+
}
|
|
2156
|
+
async getTrace(episodeId) {
|
|
2157
|
+
return this.traces.get(episodeId) ?? null;
|
|
2158
|
+
}
|
|
2159
|
+
async getEpisodesByTask(taskId) {
|
|
2160
|
+
return [...this.episodes.values()].filter((e) => e.taskId === taskId);
|
|
2161
|
+
}
|
|
2162
|
+
async getEpisodesBySession(sessionId) {
|
|
2163
|
+
return [...this.episodes.values()].filter((e) => e.sessionId === sessionId);
|
|
2164
|
+
}
|
|
2165
|
+
async getRecentEpisodes(limit) {
|
|
2166
|
+
return [...this.episodes.values()].sort((a, b) => b.createdAt - a.createdAt).slice(0, limit);
|
|
2167
|
+
}
|
|
2168
|
+
async evictTraces(_olderThan) {
|
|
2169
|
+
return 0;
|
|
2170
|
+
}
|
|
2171
|
+
};
|
|
2172
|
+
var InMemorySessionMemoStore = class {
|
|
2173
|
+
memos = /* @__PURE__ */ new Map();
|
|
2174
|
+
async addMemo(memo) {
|
|
2175
|
+
this.memos.set(memo.id, memo);
|
|
2176
|
+
}
|
|
2177
|
+
async getMemo(id) {
|
|
2178
|
+
return this.memos.get(id) ?? null;
|
|
2179
|
+
}
|
|
2180
|
+
async getMemosBySession(sessionId) {
|
|
2181
|
+
return [...this.memos.values()].filter((m) => m.sessionId === sessionId);
|
|
2182
|
+
}
|
|
2183
|
+
async getRecentMemos(limit) {
|
|
2184
|
+
return [...this.memos.values()].sort((a, b) => b.createdAt - a.createdAt).slice(0, limit);
|
|
2185
|
+
}
|
|
2186
|
+
};
|
|
2187
|
+
var InMemoryLongTermStore = class {
|
|
2188
|
+
memories = /* @__PURE__ */ new Map();
|
|
2189
|
+
async addMemory(memory) {
|
|
2190
|
+
this.memories.set(memory.id, memory);
|
|
2191
|
+
}
|
|
2192
|
+
async getMemory(id) {
|
|
2193
|
+
return this.memories.get(id) ?? null;
|
|
2194
|
+
}
|
|
2195
|
+
async getAllMemories() {
|
|
2196
|
+
return [...this.memories.values()];
|
|
2197
|
+
}
|
|
2198
|
+
async getMemoriesByCategory(category) {
|
|
2199
|
+
return [...this.memories.values()].filter((m) => m.category === category);
|
|
2200
|
+
}
|
|
2201
|
+
async updateMemory(id, updates) {
|
|
2202
|
+
const existing = this.memories.get(id);
|
|
2203
|
+
if (existing) {
|
|
2204
|
+
this.memories.set(id, { ...existing, ...updates });
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
async deleteMemory(id) {
|
|
2208
|
+
this.memories.delete(id);
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2144
2211
|
|
|
2145
2212
|
// src/arc/jobs/memory-job-registry.js
|
|
2146
2213
|
var MemoryJobRegistry = class {
|
|
@@ -5067,6 +5134,259 @@ var FsArtifactStore = class {
|
|
|
5067
5134
|
}
|
|
5068
5135
|
};
|
|
5069
5136
|
|
|
5070
|
-
|
|
5137
|
+
// src/arc/composite-tool-provider.ts
|
|
5138
|
+
var CompositeToolProvider = class {
|
|
5139
|
+
providers;
|
|
5140
|
+
constructor(providers) {
|
|
5141
|
+
this.providers = providers;
|
|
5142
|
+
}
|
|
5143
|
+
capabilities() {
|
|
5144
|
+
return this.providers.reduce(
|
|
5145
|
+
(acc, p) => {
|
|
5146
|
+
const c = p.capabilities();
|
|
5147
|
+
return {
|
|
5148
|
+
bash: acc.bash || c.bash,
|
|
5149
|
+
fileSystem: acc.fileSystem || c.fileSystem,
|
|
5150
|
+
webFetch: acc.webFetch || c.webFetch,
|
|
5151
|
+
webSearch: acc.webSearch || c.webSearch,
|
|
5152
|
+
codeExecution: acc.codeExecution || c.codeExecution,
|
|
5153
|
+
sandboxed: acc.sandboxed || c.sandboxed
|
|
5154
|
+
};
|
|
5155
|
+
},
|
|
5156
|
+
{
|
|
5157
|
+
bash: false,
|
|
5158
|
+
fileSystem: false,
|
|
5159
|
+
webFetch: false,
|
|
5160
|
+
webSearch: false,
|
|
5161
|
+
codeExecution: false,
|
|
5162
|
+
sandboxed: false
|
|
5163
|
+
}
|
|
5164
|
+
);
|
|
5165
|
+
}
|
|
5166
|
+
/** Pick the first provider that supports the requested capability. */
|
|
5167
|
+
pick(capability) {
|
|
5168
|
+
const provider = this.providers.find((p) => p.capabilities()[capability]);
|
|
5169
|
+
if (!provider) {
|
|
5170
|
+
throw new Error(`No provider supports capability: ${capability}`);
|
|
5171
|
+
}
|
|
5172
|
+
return provider;
|
|
5173
|
+
}
|
|
5174
|
+
async bash(command, options) {
|
|
5175
|
+
return this.pick("bash").bash(command, options);
|
|
5176
|
+
}
|
|
5177
|
+
async readFile(path2, options) {
|
|
5178
|
+
return this.pick("fileSystem").readFile(path2, options);
|
|
5179
|
+
}
|
|
5180
|
+
async writeFile(path2, content) {
|
|
5181
|
+
return this.pick("fileSystem").writeFile(path2, content);
|
|
5182
|
+
}
|
|
5183
|
+
async editFile(path2, oldText, newText) {
|
|
5184
|
+
return this.pick("fileSystem").editFile(path2, oldText, newText);
|
|
5185
|
+
}
|
|
5186
|
+
async glob(pattern, options) {
|
|
5187
|
+
return this.pick("fileSystem").glob(pattern, options);
|
|
5188
|
+
}
|
|
5189
|
+
async grep(pattern, path2, options) {
|
|
5190
|
+
return this.pick("fileSystem").grep(pattern, path2, options);
|
|
5191
|
+
}
|
|
5192
|
+
};
|
|
5193
|
+
|
|
5194
|
+
// src/arc/e2b-tool-provider.ts
|
|
5195
|
+
var E2BToolProvider = class {
|
|
5196
|
+
constructor(executor) {
|
|
5197
|
+
this.executor = executor;
|
|
5198
|
+
}
|
|
5199
|
+
capabilities() {
|
|
5200
|
+
return {
|
|
5201
|
+
bash: true,
|
|
5202
|
+
fileSystem: true,
|
|
5203
|
+
webFetch: false,
|
|
5204
|
+
webSearch: false,
|
|
5205
|
+
codeExecution: true,
|
|
5206
|
+
sandboxed: true
|
|
5207
|
+
};
|
|
5208
|
+
}
|
|
5209
|
+
async bash(command, options) {
|
|
5210
|
+
return this.executor.bash(command, options);
|
|
5211
|
+
}
|
|
5212
|
+
async readFile(path2, options) {
|
|
5213
|
+
return this.executor.readFile(path2, options);
|
|
5214
|
+
}
|
|
5215
|
+
async writeFile(path2, content) {
|
|
5216
|
+
return this.executor.writeFile(path2, content);
|
|
5217
|
+
}
|
|
5218
|
+
async editFile(path2, oldText, newText) {
|
|
5219
|
+
return this.executor.editFile(path2, oldText, newText);
|
|
5220
|
+
}
|
|
5221
|
+
async glob(pattern, options) {
|
|
5222
|
+
return this.executor.glob(pattern, options);
|
|
5223
|
+
}
|
|
5224
|
+
async grep(pattern, path2, options) {
|
|
5225
|
+
return this.executor.grep(pattern, path2, options);
|
|
5226
|
+
}
|
|
5227
|
+
};
|
|
5228
|
+
|
|
5229
|
+
// src/arc/control-plane-e2b-executor.ts
|
|
5230
|
+
var ControlPlaneE2BExecutor = class {
|
|
5231
|
+
baseUrl;
|
|
5232
|
+
apiKey;
|
|
5233
|
+
templateId;
|
|
5234
|
+
constructor(options) {
|
|
5235
|
+
this.baseUrl = options.baseUrl;
|
|
5236
|
+
this.apiKey = options.apiKey;
|
|
5237
|
+
this.templateId = options.templateId ?? "polyglot-v1";
|
|
5238
|
+
}
|
|
5239
|
+
async bash(_command, _options) {
|
|
5240
|
+
throw new Error(
|
|
5241
|
+
"ControlPlaneE2BExecutor.bash() not implemented \u2014 use a concrete subclass"
|
|
5242
|
+
);
|
|
5243
|
+
}
|
|
5244
|
+
async readFile(_path, _options) {
|
|
5245
|
+
throw new Error("ControlPlaneE2BExecutor.readFile() not implemented");
|
|
5246
|
+
}
|
|
5247
|
+
async writeFile(_path, _content) {
|
|
5248
|
+
throw new Error("ControlPlaneE2BExecutor.writeFile() not implemented");
|
|
5249
|
+
}
|
|
5250
|
+
async editFile(_path, _oldText, _newText) {
|
|
5251
|
+
throw new Error("ControlPlaneE2BExecutor.editFile() not implemented");
|
|
5252
|
+
}
|
|
5253
|
+
async glob(_pattern, _options) {
|
|
5254
|
+
throw new Error("ControlPlaneE2BExecutor.glob() not implemented");
|
|
5255
|
+
}
|
|
5256
|
+
async grep(_pattern, _path, _options) {
|
|
5257
|
+
throw new Error("ControlPlaneE2BExecutor.grep() not implemented");
|
|
5258
|
+
}
|
|
5259
|
+
async writeFileBytes(_path, _data) {
|
|
5260
|
+
throw new Error("ControlPlaneE2BExecutor.writeFileBytes() not implemented");
|
|
5261
|
+
}
|
|
5262
|
+
async readFileBytes(_path) {
|
|
5263
|
+
throw new Error("ControlPlaneE2BExecutor.readFileBytes() not implemented");
|
|
5264
|
+
}
|
|
5265
|
+
get activeSandboxId() {
|
|
5266
|
+
return void 0;
|
|
5267
|
+
}
|
|
5268
|
+
async destroy() {
|
|
5269
|
+
}
|
|
5270
|
+
};
|
|
5271
|
+
|
|
5272
|
+
// src/arc/permission-manager.ts
|
|
5273
|
+
var PermissionManager = class {
|
|
5274
|
+
mode;
|
|
5275
|
+
resolver;
|
|
5276
|
+
constructor(mode, resolver) {
|
|
5277
|
+
this.mode = mode;
|
|
5278
|
+
this.resolver = resolver;
|
|
5279
|
+
}
|
|
5280
|
+
/** Check whether a tool call is permitted. */
|
|
5281
|
+
async canExecute(request) {
|
|
5282
|
+
switch (this.mode) {
|
|
5283
|
+
case "deny_all":
|
|
5284
|
+
return false;
|
|
5285
|
+
case "allow_all":
|
|
5286
|
+
return true;
|
|
5287
|
+
case "ask":
|
|
5288
|
+
if (this.resolver) {
|
|
5289
|
+
return this.resolver(request);
|
|
5290
|
+
}
|
|
5291
|
+
return false;
|
|
5292
|
+
default:
|
|
5293
|
+
return false;
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
};
|
|
5297
|
+
|
|
5298
|
+
// src/arc/resilience.ts
|
|
5299
|
+
var ResiliencePipeline = class {
|
|
5300
|
+
options;
|
|
5301
|
+
constructor(options = {}) {
|
|
5302
|
+
this.options = options;
|
|
5303
|
+
}
|
|
5304
|
+
/** Set a timeout in milliseconds for execution. */
|
|
5305
|
+
timeout(ms) {
|
|
5306
|
+
this.options.timeout = ms;
|
|
5307
|
+
return this;
|
|
5308
|
+
}
|
|
5309
|
+
/** Set retry count. */
|
|
5310
|
+
retries(count) {
|
|
5311
|
+
this.options.retryCount = count;
|
|
5312
|
+
return this;
|
|
5313
|
+
}
|
|
5314
|
+
/** Build the executable pipeline. */
|
|
5315
|
+
build() {
|
|
5316
|
+
const { timeout: timeoutMs, retryCount = 0 } = this.options;
|
|
5317
|
+
return {
|
|
5318
|
+
execute: async (fn, ctx) => {
|
|
5319
|
+
let lastError;
|
|
5320
|
+
for (let attempt = 0; attempt <= retryCount; attempt++) {
|
|
5321
|
+
if (ctx.signal.aborted) {
|
|
5322
|
+
throw ctx.signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
5323
|
+
}
|
|
5324
|
+
try {
|
|
5325
|
+
if (timeoutMs) {
|
|
5326
|
+
const result = await raceWithTimeout(
|
|
5327
|
+
fn(),
|
|
5328
|
+
timeoutMs,
|
|
5329
|
+
ctx.signal
|
|
5330
|
+
);
|
|
5331
|
+
return result;
|
|
5332
|
+
}
|
|
5333
|
+
return await fn();
|
|
5334
|
+
} catch (err2) {
|
|
5335
|
+
lastError = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
5336
|
+
if (attempt === retryCount) {
|
|
5337
|
+
throw lastError;
|
|
5338
|
+
}
|
|
5339
|
+
const delay = Math.min(4e3, 500 * Math.pow(2, attempt));
|
|
5340
|
+
await sleep2(delay, ctx.signal);
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
throw lastError ?? new Error("Pipeline failed");
|
|
5344
|
+
}
|
|
5345
|
+
};
|
|
5346
|
+
}
|
|
5347
|
+
};
|
|
5348
|
+
function resilience() {
|
|
5349
|
+
return new ResiliencePipeline();
|
|
5350
|
+
}
|
|
5351
|
+
async function raceWithTimeout(promise, timeoutMs, signal) {
|
|
5352
|
+
return Promise.race([
|
|
5353
|
+
promise,
|
|
5354
|
+
new Promise((_, reject) => {
|
|
5355
|
+
const timer = setTimeout(() => {
|
|
5356
|
+
reject(new Error(`Timeout after ${timeoutMs}ms`));
|
|
5357
|
+
}, timeoutMs);
|
|
5358
|
+
const onAbort = () => {
|
|
5359
|
+
clearTimeout(timer);
|
|
5360
|
+
reject(
|
|
5361
|
+
signal.reason ?? new DOMException("Aborted", "AbortError")
|
|
5362
|
+
);
|
|
5363
|
+
};
|
|
5364
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
5365
|
+
})
|
|
5366
|
+
]);
|
|
5367
|
+
}
|
|
5368
|
+
function sleep2(ms, signal) {
|
|
5369
|
+
return new Promise((resolve, reject) => {
|
|
5370
|
+
if (signal.aborted) {
|
|
5371
|
+
reject(
|
|
5372
|
+
signal.reason ?? new DOMException("Aborted", "AbortError")
|
|
5373
|
+
);
|
|
5374
|
+
return;
|
|
5375
|
+
}
|
|
5376
|
+
const timer = setTimeout(() => {
|
|
5377
|
+
signal.removeEventListener("abort", onAbort);
|
|
5378
|
+
resolve();
|
|
5379
|
+
}, ms);
|
|
5380
|
+
function onAbort() {
|
|
5381
|
+
clearTimeout(timer);
|
|
5382
|
+
reject(
|
|
5383
|
+
signal.reason ?? new DOMException("Aborted", "AbortError")
|
|
5384
|
+
);
|
|
5385
|
+
}
|
|
5386
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
5387
|
+
});
|
|
5388
|
+
}
|
|
5389
|
+
|
|
5390
|
+
export { ABSOLUTE_MAX_WORKER_STEPS, ArcLoop, CompositeToolProvider, ControlPlaneE2BExecutor, DEFAULT_MAX_STEPS_PER_WORKER, DEFAULT_WORKER_STEP_BUDGETS, E2BToolProvider, FsArtifactStore, FsTranscriptStore, HarnessTelemetry, HookRunner, InMemoryEpisodeStore, InMemoryLongTermStore, InMemorySessionMemoStore, MemoryArtifactStore, MemoryJobRegistry, MemoryMessageStore, MemoryScratchPad, MemorySessionStore, MemorySummaryDAG, MemoryTranscriptStore, MemoryVectorIndex, PermissionManager, REQUEST_MORE_STEPS_INCREMENT, cloneForTrace, formatDispatchForPrompt, resilience };
|
|
5071
5391
|
//# sourceMappingURL=index.js.map
|
|
5072
5392
|
//# sourceMappingURL=index.js.map
|