@assemblyline-agents/runtime 3.2.0 → 4.0.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/README.md +6 -0
- package/dist/background-subagents.d.ts.map +1 -1
- package/dist/background-subagents.js +8 -3
- package/dist/background-subagents.js.map +1 -1
- package/dist/harness-loop.d.ts +5 -5
- package/dist/harness-loop.d.ts.map +1 -1
- package/dist/harness-loop.js +14 -5
- package/dist/harness-loop.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -9
- package/dist/index.js.map +1 -1
- package/dist/model-credential-stores.d.ts +20 -0
- package/dist/model-credential-stores.d.ts.map +1 -0
- package/dist/model-credential-stores.js +142 -0
- package/dist/model-credential-stores.js.map +1 -0
- package/dist/public-api.d.ts +3 -1
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +1 -0
- package/dist/public-api.js.map +1 -1
- package/dist/run-recovery.js.map +1 -1
- package/dist/runtime-types.d.ts +11 -3
- package/dist/runtime-types.d.ts.map +1 -1
- package/dist/sandbox-authored-tool-child.d.ts +7 -0
- package/dist/sandbox-authored-tool-child.d.ts.map +1 -0
- package/dist/sandbox-authored-tool-child.js +217 -0
- package/dist/sandbox-authored-tool-child.js.map +1 -0
- package/dist/sandbox-authored-tool-executor.d.ts +23 -0
- package/dist/sandbox-authored-tool-executor.d.ts.map +1 -0
- package/dist/sandbox-authored-tool-executor.js +290 -0
- package/dist/sandbox-authored-tool-executor.js.map +1 -0
- package/dist/sandbox-tool-bridge.d.ts +19 -0
- package/dist/sandbox-tool-bridge.d.ts.map +1 -0
- package/dist/sandbox-tool-bridge.js +227 -0
- package/dist/sandbox-tool-bridge.js.map +1 -0
- package/dist/source-loader.d.ts +10 -0
- package/dist/source-loader.d.ts.map +1 -1
- package/dist/source-loader.js +64 -3
- package/dist/source-loader.js.map +1 -1
- package/dist/state.d.ts +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/subagent-execution.d.ts +9 -0
- package/dist/subagent-execution.d.ts.map +1 -1
- package/dist/subagent-execution.js +86 -1
- package/dist/subagent-execution.js.map +1 -1
- package/dist/tool-apis.d.ts +1 -1
- package/dist/tool-apis.d.ts.map +1 -1
- package/dist/tool-apis.js +10 -4
- package/dist/tool-apis.js.map +1 -1
- package/dist/tool-execution.d.ts +12 -3
- package/dist/tool-execution.d.ts.map +1 -1
- package/dist/tool-execution.js +52 -12
- package/dist/tool-execution.js.map +1 -1
- package/dist/usage-accounting.js +0 -2
- package/dist/usage-accounting.js.map +1 -1
- package/dist/usage-reconciliation.js +1 -1
- package/dist/usage-reconciliation.js.map +1 -1
- package/package.json +3 -3
- package/dist/model-harnesses.d.ts +0 -4
- package/dist/model-harnesses.d.ts.map +0 -1
- package/dist/model-harnesses.js +0 -6
- package/dist/model-harnesses.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { builtInToolDefinition } from "./builtin-tools.js";
|
|
4
|
+
import { InMemoryModelCredentialStore } from "./model-credential-stores.js";
|
|
4
5
|
export * from "./public-api.js";
|
|
5
6
|
export { builtInToolDefaults, FILES_MOUNT_TOOL_NAME, FILES_SEARCH_TOOL_NAME, HISTORY_SEARCH_TOOL_NAME, PAIR_TOOL_NAME } from "./builtin-tools.js";
|
|
6
7
|
export { inspectAgentCapabilities } from "./capability-inspection.js";
|
|
7
8
|
export { CONNECTION_PAIRING_UNAVAILABLE_EVENT, executePairTool } from "./builtin-tool-executors.js";
|
|
8
|
-
import { resolveEvalToolStub, validateEvalRunOptions } from "./eval-run-options.js";
|
|
9
|
+
import { evalRunOptionsForRun, resolveEvalToolStub, validateEvalRunOptions } from "./eval-run-options.js";
|
|
9
10
|
import { rememberDefaultOutboundRoute } from "./default-outbound-route.js";
|
|
10
11
|
import { audienceFromRun, audienceUserKey, normalizeAgentAudience } from "./audience.js";
|
|
11
12
|
import { AgentSourceModuleLoader } from "./source-loader.js";
|
|
13
|
+
import { SandboxAuthoredToolExecutor, resolveAuthoredToolExecutionPolicy } from "./sandbox-authored-tool-executor.js";
|
|
12
14
|
import { AgentEventHandlerRegistry } from "./agent-event-handlers.js";
|
|
13
15
|
import { createMainAgentHookController as createMainAgentHookControllerImpl, createSubagentHookController as createSubagentHookControllerImpl } from "./agent-hook-controller-factory.js";
|
|
14
16
|
import { durableAgentSurfaceScope, flattenSubagents, surfaceForPath, surfaceForRun } from "./agent-surface.js";
|
|
@@ -64,7 +66,7 @@ import { completeConnectionAuthorizationCallbackImpl, replayImpl, resumeApproval
|
|
|
64
66
|
import { recordRunReplayStarted, rerunFromSnapshot } from "./run-replay.js";
|
|
65
67
|
export { RunReplayError } from "./run-replay.js";
|
|
66
68
|
import { buildRunAgentResult } from "./run-result.js";
|
|
67
|
-
import { createSubagentRunImpl, executeSubagentRunImpl, finalizeSubagentHandoffImpl, readSubagentImpl, runSubagentImpl, sendSubagentFollowupImpl } from "./subagent-execution.js";
|
|
69
|
+
import { createSubagentRunImpl, executeSubagentRunImpl, finalizeSubagentHandoffImpl, readSubagentImpl, resumeSubagentImpl, runSubagentImpl, sendSubagentFollowupImpl } from "./subagent-execution.js";
|
|
68
70
|
import { acceptBackgroundSubagentHandoff } from "./subagent-handoff.js";
|
|
69
71
|
import { createHarnessContextImpl, DEFAULT_MAX_MODEL_ITERATIONS, DEFAULT_OUTPUT_VALIDATION_MAX_RETRIES, executeHarnessTurnImpl, persistHarnessContinuationImpl, resolveAgentHarnessImpl, runHarnessLoopImpl } from "./harness-loop.js";
|
|
70
72
|
import { getAgentControlImpl, requestRunControlImpl, setAgentEnabledImpl, setAgentMaintenanceImpl } from "./operator-controls.js";
|
|
@@ -97,6 +99,7 @@ import { inferToolInput } from "./channel-http-util.js";
|
|
|
97
99
|
import { connectionPrincipalKeyForGrant, durableAgentScopeForManifest, isInstrumentationDefinition, normalizeCapturePolicy, randomHex, timestamp, } from "./runtime-util.js";
|
|
98
100
|
export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
99
101
|
manifest;
|
|
102
|
+
authoredToolExecution;
|
|
100
103
|
state;
|
|
101
104
|
runEventBus = new RunEventBus();
|
|
102
105
|
eventHandlers;
|
|
@@ -115,7 +118,7 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
115
118
|
/** @deprecated See {@link RuntimeOptions.models}. */
|
|
116
119
|
models;
|
|
117
120
|
agentHarnessOverride;
|
|
118
|
-
|
|
121
|
+
modelCredentialStore;
|
|
119
122
|
defaultAgentHarness;
|
|
120
123
|
checkpointEveryIteration;
|
|
121
124
|
checkpointRetention;
|
|
@@ -173,6 +176,7 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
173
176
|
hostInstrumentationProvided;
|
|
174
177
|
instrumentationConfig;
|
|
175
178
|
sourceLoader;
|
|
179
|
+
sandboxAuthoredToolExecutor;
|
|
176
180
|
skillBundleIndex;
|
|
177
181
|
skillResourceReader;
|
|
178
182
|
contextPolicyPromise;
|
|
@@ -185,6 +189,7 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
185
189
|
constructor(options) {
|
|
186
190
|
super();
|
|
187
191
|
this.manifest = options.manifest;
|
|
192
|
+
this.authoredToolExecution = resolveAuthoredToolExecutionPolicy(options.authoredToolExecution);
|
|
188
193
|
const normalizedState = normalizeRuntimeState(options.state ?? new InMemoryStateAdapter());
|
|
189
194
|
// Events fan out to live streams; terminal outcomes become log lines at
|
|
190
195
|
// this one choke point (logger read lazily — assigned below).
|
|
@@ -213,7 +218,7 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
213
218
|
this.coreToolPolicy = resolveCoreToolPolicy(options.coreToolPolicy, this.env, this.devMode);
|
|
214
219
|
this.models = options.models;
|
|
215
220
|
this.agentHarnessOverride = options.agentHarness;
|
|
216
|
-
this.
|
|
221
|
+
this.modelCredentialStore = options.modelCredentialStore ?? new InMemoryModelCredentialStore();
|
|
217
222
|
this.checkpointEveryIteration = resolveBooleanEnv(this.env.ASSEMBLY_LINE_CHECKPOINT_EVERY_ITERATION, true);
|
|
218
223
|
this.checkpointRetention = resolveCheckpointRetentionPolicy(options.checkpointRetention, this.env);
|
|
219
224
|
this.checkpointBlobStorageEnabled = options.blob !== undefined && this.checkpointRetention.blobThresholdBytes > 0;
|
|
@@ -319,8 +324,12 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
319
324
|
this.sourceLoader = new AgentSourceModuleLoader({
|
|
320
325
|
manifest: this.manifest,
|
|
321
326
|
sourceBundle: this.sourceBundle,
|
|
322
|
-
...(options.artifactRoot ? {
|
|
327
|
+
...(options.artifactRoot ? {
|
|
328
|
+
cacheRoot: join(resolve(options.artifactRoot), ARTIFACT_DIR_NAME, "module-cache"),
|
|
329
|
+
packageRoot: resolve(options.artifactRoot)
|
|
330
|
+
} : {})
|
|
323
331
|
});
|
|
332
|
+
this.sandboxAuthoredToolExecutor = new SandboxAuthoredToolExecutor(this.sourceLoader);
|
|
324
333
|
this.skillBundleIndex = createSkillBundleIndex(this.manifest);
|
|
325
334
|
this.skillResourceReader = createSkillResourceReader({
|
|
326
335
|
manifest: this.manifest,
|
|
@@ -1120,8 +1129,8 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
1120
1129
|
env: this.env,
|
|
1121
1130
|
logger: this.logger,
|
|
1122
1131
|
models: this.models,
|
|
1132
|
+
modelCredentialStore: this.modelCredentialStore,
|
|
1123
1133
|
agentHarnessOverride: this.agentHarnessOverride,
|
|
1124
|
-
modelHarnesses: this.modelHarnesses,
|
|
1125
1134
|
checkpointEveryIteration: this.checkpointEveryIteration,
|
|
1126
1135
|
maxModelIterations: this.maxModelIterations,
|
|
1127
1136
|
outputValidationMaxRetries: this.outputValidationMaxRetries,
|
|
@@ -1145,7 +1154,7 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
1145
1154
|
createConnectionRegistryForRun: (run, fallbackChannel, sandboxHandle, selectedConnections) => this.createConnectionRegistryForRun(run, fallbackChannel, sandboxHandle, selectedConnections),
|
|
1146
1155
|
missingRequiredConnections: (selected) => this.missingRequiredConnections(selected),
|
|
1147
1156
|
visibleToolSet: (defaultToolNames, activeSkills) => this.visibleToolSet(defaultToolNames, activeSkills),
|
|
1148
|
-
modelTools: (run, activeToolNames, connectionRegistry, discoveredConnectionTools, options) => this.modelTools(run, activeToolNames, connectionRegistry, discoveredConnectionTools, options),
|
|
1157
|
+
modelTools: (run, activeToolNames, sandboxHandle, connectionRegistry, discoveredConnectionTools, options) => this.modelTools(run, activeToolNames, sandboxHandle, connectionRegistry, discoveredConnectionTools, options),
|
|
1149
1158
|
harnessExecuteTool: (call, state) => this.harnessExecuteTool(call, state),
|
|
1150
1159
|
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1151
1160
|
hydrateCheckpointData: (data) => this.hydrateCheckpointData(data),
|
|
@@ -1431,6 +1440,9 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
1431
1440
|
async runSubagent(parentRunId, subagentName, task) {
|
|
1432
1441
|
return runSubagentImpl(this.subagentExecutionHost(), parentRunId, subagentName, task);
|
|
1433
1442
|
}
|
|
1443
|
+
async resumeSubagent(parentRunId, childRunId, subagentName, message) {
|
|
1444
|
+
return resumeSubagentImpl(this.subagentExecutionHost(), parentRunId, childRunId, subagentName, message);
|
|
1445
|
+
}
|
|
1434
1446
|
async queueSubagent(parentRunId, subagentName, task) {
|
|
1435
1447
|
const child = await createSubagentRunImpl(this.subagentExecutionHost(), parentRunId, subagentName, task, { background: true });
|
|
1436
1448
|
this.backgroundSubagents.requestDrain();
|
|
@@ -1740,8 +1752,8 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
1740
1752
|
async instructionsForRunTarget(run, target, baseInstructions) {
|
|
1741
1753
|
return instructionsForRunTargetImpl({ appendEvent: (runId, type, data) => this.state.appendEvent(runId, type, data), skillLoadDetails: (skillName) => this.skillLoadDetails(run, skillName) }, run, target, baseInstructions);
|
|
1742
1754
|
}
|
|
1743
|
-
async modelTools(run, activeToolNames, connectionRegistry, discoveredConnectionTools = new Map(), options) {
|
|
1744
|
-
return modelToolsImpl(this.toolExecutionHost(), run, activeToolNames, connectionRegistry, discoveredConnectionTools, options);
|
|
1755
|
+
async modelTools(run, activeToolNames, sandboxHandle, connectionRegistry, discoveredConnectionTools = new Map(), options) {
|
|
1756
|
+
return modelToolsImpl(this.toolExecutionHost(), run, activeToolNames, sandboxHandle, connectionRegistry, discoveredConnectionTools, options);
|
|
1745
1757
|
}
|
|
1746
1758
|
async harnessExecuteTool(call, state) {
|
|
1747
1759
|
return harnessExecuteToolImpl(this.toolExecutionHost(), call, state);
|
|
@@ -1878,6 +1890,7 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
1878
1890
|
connectionAuthorizationSessionStore: this.connectionAuthorizationSessionStore,
|
|
1879
1891
|
connectionCallbackBaseUrl: this.connectionCallbackBaseUrl,
|
|
1880
1892
|
toolOutputMaxChars: this.toolOutputMaxChars,
|
|
1893
|
+
authoredToolExecution: this.authoredToolExecution,
|
|
1881
1894
|
toolTimeoutMs: this.toolTimeoutMs,
|
|
1882
1895
|
sandboxSyncMaxAttempts: this.sandboxSyncMaxAttempts,
|
|
1883
1896
|
skillsConfigForRun: (run) => this.skillsConfigForRun(run),
|
|
@@ -1896,8 +1909,12 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
1896
1909
|
mergedConnections: () => this.mergedConnections(),
|
|
1897
1910
|
loadConnectionDefinition: (connection) => this.loadConnectionDefinition(connection),
|
|
1898
1911
|
loadTool: (tool, run) => this.loadTool(tool, run),
|
|
1912
|
+
shouldSandboxAuthoredTool: (tool, run) => this.shouldSandboxAuthoredTool(tool, run),
|
|
1913
|
+
describeSandboxedTool: (tool, sandboxHandle) => this.sandboxAuthoredToolExecutor.describe(tool, sandboxHandle),
|
|
1914
|
+
executeSandboxedTool: (tool, input, context, sandboxHandle, signal) => this.sandboxAuthoredToolExecutor.execute(tool, input, context, sandboxHandle, signal),
|
|
1899
1915
|
runSubagent: (parentRunId, subagentName, task) => this.runSubagent(parentRunId, subagentName, task),
|
|
1900
1916
|
queueSubagent: (parentRunId, subagentName, task) => this.queueSubagent(parentRunId, subagentName, task),
|
|
1917
|
+
resumeSubagent: (parentRunId, childRunId, subagentName, message) => this.resumeSubagent(parentRunId, childRunId, subagentName, message),
|
|
1901
1918
|
listBackgroundWork: (rootRunId, includeTerminal) => this.listBackgroundWork(rootRunId, includeTerminal),
|
|
1902
1919
|
getBackgroundWork: (rootRunId, childRunId) => this.getBackgroundWork(rootRunId, childRunId),
|
|
1903
1920
|
cancelBackgroundWork: (rootRunId, childRunId) => this.cancelBackgroundWork(rootRunId, childRunId),
|
|
@@ -2083,6 +2100,13 @@ export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
|
2083
2100
|
const module = await this.sourceLoader.load(tool.source);
|
|
2084
2101
|
return module.default;
|
|
2085
2102
|
}
|
|
2103
|
+
shouldSandboxAuthoredTool(tool, run) {
|
|
2104
|
+
if (tool.source.path.startsWith("__builtin__"))
|
|
2105
|
+
return false;
|
|
2106
|
+
if (this.toolStubs[tool.name] || evalRunOptionsForRun(run)?.toolStubs?.[tool.name])
|
|
2107
|
+
return false;
|
|
2108
|
+
return this.authoredToolExecution === "sandbox" || tool.execution === "sandbox";
|
|
2109
|
+
}
|
|
2086
2110
|
async result(run, response, waitingForApproval, waitingForInput, waitingForConnection) {
|
|
2087
2111
|
return buildRunAgentResult(this.state, run, response, waitingForApproval, waitingForInput, waitingForConnection);
|
|
2088
2112
|
}
|