@opengeni/runtime 0.3.1 → 0.5.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/LICENSE +190 -0
- package/dist/{chunk-HGQ252FL.js → chunk-Q36E4MDM.js} +17 -2
- package/dist/chunk-Q36E4MDM.js.map +1 -0
- package/dist/{index-CSGkld-v.d.ts → index-BrdnxaAW.d.ts} +5 -3
- package/dist/index.d.ts +106 -9
- package/dist/index.js +483 -36
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +1 -1
- package/package.json +6 -8
- package/src/context-compaction.ts +164 -16
- package/src/history-sanitizer.ts +2 -1
- package/src/index.ts +574 -19
- package/src/sandbox/selfhosted/session.ts +32 -4
- package/dist/chunk-HGQ252FL.js.map +0 -1
|
@@ -922,9 +922,11 @@ interface SelfhostedSessionDeps {
|
|
|
922
922
|
* session delta; `validateNoEnvironmentDelta` throws "Live sandbox sessions cannot
|
|
923
923
|
* change manifest environment variables" on ANY env mismatch. So `state.manifest`'s
|
|
924
924
|
* `environment` MUST EQUAL the turn's environment for the delta to be empty. The
|
|
925
|
-
* selfhosted exec routes over NATS and does NOT consume
|
|
926
|
-
*
|
|
927
|
-
*
|
|
925
|
+
* selfhosted exec routes over NATS and does NOT consume this env wholesale (the
|
|
926
|
+
* machine owns its own shell), EXCEPT the allowlisted toolspace pointers it
|
|
927
|
+
* exports per exec so `ogtool` works — see SELFHOSTED_EXEC_ENV_ALLOWLIST. The
|
|
928
|
+
* manifest carries the full env for parity. Omitted → `{}` (the negotiation-only
|
|
929
|
+
* / test path, which never applies a turn manifest, so there is no delta).
|
|
928
930
|
*/
|
|
929
931
|
environment?: Record<string, string>;
|
|
930
932
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { Tool, Computer, AgentInputItem, Model, MCPServer, ModelProvider, Agent,
|
|
|
3
3
|
export { MaxTurnsExceededError, OpenAIChatCompletionsModel, OpenAIResponsesModel } from '@openai/agents';
|
|
4
4
|
import { ContextCompactionMode, Settings, ResolvedModelProvider, ConfiguredModel, ModelProviderApi } from '@opengeni/config';
|
|
5
5
|
export { collectSandboxEnvironment, parseExposedPorts } from '@opengeni/config';
|
|
6
|
-
import { ReasoningEffort, SessionEventType, ResourceRef, ToolRef, Permission } from '@opengeni/contracts';
|
|
6
|
+
import { ReasoningEffort, SessionEventType, ResourceRef, ToolRef, Permission, McpServerConnectionRef, ToolAuthNeededPayload } from '@opengeni/contracts';
|
|
7
7
|
export { CAPABILITY_DESCRIPTORS, CapabilityDescriptor, DESKTOP_STREAM_PORT, StreamTokenPayload, StreamTokenPayload as StreamTokenPayloadType, TERMINAL_STREAM_PORT } from '@opengeni/contracts';
|
|
8
8
|
import { Capability, SandboxSessionLike, SandboxSessionState, Manifest, Capabilities, LocalDirLazySkillSource, SandboxClient } from '@openai/agents/sandbox';
|
|
9
9
|
import OpenAI from 'openai';
|
|
10
|
-
import { R as RuntimeMetricsHooks } from './index-
|
|
11
|
-
export { A as ActiveBackendResolverDeps, a as ActiveBackendUnresolvableError, b as ActivePointer, C as ChannelAConflictError, c as ChannelAEmitter, d as ChannelAExecArgs, e as ChannelAExecResult, f as ChannelANotFoundError, g as ChannelASession, h as ChannelAUnsupportedError, i as ChannelAValidationError, j as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, k as DISPLAY_STACK_TIMEOUT_MS, l as DesktopGeometry, m as DisplayStackError, n as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, o as EnsureDisplayStackResult, p as EnsureTerminalServerOptions, q as EnsureTerminalServerResult, r as EstablishedSandboxSession, s as ExposeStreamPortInput, t as ExposeStreamPortResult, u as ExposedPortEndpoint, F as FinalizeRecordingResult, L as LiveModalSandboxLeaseAttribution, M as MintStreamTokenInput, v as MockAgentResponder, w as MockAgentResponderOptions, x as MockExecHandler, y as ModalOrphanSweepResult, z as ModalSandboxAttribution, N as NatsControlRpc, B as NatsRequestConnection, G as NegotiationContext, H as NumstatEntry, P as PROVIDER_REGISTRY, I as ProviderConstructionContext, J as ProviderRegistration, K as RecordingCodec, O as RecordingContentType, Q as RecordingError, S as RecordingProcess, T as RecordingUnavailableError, U as ResolvedActiveBackend, V as RoutableBackendSession, W as RoutableSandbox, X as RoutingSandboxSession, Y as RoutingSandboxSessionDeps, Z as RoutingTransitionEvent, _ as RoutingUnsupportedError, $ as SELFHOSTED_DEFAULT_TIMEOUT_MS, a0 as SELFHOSTED_RECONNECT_WINDOW_MS, a1 as SELFHOSTED_RELAY_STREAM_PATH, a2 as STREAM_PORT, a3 as STREAM_TOKEN_DEFAULT_TTL_SECONDS, a4 as SandboxChannelAService, a5 as SandboxChannelAServiceOptions, a6 as SandboxConfigError, a7 as SandboxCreatedCallback, a8 as SandboxProviderUnavailableError, a9 as SelfhostedApplyDiff, aa as SelfhostedControlError, ab as SelfhostedEditor, ac as SelfhostedEnrollment, ad as SelfhostedExecArgs, ae as SelfhostedExecResult, af as SelfhostedImageOutput, ag as SelfhostedLivenessState, ah as SelfhostedNegotiationInput, ai as SelfhostedRelayConfig, aj as SelfhostedSandboxClient, ak as SelfhostedSession, al as SelfhostedSessionBuild, am as SelfhostedSessionDeps, an as SelfhostedSessionState, ao as SelfhostedUnavailableReason, ap as StartRecordingInput, aq as StreamPortUnavailableError, ar as TERMINAL_SERVER_TIMEOUT_MS, as as TerminalServerError, at as TerminalServerUnsupportedError, au as agentErrorToControlError, av as assertDescriptorRegistryInvariants, aw as assertProviderRegistryInvariants, ax as assertSafeRelPath, ay as backendSupportsOs, az as buildDisplayStackScript, aA as buildSelfhostedBackendSession, aB as buildStreamUrl, aC as buildTerminalServerScript, aD as contentTypeForCodec, aE as createSandboxClient, aF as createSandboxClientForBackend, aG as decodeModalSnapshotId, aH as deletePriorPersistedSnapshot, aI as deleteRecordingArtifacts, aJ as deserializeSandboxSessionStateEnvelope, aK as desktopCapableBackend, aL as ensureDisplayStack, aM as ensureTerminalServer, aN as establishSandboxSessionFromEnvelope, aO as exposeStreamPort, aP as extForCodec, aQ as isExecSessionLostBanner, aR as isProviderSandboxNotFoundError, aS as isSelfhostedProviderNotFoundError, aT as isWorkspaceEscapeError, aU as makeActiveBackendResolver, aV as mintStreamToken, aW as modalSandboxAttributionEnvironment, aX as modalSandboxAttributionTags, aY as negotiateCapabilities, aZ as negotiateSelfhostedCapabilities, a_ as offlineAgentError, a$ as offlineControlResponse, b0 as parseExecBannerSessionId, b1 as parseNumstatZ, b2 as parsePorcelainV2, b3 as parseUnifiedPatch, b4 as readRecordingBytes, b5 as readWorkspaceArchiveFromEnvelopeSessionState, b6 as recordingStorageKey, b7 as restoredSandboxSessionStateFromEntry, b8 as sandboxStateEntryFromRunState, b9 as selectBackend, ba as selfhostedLiveness, bb as serializeEstablishedSandboxEnvelope, bc as setSelfhostedApplyDiff, bd as startRecording, be as stopRecording, bf as stripExecBanner, bg as subjectFor, bh as sweepModalOrphanSandboxes, bi as tagModalSandbox, bj as tearDownDisplayStack, bk as tearDownTerminalServer, bl as terminateModalSandboxById, bm as timeoutAgentError, bn as timeoutControlResponse, bo as verifyStreamToken } from './index-
|
|
10
|
+
import { R as RuntimeMetricsHooks } from './index-BrdnxaAW.js';
|
|
11
|
+
export { A as ActiveBackendResolverDeps, a as ActiveBackendUnresolvableError, b as ActivePointer, C as ChannelAConflictError, c as ChannelAEmitter, d as ChannelAExecArgs, e as ChannelAExecResult, f as ChannelANotFoundError, g as ChannelASession, h as ChannelAUnsupportedError, i as ChannelAValidationError, j as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, k as DISPLAY_STACK_TIMEOUT_MS, l as DesktopGeometry, m as DisplayStackError, n as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, o as EnsureDisplayStackResult, p as EnsureTerminalServerOptions, q as EnsureTerminalServerResult, r as EstablishedSandboxSession, s as ExposeStreamPortInput, t as ExposeStreamPortResult, u as ExposedPortEndpoint, F as FinalizeRecordingResult, L as LiveModalSandboxLeaseAttribution, M as MintStreamTokenInput, v as MockAgentResponder, w as MockAgentResponderOptions, x as MockExecHandler, y as ModalOrphanSweepResult, z as ModalSandboxAttribution, N as NatsControlRpc, B as NatsRequestConnection, G as NegotiationContext, H as NumstatEntry, P as PROVIDER_REGISTRY, I as ProviderConstructionContext, J as ProviderRegistration, K as RecordingCodec, O as RecordingContentType, Q as RecordingError, S as RecordingProcess, T as RecordingUnavailableError, U as ResolvedActiveBackend, V as RoutableBackendSession, W as RoutableSandbox, X as RoutingSandboxSession, Y as RoutingSandboxSessionDeps, Z as RoutingTransitionEvent, _ as RoutingUnsupportedError, $ as SELFHOSTED_DEFAULT_TIMEOUT_MS, a0 as SELFHOSTED_RECONNECT_WINDOW_MS, a1 as SELFHOSTED_RELAY_STREAM_PATH, a2 as STREAM_PORT, a3 as STREAM_TOKEN_DEFAULT_TTL_SECONDS, a4 as SandboxChannelAService, a5 as SandboxChannelAServiceOptions, a6 as SandboxConfigError, a7 as SandboxCreatedCallback, a8 as SandboxProviderUnavailableError, a9 as SelfhostedApplyDiff, aa as SelfhostedControlError, ab as SelfhostedEditor, ac as SelfhostedEnrollment, ad as SelfhostedExecArgs, ae as SelfhostedExecResult, af as SelfhostedImageOutput, ag as SelfhostedLivenessState, ah as SelfhostedNegotiationInput, ai as SelfhostedRelayConfig, aj as SelfhostedSandboxClient, ak as SelfhostedSession, al as SelfhostedSessionBuild, am as SelfhostedSessionDeps, an as SelfhostedSessionState, ao as SelfhostedUnavailableReason, ap as StartRecordingInput, aq as StreamPortUnavailableError, ar as TERMINAL_SERVER_TIMEOUT_MS, as as TerminalServerError, at as TerminalServerUnsupportedError, au as agentErrorToControlError, av as assertDescriptorRegistryInvariants, aw as assertProviderRegistryInvariants, ax as assertSafeRelPath, ay as backendSupportsOs, az as buildDisplayStackScript, aA as buildSelfhostedBackendSession, aB as buildStreamUrl, aC as buildTerminalServerScript, aD as contentTypeForCodec, aE as createSandboxClient, aF as createSandboxClientForBackend, aG as decodeModalSnapshotId, aH as deletePriorPersistedSnapshot, aI as deleteRecordingArtifacts, aJ as deserializeSandboxSessionStateEnvelope, aK as desktopCapableBackend, aL as ensureDisplayStack, aM as ensureTerminalServer, aN as establishSandboxSessionFromEnvelope, aO as exposeStreamPort, aP as extForCodec, aQ as isExecSessionLostBanner, aR as isProviderSandboxNotFoundError, aS as isSelfhostedProviderNotFoundError, aT as isWorkspaceEscapeError, aU as makeActiveBackendResolver, aV as mintStreamToken, aW as modalSandboxAttributionEnvironment, aX as modalSandboxAttributionTags, aY as negotiateCapabilities, aZ as negotiateSelfhostedCapabilities, a_ as offlineAgentError, a$ as offlineControlResponse, b0 as parseExecBannerSessionId, b1 as parseNumstatZ, b2 as parsePorcelainV2, b3 as parseUnifiedPatch, b4 as readRecordingBytes, b5 as readWorkspaceArchiveFromEnvelopeSessionState, b6 as recordingStorageKey, b7 as restoredSandboxSessionStateFromEntry, b8 as sandboxStateEntryFromRunState, b9 as selectBackend, ba as selfhostedLiveness, bb as serializeEstablishedSandboxEnvelope, bc as setSelfhostedApplyDiff, bd as startRecording, be as stopRecording, bf as stripExecBanner, bg as subjectFor, bh as sweepModalOrphanSandboxes, bi as tagModalSandbox, bj as tearDownDisplayStack, bk as tearDownTerminalServer, bl as terminateModalSandboxById, bm as timeoutAgentError, bn as timeoutControlResponse, bo as verifyStreamToken } from './index-BrdnxaAW.js';
|
|
12
12
|
import 'modal';
|
|
13
13
|
import '@opengeni/agent-proto';
|
|
14
14
|
|
|
@@ -303,7 +303,9 @@ type CompactionItem = Record<string, unknown>;
|
|
|
303
303
|
declare const COMPACTION_SUMMARY_MARKER = "opengeni_context_summary";
|
|
304
304
|
declare const SUMMARY_BUFFER_TOKENS = 20000;
|
|
305
305
|
declare const COMPACT_USER_MESSAGE_MAX_TOKENS = 20000;
|
|
306
|
-
declare const
|
|
306
|
+
declare const DEFAULT_COMPACTION_THRESHOLD_RATIO = 0.6;
|
|
307
|
+
declare const MIN_COMPACTION_THRESHOLD_RATIO = 0.3;
|
|
308
|
+
declare const MAX_COMPACTION_THRESHOLD_RATIO = 0.9;
|
|
307
309
|
declare const COMPACTION_PROMPT: string;
|
|
308
310
|
declare const SUMMARY_PREFIX = "Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:";
|
|
309
311
|
declare const USER_MESSAGE_TRUNCATION_MARKER = "\n[... middle truncated for context compaction ...]\n";
|
|
@@ -317,9 +319,11 @@ declare function isCompactionSummary(item: unknown): boolean;
|
|
|
317
319
|
*/
|
|
318
320
|
declare function estimateItemTokens(item: CompactionItem): number;
|
|
319
321
|
declare function estimateTokens(items: readonly CompactionItem[]): number;
|
|
322
|
+
declare function clampCompactionThresholdRatio(value: number | undefined | null): number;
|
|
320
323
|
declare function clientCompactionThresholdTokens(input: {
|
|
321
324
|
contextWindowTokens: number;
|
|
322
325
|
contextReservedOutputTokens: number;
|
|
326
|
+
contextCompactionThresholdRatio?: number | null;
|
|
323
327
|
}): number;
|
|
324
328
|
type ClientCompactionDecision = {
|
|
325
329
|
shouldCompact: boolean;
|
|
@@ -332,6 +336,7 @@ declare function decideClientCompaction(input: {
|
|
|
332
336
|
lastInputTokens?: number | null;
|
|
333
337
|
contextWindowTokens: number;
|
|
334
338
|
contextReservedOutputTokens: number;
|
|
339
|
+
contextCompactionThresholdRatio?: number | null;
|
|
335
340
|
force?: boolean;
|
|
336
341
|
}): ClientCompactionDecision;
|
|
337
342
|
declare class CompactionNeededError extends Error {
|
|
@@ -376,12 +381,26 @@ declare function buildCompactionPromptInput(items: readonly CompactionItem[]): C
|
|
|
376
381
|
* message capped) plus one marked summary item.
|
|
377
382
|
*/
|
|
378
383
|
declare function buildCompactionReplacementHistory(items: readonly CompactionItem[], summaryBody: string): CompactionItem[];
|
|
384
|
+
type DeterministicFallbackCompactionInput = {
|
|
385
|
+
items: readonly CompactionItem[];
|
|
386
|
+
cause?: string;
|
|
387
|
+
targetTokens?: number;
|
|
388
|
+
};
|
|
389
|
+
declare function buildDeterministicFallbackCompactionHistory(input: DeterministicFallbackCompactionInput): CompactionItem[];
|
|
379
390
|
/**
|
|
380
391
|
* Build the synthetic summary item (a plain user message) appended to the
|
|
381
392
|
* rebuilt active history.
|
|
382
393
|
*/
|
|
383
394
|
declare function buildSummaryItem(summaryBody: string): CompactionItem;
|
|
384
|
-
|
|
395
|
+
type RenderCompactionTranscriptOptions = {
|
|
396
|
+
/**
|
|
397
|
+
* Hard cap for a rendered transcript. When set, oldest rendered items are
|
|
398
|
+
* dropped first while preserving the final checkpoint prompt; if the retained
|
|
399
|
+
* item itself is too large, it is middle-truncated instead of looping.
|
|
400
|
+
*/
|
|
401
|
+
maxEstimatedTokens?: number;
|
|
402
|
+
};
|
|
403
|
+
declare function renderCompactionPromptInputForChat(input: readonly CompactionItem[], options?: RenderCompactionTranscriptOptions): string;
|
|
385
404
|
|
|
386
405
|
declare const SCREENSHOT_OMITTED_PLACEHOLDER = "[screenshot omitted: an older desktop frame \u2014 the full image remains in the session event log]";
|
|
387
406
|
type ElideStaleScreenshotsResult<T> = {
|
|
@@ -408,6 +427,28 @@ type ModelResponseUsage = {
|
|
|
408
427
|
inputTokensDetails?: Record<string, number> | Array<Record<string, number>>;
|
|
409
428
|
};
|
|
410
429
|
};
|
|
430
|
+
type ResolveConnectionCredentialInput = {
|
|
431
|
+
workspaceId: string;
|
|
432
|
+
subjectId?: string;
|
|
433
|
+
serverId: string;
|
|
434
|
+
toolName?: string;
|
|
435
|
+
connectionRef: McpServerConnectionRef;
|
|
436
|
+
forceRefresh?: boolean;
|
|
437
|
+
};
|
|
438
|
+
type ResolveConnectionCredentialResult = {
|
|
439
|
+
status: "ok";
|
|
440
|
+
headers: Record<string, string>;
|
|
441
|
+
connectionId: string;
|
|
442
|
+
expiresAt?: Date | null;
|
|
443
|
+
} | {
|
|
444
|
+
status: "auth_needed";
|
|
445
|
+
reason: ToolAuthNeededPayload["reason"];
|
|
446
|
+
providerDomain: string;
|
|
447
|
+
connectionId?: string;
|
|
448
|
+
scopes?: string[];
|
|
449
|
+
resource?: string;
|
|
450
|
+
authorizationUrl?: string;
|
|
451
|
+
};
|
|
411
452
|
declare function ensureReadableStreamFrom(): void;
|
|
412
453
|
type AgentSegmentInput = {
|
|
413
454
|
kind: "message";
|
|
@@ -528,9 +569,10 @@ declare function configureOpenAI(settings: Settings): void;
|
|
|
528
569
|
* Run the compaction summarizer as one plain, tool-less, non-streaming model
|
|
529
570
|
* call against the resolved provider. `input` is the active history plus
|
|
530
571
|
* Codex's checkpoint prompt. Returns the trimmed summary text, or null on any
|
|
531
|
-
* failure (the caller
|
|
532
|
-
* -
|
|
533
|
-
* tools, or server-side compaction; it is a
|
|
572
|
+
* failure (the caller can retry with a harder-trimmed transcript, then fall
|
|
573
|
+
* back to deterministic non-LLM compaction). The call deliberately does NOT
|
|
574
|
+
* request reasoning encryption, tools, or server-side compaction; it is a
|
|
575
|
+
* self-contained summarize.
|
|
534
576
|
*
|
|
535
577
|
* Provider-aware: the summary always runs on the SAME provider that serves the
|
|
536
578
|
* turn (registry providers can't summarize through OpenAI/Azure, and vice
|
|
@@ -546,6 +588,7 @@ declare function summarizeForCompaction(settings: Settings, input: Array<Record<
|
|
|
546
588
|
api?: ModelProviderApi;
|
|
547
589
|
maxOutputTokens?: number;
|
|
548
590
|
model?: string;
|
|
591
|
+
maxTranscriptTokens?: number;
|
|
549
592
|
}): Promise<string | null>;
|
|
550
593
|
/**
|
|
551
594
|
* Pull the assistant text out of a Responses API result, shape-tolerant. Only
|
|
@@ -572,6 +615,7 @@ type BuildAgentOptions = {
|
|
|
572
615
|
mcpServers?: MCPServer[];
|
|
573
616
|
workspaceEnvironment?: WorkspaceEnvironmentContext;
|
|
574
617
|
gitTokenSeed?: string;
|
|
618
|
+
toolspaceTokenSeed?: string;
|
|
575
619
|
genesisTitleHint?: boolean;
|
|
576
620
|
instructionsTemplate?: string;
|
|
577
621
|
sessionInstructions?: string;
|
|
@@ -629,12 +673,59 @@ declare function composeAgentInstructions(template: string, workspaceEnvironment
|
|
|
629
673
|
* is a no-op that returns the composed string byte-for-byte.
|
|
630
674
|
*/
|
|
631
675
|
declare function appendSessionInstructions(composed: string, sessionInstructions?: string): string;
|
|
676
|
+
/**
|
|
677
|
+
* Appends the generic programmatic-tool-calling (toolspace) directive to the
|
|
678
|
+
* composed workspace + CORE instructions, joined by " ". This is GENERIC
|
|
679
|
+
* substrate prompting — the same text for every host, never per-host copy.
|
|
680
|
+
*
|
|
681
|
+
* Included ONLY when `toolspaceAvailable` is true, which the caller sets from the
|
|
682
|
+
* exact condition that gates the sandbox token mint: the toolspace feature is
|
|
683
|
+
* enabled AND a toolspace token was minted for THIS turn. That mint now happens
|
|
684
|
+
* on every backend including selfhosted (connected machines get the token too),
|
|
685
|
+
* so the block appears there as well; a turn with no minted token (feature off)
|
|
686
|
+
* has no toolspace URL/token in its sandbox and must not advertise a capability
|
|
687
|
+
* that is not there — the gate is false and this is a no-op. Placed BEFORE the
|
|
688
|
+
* per-session instructions so host/session specificity still wins over this
|
|
689
|
+
* substrate note.
|
|
690
|
+
*/
|
|
691
|
+
declare function appendToolspaceInstructions(composed: string, toolspaceAvailable: boolean): string;
|
|
632
692
|
/**
|
|
633
693
|
* Appends the one-shot genesis title directive (genesis turn only), joined by
|
|
634
694
|
* " " and always LAST so a white-label persona template or a per-session
|
|
635
695
|
* instruction can't drop it. A no-op when the hint is absent.
|
|
636
696
|
*/
|
|
637
697
|
declare function appendGenesisTitleDirective(instructions: string, genesisTitleHint?: boolean): string;
|
|
698
|
+
/**
|
|
699
|
+
* The tool output emitted for an MCP tool call that FAILED with a THROWN error
|
|
700
|
+
* — a JSON-RPC protocol error (e.g. -32602 invalid params), an auth 401/403, a
|
|
701
|
+
* transport failure, a timeout, or tool-not-found. Shaped as an MCP
|
|
702
|
+
* `{ isError: true, content }` result so the failure is CARRIED on the tool
|
|
703
|
+
* output rather than erased.
|
|
704
|
+
*
|
|
705
|
+
* The SDK's `defaultToolErrorFunction` would instead turn a thrown tool error
|
|
706
|
+
* into a plain STRING ("An error occurred while running the tool…") returned as
|
|
707
|
+
* a NORMAL, successful-looking result — so `agent.toolCall.output` carried no
|
|
708
|
+
* error signal and the timeline rendered the failure as success. `normalizeSdkEvent`
|
|
709
|
+
* captures `RunToolCallOutputItem.output` (the raw function return) verbatim, so
|
|
710
|
+
* returning this object makes the emitted payload's `output.isError === true`,
|
|
711
|
+
* which the timeline projection's `isErrorOutput` (packages/react/src/timeline/
|
|
712
|
+
* projection.ts) settles to "failed" and downstream client normalizers read the same field.
|
|
713
|
+
*
|
|
714
|
+
* SCOPE: this only covers THROWN MCP failures (the ones that reach an
|
|
715
|
+
* errorFunction). An MCP tool result carrying `isError: true` INLINE alongside
|
|
716
|
+
* content is stripped to its `content` by @openai/agents-core's streamable-http
|
|
717
|
+
* shim (dist/shims/mcp-server/node.js `callTool` returns `parsed.content`,
|
|
718
|
+
* dropping `parsed.isError`) BEFORE the runtime ever sees it. Covering that mode
|
|
719
|
+
* requires an SDK-level change (preserve `isError`) or reading the raw
|
|
720
|
+
* CallToolResult — tracked separately.
|
|
721
|
+
*/
|
|
722
|
+
declare function mcpToolErrorOutput(error: unknown): {
|
|
723
|
+
isError: true;
|
|
724
|
+
content: [{
|
|
725
|
+
type: "text";
|
|
726
|
+
text: string;
|
|
727
|
+
}];
|
|
728
|
+
};
|
|
638
729
|
declare function buildOpenGeniAgent(settings: Settings, resources: ResourceRef[], options?: BuildAgentOptions): Agent<any, any>;
|
|
639
730
|
/**
|
|
640
731
|
* Build the SandboxAgent capability set provider-aware.
|
|
@@ -679,6 +770,8 @@ type PrepareToolsOptions = {
|
|
|
679
770
|
subjectId?: string;
|
|
680
771
|
subjectLabel?: string;
|
|
681
772
|
firstPartyPermissions?: Permission[];
|
|
773
|
+
resolveCredential?: (input: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
|
|
774
|
+
onAuthNeeded?: (payload: ToolAuthNeededPayload) => Promise<void> | void;
|
|
682
775
|
};
|
|
683
776
|
declare function prepareAgentTools(settings: Settings, tools: ToolRef[], options?: PrepareToolsOptions): Promise<PreparedAgentTools>;
|
|
684
777
|
declare function prefixedMcpToolName(registryId: string, toolName: string): string;
|
|
@@ -712,6 +805,7 @@ type ContextRobustnessFilterOptions = {
|
|
|
712
805
|
throwOnCompactionNeeded?: boolean;
|
|
713
806
|
};
|
|
714
807
|
declare const GENESIS_TITLE_DIRECTIVE = "This is the first turn of a new session. Before responding to the user, call the opengeni__set_session_title tool with a concise 3-7 word title that summarizes what this session is about, then address the user's request normally.";
|
|
808
|
+
declare const TOOLSPACE_PROGRAMMATIC_DIRECTIVE = "Every tool on your MCP surface is also callable programmatically from the sandbox shell, so scripts can invoke tools without a model round trip per call. Run `ogtool list` to see the available tools and their input schemas (from tools/list), then `ogtool call <tool-name> '<json-args>'`; equivalently, POST MCP JSON-RPC to $OPENGENI_TOOLSPACE_URL with the bearer token read from $OPENGENI_TOOLSPACE_TOKEN_FILE. Prefer programmatic calls for loops, polling, and bulk filtering: their results stay in the sandbox and do not consume your context window. Tools that require human approval must still be invoked normally \u2014 called programmatically they return a typed error.";
|
|
715
809
|
/**
|
|
716
810
|
* callModelInputFilter that removes provider-assigned item ids (rs_/msg_/fc_…)
|
|
717
811
|
* from every input item immediately before each model call. Responses-API
|
|
@@ -800,6 +894,7 @@ type SandboxLifecycleHookContext = {
|
|
|
800
894
|
onRuntimeEvent?: (event: NormalizedRuntimeEvent) => Promise<void> | void;
|
|
801
895
|
runAs?: string;
|
|
802
896
|
gitTokenSeed?: string;
|
|
897
|
+
toolspaceTokenSeed?: string;
|
|
803
898
|
};
|
|
804
899
|
type SandboxLifecycleHook = {
|
|
805
900
|
id: string;
|
|
@@ -845,6 +940,8 @@ declare function repositoryUsesSandboxClone(settings: Settings, resource: Extrac
|
|
|
845
940
|
declare function repositoryCloneCommand(resources: Extract<ResourceRef, {
|
|
846
941
|
kind: "repository";
|
|
847
942
|
}>[]): string;
|
|
943
|
+
declare function toolspaceTokenSeedCommand(): string;
|
|
944
|
+
declare function runToolspaceTokenSeedHook(session: SandboxSessionLike, context: SandboxLifecycleHookContext): Promise<void>;
|
|
848
945
|
declare function runRepositoryCloneHook(session: SandboxSessionLike, resources: Extract<ResourceRef, {
|
|
849
946
|
kind: "repository";
|
|
850
947
|
}>[], context?: SandboxLifecycleHookContext): Promise<void>;
|
|
@@ -865,4 +962,4 @@ declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiAp
|
|
|
865
962
|
*/
|
|
866
963
|
declare function lazySkillSourceWithPackSkills(packSkills: PackSkill[]): LocalDirLazySkillSource;
|
|
867
964
|
|
|
868
|
-
export { type AgentSegmentInput, type BuildAgentOptions,
|
|
965
|
+
export { type AgentSegmentInput, type BuildAgentOptions, COMPACTION_PROMPT, COMPACTION_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, type ClientCompactionDecision, CodexSubscriptionUnavailableError, type CompactionItem, CompactionNeededError, ComputerActionError, ComputerReadOnlyError, type ComputerToolMode, ComputerUnavailableError, type ComputerUseArgs, ComputerUseCapability, type ContextRobustnessFilterOptions, DEFAULT_COMPACTION_THRESHOLD_RATIO, type ElideStaleScreenshotsOptions, type ElideStaleScreenshotsResult, GENESIS_TITLE_DIRECTIVE, type HistoryItem, MAX_COMPACTION_THRESHOLD_RATIO, MIN_COMPACTION_THRESHOLD_RATIO, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type ProductionRuntimeOverrides, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult, type RunAgentStreamOptions, RuntimeMetricsHooks, SCREENSHOT_OMITTED_PLACEHOLDER, SUMMARY_BUFFER_TOKENS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, TOOLSPACE_PROGRAMMATIC_DIRECTIVE, USER_MESSAGE_TRUNCATION_MARKER, type WorkspaceEnvironmentContext, agentsErrorRunState, appendGenesisTitleDirective, appendSessionInstructions, appendToolspaceInstructions, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, buildAgentCapabilities, buildCompactionPromptInput, buildCompactionReplacementHistory, buildDeterministicFallbackCompactionHistory, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, clampCompactionThresholdRatio, clientCompactionThresholdTokens, composeAgentInstructions, computerUse, configureOpenAI, configureRuntimeMetricsHooks, contextRobustnessFilterForSettings, coreInstructions, createProductionAgentRuntime, decideClientCompaction, elideStaleScreenshotImages, enforceInputBudget, ensureReadableStreamFrom, estimateItemTokens, estimateTokens, extractResponseOutputText, findCompactionNeededError, findKeepBoundary, isCompactionSummary, isUserMessage, lazySkillSourceWithPackSkills, materializeSandboxFileDownloads, maxTurnsExceededRunState, mcpToolErrorOutput, modelResponseUsageFromSdkEvent, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeSdkEvent, normalizeToolOutputForEvent, prefixedMcpToolName, prepareAgentTools, prepareRunInput, renderCompactionPromptInputForChat, repositoryCloneCommand, repositoryUsesSandboxClone, resolveTurnModel, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runRepositoryCloneHook, runToolspaceTokenSeedHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, toolspaceTokenSeedCommand, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, workspaceEnvironmentInstructions };
|