@opengeni/runtime 0.2.1 → 0.2.2
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.d.ts +25 -1
- package/dist/index.js +25 -15
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +55 -26
- package/src/sandbox-computer.ts +54 -9
package/dist/index.d.ts
CHANGED
|
@@ -70,12 +70,31 @@ declare class SandboxComputer implements Computer {
|
|
|
70
70
|
drag(path: [number, number][]): Promise<void>;
|
|
71
71
|
wait(): Promise<void>;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* EXPLICIT tool-transport selection, decided by the caller that knows the
|
|
75
|
+
* provider's true wire identity (the worker's model resolution — see agent-turn.ts),
|
|
76
|
+
* NOT inferred from the bound model instance's constructor name. This is the
|
|
77
|
+
* HARDENING seam: `supportsStructuredToolOutputTransport` string-sniffs the
|
|
78
|
+
* constructor for "ChatCompletions", which a wrapped / proxied / minified model
|
|
79
|
+
* instance would defeat — silently handing a chat-completions provider the HOSTED
|
|
80
|
+
* `computer_use_preview` tool it 400s on every turn. When `toolMode` is set, tools()
|
|
81
|
+
* OBEYS it and never consults the sniff:
|
|
82
|
+
* • "hosted" → the single hosted `computer_use_preview` tool (Responses backends).
|
|
83
|
+
* • "function-image" → the FUNCTION `computer_*` tools with screenshots delivered as a
|
|
84
|
+
* structured `{type:'image'}` output (the codex/ChatGPT backend,
|
|
85
|
+
* which rejects hosted tool types but SEES structured image results).
|
|
86
|
+
* • "function-text" → the FUNCTION tools with screenshots rendered as a text
|
|
87
|
+
* `data:…;base64` URL (chat-completions providers, which can't read
|
|
88
|
+
* structured image tool results).
|
|
89
|
+
*/
|
|
90
|
+
type ComputerToolMode = "hosted" | "function-image" | "function-text";
|
|
73
91
|
type ComputerUseArgs = {
|
|
74
92
|
dimensions?: [number, number];
|
|
75
93
|
readOnly?: boolean;
|
|
76
94
|
display?: string;
|
|
77
95
|
needsApproval?: boolean | ((ctx: unknown, action: unknown) => boolean | Promise<boolean>);
|
|
78
96
|
imageFunctionResults?: boolean;
|
|
97
|
+
toolMode?: ComputerToolMode;
|
|
79
98
|
};
|
|
80
99
|
declare function computerUse(args?: ComputerUseArgs): ComputerUseCapability;
|
|
81
100
|
/**
|
|
@@ -101,6 +120,9 @@ declare class ComputerUseCapability extends Capability {
|
|
|
101
120
|
readonly type = "computer-use";
|
|
102
121
|
constructor(args?: ComputerUseArgs);
|
|
103
122
|
tools(): Tool<unknown>[];
|
|
123
|
+
/** The single HOSTED `computer_use_preview` tool bound to `computer` — identical
|
|
124
|
+
* construction for the explicit "hosted" mode and the legacy structured-sniff path. */
|
|
125
|
+
private hostedComputerTool;
|
|
104
126
|
}
|
|
105
127
|
|
|
106
128
|
/**
|
|
@@ -632,6 +654,7 @@ type BuildAgentOptions = {
|
|
|
632
654
|
encryptedReasoning?: boolean;
|
|
633
655
|
contextWindowTokens?: number;
|
|
634
656
|
structuredToolTransport?: boolean;
|
|
657
|
+
computerToolMode?: ComputerToolMode;
|
|
635
658
|
codexConnectorNamespaces?: ReadonlySet<string>;
|
|
636
659
|
sandboxEnvironment?: Record<string, string>;
|
|
637
660
|
activeSandboxBackend?: Settings["sandboxBackend"];
|
|
@@ -716,6 +739,7 @@ declare function buildAgentCapabilities(settings: Settings, packSkills: PackSkil
|
|
|
716
739
|
compactionMode?: ContextCompactionMode;
|
|
717
740
|
contextWindowTokens?: number;
|
|
718
741
|
structuredToolTransport?: boolean;
|
|
742
|
+
computerToolMode?: ComputerToolMode;
|
|
719
743
|
}): ReturnType<typeof Capabilities.default>;
|
|
720
744
|
declare function sandboxRunAs(_settings: Settings): string | undefined;
|
|
721
745
|
type PreparedAgentTools = {
|
|
@@ -909,4 +933,4 @@ declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiAp
|
|
|
909
933
|
*/
|
|
910
934
|
declare function lazySkillSourceWithPackSkills(packSkills: PackSkill[]): LocalDirLazySkillSource;
|
|
911
935
|
|
|
912
|
-
export { type AgentSegmentInput, type BuildAgentOptions, COMPACTION_SUMMARY_MARKER, CodexSubscriptionUnavailableError, type CompactionItem, type CompactionPlan, ComputerActionError, ComputerReadOnlyError, ComputerUnavailableError, type ComputerUseArgs, ComputerUseCapability, GENESIS_TITLE_DIRECTIVE, type HistoryItem, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PlanCompactionInput, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type ProductionRuntimeOverrides, type RunAgentStreamOptions, SUMMARY_INSTRUCTIONS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, type WorkspaceEnvironmentContext, agentsErrorRunState, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, buildAgentCapabilities, buildCompactionMessages, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, compactionSummaryText, composeAgentInstructions, computerUse, configureOpenAI, coreInstructions, createProductionAgentRuntime, enforceInputBudget, ensureReadableStreamFrom, estimateItemTokens, estimateTokens, extractResponseOutputText, findKeepBoundary, isCompactionSummary, isUserMessage, lazySkillSourceWithPackSkills, materializeSandboxFileDownloads, maxTurnsExceededRunState, modelResponseUsageFromSdkEvent, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeSdkEvent, normalizeToolOutputForEvent, planCompaction, prefixedMcpToolName, prepareAgentTools, prepareRunInput, renderPrefixTranscript, repositoryCloneCommand, repositoryUsesSandboxClone, resolveTurnModel, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runRepositoryCloneHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, workspaceEnvironmentInstructions };
|
|
936
|
+
export { type AgentSegmentInput, type BuildAgentOptions, COMPACTION_SUMMARY_MARKER, CodexSubscriptionUnavailableError, type CompactionItem, type CompactionPlan, ComputerActionError, ComputerReadOnlyError, type ComputerToolMode, ComputerUnavailableError, type ComputerUseArgs, ComputerUseCapability, GENESIS_TITLE_DIRECTIVE, type HistoryItem, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PlanCompactionInput, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type ProductionRuntimeOverrides, type RunAgentStreamOptions, SUMMARY_INSTRUCTIONS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, type WorkspaceEnvironmentContext, agentsErrorRunState, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, buildAgentCapabilities, buildCompactionMessages, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, compactionSummaryText, composeAgentInstructions, computerUse, configureOpenAI, coreInstructions, createProductionAgentRuntime, enforceInputBudget, ensureReadableStreamFrom, estimateItemTokens, estimateTokens, extractResponseOutputText, findKeepBoundary, isCompactionSummary, isUserMessage, lazySkillSourceWithPackSkills, materializeSandboxFileDownloads, maxTurnsExceededRunState, modelResponseUsageFromSdkEvent, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeSdkEvent, normalizeToolOutputForEvent, planCompaction, prefixedMcpToolName, prepareAgentTools, prepareRunInput, renderPrefixTranscript, repositoryCloneCommand, repositoryUsesSandboxClone, resolveTurnModel, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runRepositoryCloneHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, workspaceEnvironmentInstructions };
|
package/dist/index.js
CHANGED
|
@@ -1449,16 +1449,29 @@ var ComputerUseCapability = class extends Capability {
|
|
|
1449
1449
|
// The SDK base exposes the bound runAs as a protected field.
|
|
1450
1450
|
...typeof this._runAs === "string" ? { runAs: this._runAs } : {}
|
|
1451
1451
|
});
|
|
1452
|
+
switch (this.args.toolMode) {
|
|
1453
|
+
case "hosted":
|
|
1454
|
+
return [this.hostedComputerTool(computer)];
|
|
1455
|
+
case "function-image":
|
|
1456
|
+
return computerFunctionTools(computer, this.args.readOnly ?? false, this.args.needsApproval, true);
|
|
1457
|
+
case "function-text":
|
|
1458
|
+
return computerFunctionTools(computer, this.args.readOnly ?? false, this.args.needsApproval, false);
|
|
1459
|
+
case void 0:
|
|
1460
|
+
break;
|
|
1461
|
+
}
|
|
1452
1462
|
if (supportsStructuredToolOutputTransport(this._modelInstance)) {
|
|
1453
|
-
return [
|
|
1454
|
-
computerTool({
|
|
1455
|
-
computer,
|
|
1456
|
-
...this.args.needsApproval !== void 0 ? { needsApproval: this.args.needsApproval } : {}
|
|
1457
|
-
})
|
|
1458
|
-
];
|
|
1463
|
+
return [this.hostedComputerTool(computer)];
|
|
1459
1464
|
}
|
|
1460
1465
|
return computerFunctionTools(computer, this.args.readOnly ?? false, this.args.needsApproval, this.args.imageFunctionResults ?? false);
|
|
1461
1466
|
}
|
|
1467
|
+
/** The single HOSTED `computer_use_preview` tool bound to `computer` — identical
|
|
1468
|
+
* construction for the explicit "hosted" mode and the legacy structured-sniff path. */
|
|
1469
|
+
hostedComputerTool(computer) {
|
|
1470
|
+
return computerTool({
|
|
1471
|
+
computer,
|
|
1472
|
+
...this.args.needsApproval !== void 0 ? { needsApproval: this.args.needsApproval } : {}
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1462
1475
|
};
|
|
1463
1476
|
|
|
1464
1477
|
// src/index.ts
|
|
@@ -1786,7 +1799,8 @@ function buildOpenGeniAgent(settings, resources, options = {}) {
|
|
|
1786
1799
|
capabilities: buildAgentCapabilities(settings, options.packSkills ?? [], {
|
|
1787
1800
|
compactionMode,
|
|
1788
1801
|
contextWindowTokens,
|
|
1789
|
-
...options.structuredToolTransport !== void 0 ? { structuredToolTransport: options.structuredToolTransport } : {}
|
|
1802
|
+
...options.structuredToolTransport !== void 0 ? { structuredToolTransport: options.structuredToolTransport } : {},
|
|
1803
|
+
...options.computerToolMode !== void 0 ? { computerToolMode: options.computerToolMode } : {}
|
|
1790
1804
|
})
|
|
1791
1805
|
});
|
|
1792
1806
|
agentFileDownloads.set(agent, normalizeSandboxFileDownloads(options.fileResourceDownloads ?? []).filter((download) => !download.content));
|
|
@@ -1828,17 +1842,13 @@ function buildAgentCapabilities(settings, packSkills, options = {}) {
|
|
|
1828
1842
|
}
|
|
1829
1843
|
caps.push(skills({ lazyFrom: lazySkillSourceWithPackSkills(packSkills) }));
|
|
1830
1844
|
if (settings.computerUseEnabled && settings.sandboxDesktopEnabled && desktopCapableBackend(settings.sandboxBackend)) {
|
|
1845
|
+
const explicitMode = options.computerToolMode;
|
|
1831
1846
|
const computerCapability = computerUse({
|
|
1832
1847
|
dimensions: [settings.streamResolutionWidth, settings.streamResolutionHeight],
|
|
1833
1848
|
readOnly: settings.computerUseReadOnly,
|
|
1834
|
-
|
|
1835
|
-
// model can see. The ChatGPT/Codex backend rejects HOSTED tool types but DOES
|
|
1836
|
-
// accept `input_image` content items inside a `function_call_output` (proven by
|
|
1837
|
-
// openai/codex codex-rs, whose view_image tool ships exactly that shape) — so a
|
|
1838
|
-
// structured image tool result is seen, where a text data-URL would be unreadable.
|
|
1839
|
-
...options.structuredToolTransport === false ? { imageFunctionResults: true } : {}
|
|
1849
|
+
...explicitMode ? { toolMode: explicitMode } : options.structuredToolTransport === false ? { imageFunctionResults: true } : {}
|
|
1840
1850
|
});
|
|
1841
|
-
if (options.structuredToolTransport === false) {
|
|
1851
|
+
if (!explicitMode && options.structuredToolTransport === false) {
|
|
1842
1852
|
neutralizeStructuredToolTransport(computerCapability);
|
|
1843
1853
|
}
|
|
1844
1854
|
caps.push(computerCapability);
|
|
@@ -1899,7 +1909,7 @@ async function prepareAgentTools(settings, tools, options = {}) {
|
|
|
1899
1909
|
}
|
|
1900
1910
|
const error = connectedBestEffort.errors.get(failed);
|
|
1901
1911
|
console.warn(
|
|
1902
|
-
`[mcp] optional
|
|
1912
|
+
`[mcp] optional server "${failed.name}" failed to connect/list tools; skipping it for this turn`,
|
|
1903
1913
|
error instanceof Error ? error.message : error
|
|
1904
1914
|
);
|
|
1905
1915
|
}
|