@opengeni/runtime 4.3.0-canary.36855269964001 → 4.3.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/dist/assets/codemode-client.json +1 -1
- package/dist/{chunk-PEEYZDLS.js → chunk-22M75RJF.js} +622 -890
- package/dist/chunk-22M75RJF.js.map +1 -0
- package/dist/{chunk-BK3S65CI.js → chunk-JUFVYQCY.js} +13 -91
- package/dist/chunk-JUFVYQCY.js.map +1 -0
- package/dist/claude-subscription-usage.d.ts +1 -3
- package/dist/index.d.ts +1 -7
- package/dist/index.js +2 -8
- package/dist/input-wait-yield.d.ts +0 -4
- package/dist/mcp-run-credentials.d.ts +2 -3
- package/dist/model-preparation-diagnostics.d.ts +0 -9
- package/dist/model-provider-routing.d.ts +0 -4
- package/dist/model-provider.d.ts +0 -1
- package/dist/model-request-capture.d.ts +0 -9
- package/dist/replayable-json-body.d.ts +1 -2
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +1 -3
- package/dist/sandbox/provider-command-session.d.ts +0 -6
- package/dist/sandbox/providers/modal-command-router-wire.d.ts +0 -5
- package/dist/sandbox/routing/routing-session.d.ts +4 -5
- package/dist/workspace-tool-gateway.js +2 -2
- package/package.json +12 -12
- package/src/bundled_default_skills/opengeni-client/SKILL.md +0 -5
- package/src/bundled_default_skills/opengeni-client/references/api-workflows.md +0 -8
- package/src/bundled_default_skills/opengeni-client/references/product-shapes-and-ui.md +3 -16
- package/src/claude-subscription-usage.ts +4 -23
- package/src/index.ts +2 -29
- package/src/input-wait-yield.ts +0 -7
- package/src/interaction-tools.ts +2 -12
- package/src/lazy-tool-transport.ts +14 -22
- package/src/mcp-run-credentials.ts +3 -18
- package/src/model-preparation-diagnostics.ts +1 -48
- package/src/model-provider-client.ts +1 -5
- package/src/model-provider-routing.ts +1 -95
- package/src/model-provider.ts +0 -1
- package/src/model-request-capture.ts +1 -28
- package/src/provider-history-adapter.ts +3 -24
- package/src/replayable-json-body.ts +2 -19
- package/src/sandbox/index.ts +0 -1
- package/src/sandbox/provider-command-session.ts +0 -12
- package/src/sandbox/providers/modal-command-control.ts +8 -14
- package/src/sandbox/providers/modal-command-router-wire.ts +3 -20
- package/src/sandbox/providers/modal-command-session.ts +0 -11
- package/src/sandbox/providers/modal.ts +1 -5
- package/src/sandbox/routing/routing-session.ts +6 -61
- package/src/sandbox/turn-tool-cancellation.ts +1 -8
- package/dist/chunk-BK3S65CI.js.map +0 -1
- package/dist/chunk-PEEYZDLS.js.map +0 -1
- package/dist/responses-terminal-error.d.ts +0 -17
- package/src/bundled_default_skills/opengeni-client/references/usage-allowances.md +0 -189
- package/src/responses-terminal-error.ts +0 -136
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
type Observer = (providerId: string, response: Response) => void;
|
|
2
|
-
type Prepare = (providerId: string, headers: Headers) => Promise<Headers>;
|
|
3
2
|
/** Like Codex usage headers: free observations within this turn's provider context. */
|
|
4
|
-
export declare function withClaudeUsageObserver<T>(observer: Observer, run: () => Promise<T
|
|
5
|
-
export declare function prepareClaudeSubscriptionRequest(providerId: string, input: Parameters<typeof fetch>[0], init?: RequestInit): Promise<RequestInit | undefined>;
|
|
3
|
+
export declare function withClaudeUsageObserver<T>(observer: Observer, run: () => Promise<T>): Promise<T>;
|
|
6
4
|
export declare function observeClaudeUsageResponse(providerId: string, response: Response): void;
|
|
7
5
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -35,15 +35,13 @@ import { type WorkspaceSkillSearchPath } from "./workspace-skills.js";
|
|
|
35
35
|
import { type EffectiveSkillSelection, type RuntimeSkillActivation, type RuntimeSkillIndexEntry } from "./runtime-skills.js";
|
|
36
36
|
export { composeRuntimeSkills, loadNativeToolSkillArtifacts, readRuntimeSkill, skillCatalogFromComposition, type EffectiveSkillSelection, type InstalledSkillActivation, type NativeToolSkillSet, type RuntimeSkillActivation, type RuntimeSkillArtifact, type RuntimeSkillArtifactFile, type RuntimeSkillComposition, type RuntimeSkillDescriptor, type RuntimeSkillIndexEntry, type SessionSkillActivation, } from "./runtime-skills.js";
|
|
37
37
|
import { type PersistentAgentInstructionInspection } from "./model-context-inspector.js";
|
|
38
|
-
import { type ModelCallLifecycle } from "./model-request-capture.js";
|
|
39
|
-
export { beforeModelRequest as awaitModelCallAdmission } from "./model-request-capture.js";
|
|
40
38
|
import { type ModelPreparationMeasurement } from "./model-preparation-diagnostics.js";
|
|
41
39
|
import type { ModelResponseUsage, NormalizedRuntimeEvent, SerializedHumanInputInterruption, SerializedInteractionInterventionInterruption } from "./run-events.js";
|
|
42
40
|
export { buildPortableSkillArtifact, getSkillLibraryEntry, isSkillLibraryEntryId, listSkillLibraryEntries, loadSkillLibrarySkill, PORTABLE_SKILL_MAX_FILE_BYTES, PORTABLE_SKILL_MAX_FILES, PORTABLE_SKILL_MAX_TOTAL_BYTES, parsePortableSkillFrontmatter, skillLibraryRepositoryUrl, skillArtifactContentSha256, type PortableSkillArtifact, type SkillLibraryEntry, type SkillLibraryFile, type SkillLibrarySkill, } from "./skill-library.js";
|
|
43
41
|
export { MCP_LIFECYCLE_OUTCOMES, MCP_LIFECYCLE_PHASES, MCP_LIFECYCLE_POLICIES, MCP_TOOL_CALL_OUTCOMES, SANDBOX_READINESS_REPLACEMENT_OUTCOMES, type McpLifecycleOutcome, type McpLifecyclePhase, type McpLifecyclePolicy, type McpToolCallOutcome, type RuntimeMetricsHooks, type SandboxReadinessReplacementOutcome, } from "./metrics.js";
|
|
44
42
|
export type { ModelPreparationMeasurement, ModelPreparationPhase, } from "./model-preparation-diagnostics.js";
|
|
45
43
|
export { markModelPreparationFirstSandboxOperation, recordModelPreparationMeasurement, } from "./model-preparation-diagnostics.js";
|
|
46
|
-
export { CodexSubscriptionUnavailableError, OrganizationGatewayUnavailableError, OrganizationOpenRouterUnavailableError, MultiProviderModelProvider, OpenGeniChatCompletionsModel, OpenGeniResponsesModel,
|
|
44
|
+
export { CodexSubscriptionUnavailableError, OrganizationGatewayUnavailableError, OrganizationOpenRouterUnavailableError, MultiProviderModelProvider, OpenGeniChatCompletionsModel, OpenGeniResponsesModel, UNKNOWN_MODEL_FINISH_REASON_CODE, UnknownModelFinishReasonError, WorkspaceGatewayUnavailableError, WorkspaceOpenRouterUnavailableError, WorkspaceModelPolicyBlockedError, XaiSubscriptionUnavailableError, azureOpenAIDefaultQuery, buildModelInstance, buildOpenAIClientFromSettings, buildProviderClient, configureOpenAI, configureRuntimeMetricsHooks, modelRequestPolicyForProvider, normalizeVercelGatewayRequestBody, resolveTurnModel, vercelGatewayRoutingFetch, } from "./model-provider.js";
|
|
47
45
|
export { appendWorkspaceGovernance, CompanyProfilePromptLimitError, hasActiveWorkspaceInstructionPolicy, renderWorkspaceGovernanceContext, WorkspaceGovernancePromptLimitError, type WorkspaceGovernanceContext, } from "./workspace-governance.js";
|
|
48
46
|
export { buildModelContextSnapshot, buildModelContextSnapshotFromRequest, createModelVisibleContextCaptureFilter, joinPersistentAgentInstructionLayers, type PersistentAgentInstructionInspection, type PersistentAgentInstructionLayerDraft, } from "./model-context-inspector.js";
|
|
49
47
|
export { createTurnToolCancellationController, TurnSandboxCommandCancelledError, } from "./sandbox/turn-tool-cancellation.js";
|
|
@@ -1041,10 +1039,6 @@ export declare function restoreInterruptedRunState(agent: Agent<any, any>, seria
|
|
|
1041
1039
|
export declare const TURN_OPERATIONAL_NOTICE_PREFIX = "[OpenGeni turn-scoped operational notice]\n";
|
|
1042
1040
|
export declare function prepareRunInput(agent: Agent<any, any>, input: AgentSegmentInput, options?: PrepareInputOptions): Promise<PreparedAgentInput>;
|
|
1043
1041
|
export type RunAgentStreamOptions = {
|
|
1044
|
-
/** Producer-side gate before calling any resolved model/provider. */
|
|
1045
|
-
beforeModelRequest?: ModelCallLifecycle["beforeModelRequest"];
|
|
1046
|
-
/** Register terminal response settlement before the next producer model request. */
|
|
1047
|
-
onModelResponse?: ModelCallLifecycle["onModelResponse"];
|
|
1048
1042
|
/** Abort the provider/tool loop when the owning activity is cancelled. */
|
|
1049
1043
|
signal?: AbortSignal;
|
|
1050
1044
|
/** Nonblocking phase measurements for request preparation before provider I/O. */
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,6 @@ import {
|
|
|
52
52
|
REMOTE_COMPACTION_V2_BETA_FEATURE,
|
|
53
53
|
REMOTE_COMPACTION_V2_IMPLEMENTATION,
|
|
54
54
|
REMOTE_V2_RETAINED_MESSAGE_TOKEN_BUDGET,
|
|
55
|
-
ResponsesStreamingTerminalError,
|
|
56
55
|
RunMcpCredentialError,
|
|
57
56
|
RunMcpCredentials,
|
|
58
57
|
SANDBOX_READINESS_REPLACEMENT_OUTCOMES,
|
|
@@ -88,7 +87,6 @@ import {
|
|
|
88
87
|
attemptToolCallMeta,
|
|
89
88
|
azureCliLoginCommand,
|
|
90
89
|
azureOpenAIDefaultQuery,
|
|
91
|
-
beforeModelRequest,
|
|
92
90
|
boundModelToolOutputsFilterForSettings,
|
|
93
91
|
buildAgentCapabilities,
|
|
94
92
|
buildCompactionPromptInput,
|
|
@@ -285,7 +283,7 @@ import {
|
|
|
285
283
|
workspaceEnvironmentInstructions,
|
|
286
284
|
wrapAttemptToolDefinitions,
|
|
287
285
|
wrapAttemptToolExecute
|
|
288
|
-
} from "./chunk-
|
|
286
|
+
} from "./chunk-22M75RJF.js";
|
|
289
287
|
import {
|
|
290
288
|
ActiveBackendUnresolvableError,
|
|
291
289
|
BROWSER_CONTROL_ADMIN_TOKEN_FILE,
|
|
@@ -496,7 +494,6 @@ import {
|
|
|
496
494
|
recordingStorageKey,
|
|
497
495
|
redactOpenSandboxSignedUriPath,
|
|
498
496
|
relativeConnectedMachinePath,
|
|
499
|
-
renderRoutingMutationOutcomeUnknownToolResult,
|
|
500
497
|
renderSelfhostedFault,
|
|
501
498
|
renewSandboxProviderExpiration,
|
|
502
499
|
repairSerializedRunStateExposedPorts,
|
|
@@ -563,7 +560,7 @@ import {
|
|
|
563
560
|
withRunCredentialsClient,
|
|
564
561
|
withRunCredentialsSession,
|
|
565
562
|
withoutSandboxProviderIdentity
|
|
566
|
-
} from "./chunk-
|
|
563
|
+
} from "./chunk-JUFVYQCY.js";
|
|
567
564
|
import "./chunk-7KVMU7O3.js";
|
|
568
565
|
import "./chunk-4A4XTKKX.js";
|
|
569
566
|
import "./chunk-GUJMCB7F.js";
|
|
@@ -707,7 +704,6 @@ export {
|
|
|
707
704
|
REPOSITORY_DISCOVERY_LIMIT,
|
|
708
705
|
RecordingError,
|
|
709
706
|
RecordingUnavailableError,
|
|
710
|
-
ResponsesStreamingTerminalError,
|
|
711
707
|
RoutingActiveRouteChangedError,
|
|
712
708
|
RoutingBackendRecoveryRequiredError,
|
|
713
709
|
RoutingMutationOutcomeUnknownError,
|
|
@@ -794,7 +790,6 @@ export {
|
|
|
794
790
|
assertProviderRegistryInvariants,
|
|
795
791
|
assertSafeRelPath,
|
|
796
792
|
attemptToolCallMeta,
|
|
797
|
-
beforeModelRequest as awaitModelCallAdmission,
|
|
798
793
|
azureCliLoginCommand,
|
|
799
794
|
azureOpenAIDefaultQuery,
|
|
800
795
|
backendSupportsOs,
|
|
@@ -1045,7 +1040,6 @@ export {
|
|
|
1045
1040
|
relativeConnectedMachinePath,
|
|
1046
1041
|
releaseMcpResultCustomDataFromSdkEvent,
|
|
1047
1042
|
renderCompactionPromptInputForChat,
|
|
1048
|
-
renderRoutingMutationOutcomeUnknownToolResult,
|
|
1049
1043
|
renderSelfhostedFault,
|
|
1050
1044
|
renderSessionGoalContext,
|
|
1051
1045
|
renderWorkspaceGovernanceContext,
|
|
@@ -44,10 +44,6 @@ export declare class InputWaitYield {
|
|
|
44
44
|
* rolls back the remote mutation nor replaces its durable attempt authority.
|
|
45
45
|
*/
|
|
46
46
|
sealForSettlement(signal?: AbortSignal | undefined): Promise<void>;
|
|
47
|
-
/** A settled stream may need one final-reply handoff before attempt closure.
|
|
48
|
-
* Drain already-admitted receipts without reopening that stream's admission.
|
|
49
|
-
*/
|
|
50
|
-
drainForHandoff(signal?: AbortSignal | undefined): Promise<void>;
|
|
51
47
|
private endStream;
|
|
52
48
|
private assertCurrent;
|
|
53
49
|
private openTools;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { CredentialProviderMcpMaterial
|
|
1
|
+
import { CredentialProviderMcpMaterial } from "@opengeni/contracts";
|
|
2
2
|
export type RunMcpCredentialTarget = {
|
|
3
3
|
id: string;
|
|
4
4
|
url: string;
|
|
5
|
-
connectionRef?: McpServerConnectionRef | undefined;
|
|
6
5
|
};
|
|
7
6
|
export type RunMcpCredentialMaterial = {
|
|
8
7
|
mcp?: CredentialProviderMcpMaterial;
|
|
@@ -27,7 +26,7 @@ export declare class RunMcpCredentials {
|
|
|
27
26
|
/** Validate a complete replacement before changing any live request headers. */
|
|
28
27
|
prepare(material: RunMcpCredentialMaterial | null): () => void;
|
|
29
28
|
replace(material: RunMcpCredentialMaterial | null): void;
|
|
30
|
-
/** Refuse credentials for
|
|
29
|
+
/** Refuse credentials for omitted, local, or rewritten server routes. */
|
|
31
30
|
assertRemoteTargets(targets: readonly RunMcpCredentialTarget[]): void;
|
|
32
31
|
excludeLocalTarget(id: string): void;
|
|
33
32
|
has(id: string): boolean;
|
|
@@ -6,21 +6,12 @@ export type ModelPreparationMeasurement = {
|
|
|
6
6
|
count?: number;
|
|
7
7
|
};
|
|
8
8
|
type ModelPreparationObserver = (measurement: ModelPreparationMeasurement) => void;
|
|
9
|
-
type ModelTransportFetch = (...args: Parameters<typeof fetch>) => ReturnType<typeof fetch>;
|
|
10
9
|
export declare function withModelPreparationObserver<T>(observer: ModelPreparationObserver | undefined, callback: () => T): T;
|
|
11
10
|
/** Bind one attempt-local durable checkpoint immediately before generic model
|
|
12
11
|
* transport enters fetch. Cached provider clients are process-global, so this
|
|
13
12
|
* authority must be async-local rather than stored on the client instance. */
|
|
14
13
|
export declare function withModelTransportStartedObserver<T>(observer: (() => Promise<void> | void) | undefined, callback: () => T): T;
|
|
15
14
|
export declare function recordModelTransportStarted(): Promise<void>;
|
|
16
|
-
/** The OpenAI SDK retries thrown fetch errors and replaces their identity with
|
|
17
|
-
* APIConnectionError. Carry only our pre-wire refusal through its HTTP-error
|
|
18
|
-
* path, which honors the retry veto. Native transports keep the original throw.
|
|
19
|
-
* Each fetch owns its context even when concurrent turns share a cached client.
|
|
20
|
-
*/
|
|
21
|
-
export declare function sdkModelTransportAdmissionFetch(inner: ModelTransportFetch): ModelTransportFetch;
|
|
22
|
-
/** Restore the exact host-owned error after the SDK has suppressed retries. */
|
|
23
|
-
export declare function rethrowModelTransportAdmissionRefusal(headers: Headers): void;
|
|
24
15
|
/** Record the first routed sandbox operation boundary without publishing an
|
|
25
16
|
* overlapping parent duration. The observer receives only exclusive leaf
|
|
26
17
|
* buckets; this boundary exists solely to split the surrounding SDK work. */
|
|
@@ -16,10 +16,6 @@ export declare class OpenGeniChatCompletionsModel extends OpenAIChatCompletionsM
|
|
|
16
16
|
export declare class OpenGeniResponsesModel extends AppendOnlyOpenAIResponsesModel {
|
|
17
17
|
protected readonly provider: ResolvedModelProvider;
|
|
18
18
|
constructor(client: OpenAI, model: string, provider: ResolvedModelProvider);
|
|
19
|
-
protected _fetchResponse(request: ModelRequest, stream: false): Promise<OpenAI.Responses.Response>;
|
|
20
|
-
protected _fetchResponse(request: ModelRequest, stream: true): Promise<AsyncIterable<OpenAI.Responses.ResponseStreamEvent>>;
|
|
21
|
-
private classifiedResponseStream;
|
|
22
|
-
private ownsResponsesTerminalClassification;
|
|
23
19
|
protected _buildResponsesCreateRequest(request: ModelRequest, stream: boolean): {
|
|
24
20
|
requestData: Record<string, any>;
|
|
25
21
|
sdkRequestHeaders: Record<string, string | null>;
|
package/dist/model-provider.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Settings } from "@opengeni/config";
|
|
2
|
-
export { ResponsesStreamingTerminalError } from "./responses-terminal-error.js";
|
|
3
2
|
export { CodexSubscriptionUnavailableError, OrganizationGatewayUnavailableError, OrganizationOpenRouterUnavailableError, UNKNOWN_MODEL_FINISH_REASON_CODE, UnknownModelFinishReasonError, WorkspaceGatewayUnavailableError, WorkspaceOpenRouterUnavailableError, WorkspaceModelPolicyBlockedError, XaiSubscriptionUnavailableError, } from "./model-provider-errors.js";
|
|
4
3
|
export { azureOpenAIDefaultQuery, buildOpenAIClientFromSettings, buildProviderClient, configureRuntimeMetricsHooks, recordRuntimeMcpLifecycleMetric, recordRuntimeMcpToolCallMetric, } from "./model-provider-client.js";
|
|
5
4
|
export { modelRequestPolicyForProvider, normalizeVercelGatewayRequestBody, } from "./model-provider-request-policy.js";
|
|
@@ -3,15 +3,6 @@ export type ModelRequestCapture = ((request: ModelRequest) => void | Promise<voi
|
|
|
3
3
|
nextProviderRequestIndex?: () => number;
|
|
4
4
|
onProviderRequest?: (provider: string, body: string | null, reason?: string, index?: number) => void | Promise<void>;
|
|
5
5
|
};
|
|
6
|
-
/** Awaited producer-side authority, separate from observational request capture. */
|
|
7
|
-
export type ModelCallLifecycle = {
|
|
8
|
-
beforeModelRequest?: () => Promise<void>;
|
|
9
|
-
/** Register before yielding so the next model entry waits for consumer settlement. */
|
|
10
|
-
onModelResponse?: (event: StreamEvent) => Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
export declare function withModelCallLifecycle<T>(lifecycle: ModelCallLifecycle, fn: () => T): T;
|
|
13
|
-
export declare function beforeModelRequest(): Promise<void>;
|
|
14
|
-
export declare function modelResponseSettlement(event: StreamEvent): Promise<void> | undefined;
|
|
15
6
|
/** The same agent can re-enter runAgentStream after in-activity compaction. */
|
|
16
7
|
export declare function nextModelContextCaptureIndex(agent: object): number;
|
|
17
8
|
export declare function withModelRequestCapture<T>(capture: ModelRequestCapture | undefined, fn: () => T): T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import OpenAI
|
|
1
|
+
import OpenAI from "openai";
|
|
2
2
|
import type { APIPromise } from "openai/core/api-promise";
|
|
3
3
|
/** Internal fetch-init hook used only when a transport performs its own retry. */
|
|
4
4
|
export declare const REPLAYABLE_REQUEST_BODY_FACTORY: unique symbol;
|
|
@@ -46,7 +46,6 @@ export declare function requestBodyText(body: BodyInit | null | undefined): Prom
|
|
|
46
46
|
export declare class ReplayableJsonOpenAI extends OpenAI {
|
|
47
47
|
private readonly modelRequestPolicy;
|
|
48
48
|
constructor(options: OpenAIOptions, hooks?: ReplayableJsonOpenAIHooks);
|
|
49
|
-
protected makeStatusError(status: number, error: NonNullable<Parameters<typeof APIError.generate>[1]>, message: string | undefined, headers: Headers): APIError;
|
|
50
49
|
post<Rsp>(path: string, opts?: OpenAIPostOptions): APIPromise<Rsp>;
|
|
51
50
|
buildRequest(inputOptions: OpenAIBuildOptions, context?: OpenAIBuildContext): Promise<OpenAIBuildResult>;
|
|
52
51
|
}
|
package/dist/sandbox/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export { nextDurableOpId, runWithToolCallCorrelation, sanitizeOpIdToken } from "
|
|
|
49
49
|
export { negotiateSelfhostedCapabilities, selfhostedLiveness, selfhostedHeartbeatLiveness, SELFHOSTED_RECONNECT_WINDOW_MS, type SelfhostedNegotiationInput, type SelfhostedLivenessState, type SelfhostedEnrollment, } from "./selfhosted/capabilities.js";
|
|
50
50
|
export { MockAgentResponder, type MockAgentResponderOptions, type MockExecHandler, } from "./selfhosted/testing.js";
|
|
51
51
|
export { createMockSelfhostedOpStream, FakeOpRunner, type FakeOpScript, InMemoryOpStreamTransport, } from "./selfhosted/op-testing.js";
|
|
52
|
-
export { isRoutingMutationOutcomeUnknownError, RoutingBackendRecoveryRequiredError, RoutingMutationOutcomeUnknownError,
|
|
52
|
+
export { isRoutingMutationOutcomeUnknownError, RoutingBackendRecoveryRequiredError, RoutingMutationOutcomeUnknownError, RoutingRetainedProcessNotFoundError, RoutingSandboxSession, RoutingWorkspaceRootChangedError, RoutingActiveRouteChangedError, RoutingUnsupportedError, type ActivePointer, type DefaultBackendLossResult, type RoutableBackendSession, type ResolvedActiveBackend, type RoutingMutationSettlementResult, type RoutingSandboxFirstOperationObservation, type RoutingSandboxFirstOperationObserver, type RoutingSandboxFirstOperationPhase, type RoutingSandboxFirstOperationPhaseObservation, type RoutingSandboxOperationObservation, type RoutingSandboxOperationObserver, type RoutingSandboxCaptureWaitObserver, type RoutingSandboxPhaseOutcome, type RoutingSandboxWaitObservation, type RoutingRetainedProcess, type RoutingRetainedProcessAdoption, type RoutingRetainedProcessTerminalProof, type RoutingSandboxSessionDeps, type RoutingTransitionEvent, } from "./routing/routing-session.js";
|
|
53
53
|
export { makeActiveBackendResolver, ActiveBackendUnresolvableError, swapTargetEstablishability, type ActiveBackendResolverDeps, type RoutableSandbox, type BackendUnresolvableCode, type SwapTargetEstablishability, } from "./routing/backend-resolver.js";
|
|
54
54
|
/**
|
|
55
55
|
* Construct the raw provider SandboxClient for the configured backend. Registry-
|
package/dist/sandbox/index.js
CHANGED
|
@@ -206,7 +206,6 @@ import {
|
|
|
206
206
|
recordingStorageKey,
|
|
207
207
|
redactOpenSandboxSignedUriPath,
|
|
208
208
|
relativeConnectedMachinePath,
|
|
209
|
-
renderRoutingMutationOutcomeUnknownToolResult,
|
|
210
209
|
renderSelfhostedFault,
|
|
211
210
|
renewSandboxProviderExpiration,
|
|
212
211
|
repairSerializedRunStateExposedPorts,
|
|
@@ -273,7 +272,7 @@ import {
|
|
|
273
272
|
withRunCredentialsClient,
|
|
274
273
|
withRunCredentialsSession,
|
|
275
274
|
withoutSandboxProviderIdentity
|
|
276
|
-
} from "../chunk-
|
|
275
|
+
} from "../chunk-JUFVYQCY.js";
|
|
277
276
|
import "../chunk-7KVMU7O3.js";
|
|
278
277
|
import "../chunk-4A4XTKKX.js";
|
|
279
278
|
import "../chunk-GUJMCB7F.js";
|
|
@@ -487,7 +486,6 @@ export {
|
|
|
487
486
|
recordingStorageKey,
|
|
488
487
|
redactOpenSandboxSignedUriPath,
|
|
489
488
|
relativeConnectedMachinePath,
|
|
490
|
-
renderRoutingMutationOutcomeUnknownToolResult,
|
|
491
489
|
renderSelfhostedFault,
|
|
492
490
|
renewSandboxProviderExpiration,
|
|
493
491
|
repairSerializedRunStateExposedPorts,
|
|
@@ -37,12 +37,6 @@ export type ProviderCommandPersistence = {
|
|
|
37
37
|
export declare class ProviderCommandStartRejectedError extends Error {
|
|
38
38
|
constructor(cause: unknown);
|
|
39
39
|
}
|
|
40
|
-
/** Start was attempted exactly once, but its acknowledgement is unavailable.
|
|
41
|
-
* The client-chosen locator is reconciliation authority, never replay authority. */
|
|
42
|
-
export declare class ProviderCommandStartOutcomeUnknownError extends Error {
|
|
43
|
-
readonly command: ModalRouterProviderCommand;
|
|
44
|
-
constructor(command: ModalRouterProviderCommand, cause: unknown);
|
|
45
|
-
}
|
|
46
40
|
export type ProviderCommandSession = {
|
|
47
41
|
verifyCommandSupervisionCapability?(): Promise<{
|
|
48
42
|
sandboxId: string;
|
|
@@ -21,11 +21,6 @@ export declare class ModalCommandStartPreDispatchUnavailableError extends Error
|
|
|
21
21
|
private constructor();
|
|
22
22
|
static ensureReady(client: Client, signal?: AbortSignal): Promise<void>;
|
|
23
23
|
}
|
|
24
|
-
/** Local cancellation/closure before Start dispatch. This permits exact
|
|
25
|
-
* never-started reservation settlement, NOT another launch or turn recovery. */
|
|
26
|
-
export declare class ModalCommandStartNotDispatchedError extends Error {
|
|
27
|
-
constructor(cause: unknown);
|
|
28
|
-
}
|
|
29
24
|
export type ModalRouterIdentity = {
|
|
30
25
|
taskId: string;
|
|
31
26
|
execId: string;
|
|
@@ -175,11 +175,11 @@ export interface RoutingSandboxSessionDeps {
|
|
|
175
175
|
op: string;
|
|
176
176
|
backend: ResolvedActiveBackend;
|
|
177
177
|
admission: unknown;
|
|
178
|
-
outcome: "resolved" | "rejected"
|
|
179
|
-
/** Provider result for a resolved call.
|
|
178
|
+
outcome: "resolved" | "rejected";
|
|
179
|
+
/** Provider result for a resolved call. Never present for rejection. */
|
|
180
180
|
result?: unknown;
|
|
181
|
-
/**
|
|
182
|
-
*
|
|
181
|
+
/** Stable candidate generated before durable promotion is attempted. It is
|
|
182
|
+
* supplied only when the provider returned a positive yielded-session id. */
|
|
183
183
|
retainedProcess?: RoutingRetainedProcess;
|
|
184
184
|
}) => Promise<void | RoutingMutationSettlementResult>;
|
|
185
185
|
/** Admit one model/user-visible stdin mutation under the already-durable
|
|
@@ -343,7 +343,6 @@ export declare class RoutingRetainedProcessNotFoundError extends Error {
|
|
|
343
343
|
readonly retryable = false;
|
|
344
344
|
constructor(providerSessionId: number);
|
|
345
345
|
}
|
|
346
|
-
export declare function renderRoutingMutationOutcomeUnknownToolResult(error: RoutingMutationOutcomeUnknownError): string;
|
|
347
346
|
/**
|
|
348
347
|
* ONE stable session-shaped object the SDK binds to. Every method re-reads the
|
|
349
348
|
* pointer, resolves the active backend (cached by epoch), and dispatches. A
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/runtime",
|
|
3
|
-
"version": "4.3.0
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,17 +63,17 @@
|
|
|
63
63
|
"@openai/agents": "0.14.3",
|
|
64
64
|
"@openai/agents-core": "0.14.3",
|
|
65
65
|
"@openai/agents-extensions": "0.14.3",
|
|
66
|
-
"@opengeni/agent-proto": "^0.6.0
|
|
67
|
-
"@opengeni/capabilities": "^0.3.4
|
|
68
|
-
"@opengeni/codemode": "^0.6.5
|
|
69
|
-
"@opengeni/codex": "^0.2.29
|
|
70
|
-
"@opengeni/config": "^3.1.1
|
|
71
|
-
"@opengeni/contracts": "^5.4.0
|
|
72
|
-
"@opengeni/network": "^0.3.1
|
|
73
|
-
"@opengeni/observability": "^0.8.35
|
|
74
|
-
"@opengeni/sdk": "^7.4.0
|
|
75
|
-
"@opengeni/tool-gateway": "^0.1.16
|
|
76
|
-
"@opengeni/xai-subscription": "^0.1.4
|
|
66
|
+
"@opengeni/agent-proto": "^0.6.0",
|
|
67
|
+
"@opengeni/capabilities": "^0.3.4",
|
|
68
|
+
"@opengeni/codemode": "^0.6.5",
|
|
69
|
+
"@opengeni/codex": "^0.2.29",
|
|
70
|
+
"@opengeni/config": "^3.1.1",
|
|
71
|
+
"@opengeni/contracts": "^5.4.0",
|
|
72
|
+
"@opengeni/network": "^0.3.1",
|
|
73
|
+
"@opengeni/observability": "^0.8.35",
|
|
74
|
+
"@opengeni/sdk": "^7.4.0",
|
|
75
|
+
"@opengeni/tool-gateway": "^0.1.16",
|
|
76
|
+
"@opengeni/xai-subscription": "^0.1.4",
|
|
77
77
|
"debug": "4.4.3",
|
|
78
78
|
"modal": "0.9.0",
|
|
79
79
|
"openai": "6.47.0",
|
|
@@ -184,11 +184,6 @@ Read selectively: [Product integration shapes](references/product-integration-sh
|
|
|
184
184
|
[Data tools and credentials](references/data-tools-and-credentials.md), and
|
|
185
185
|
[External users and embedded connection setup](references/external-users-and-connect.md).
|
|
186
186
|
|
|
187
|
-
For per-seat included usage, administrator splits, top-ups, team budgets, or
|
|
188
|
-
browser progress meters, read [Usage allowances](references/usage-allowances.md).
|
|
189
|
-
Keep organization-budget writes on the backend; the conversation proxy exposes
|
|
190
|
-
only own usage. These are post-call ceilings, not prepaid reservations.
|
|
191
|
-
|
|
192
187
|
## Build Gotchas
|
|
193
188
|
|
|
194
189
|
- Always pass `baseUrl` (`process.env.OPENGENI_API_BASE_URL`); the chat facade
|
|
@@ -25,8 +25,6 @@ Only add `x-opengeni-access-key` when the operator says the deployment
|
|
|
25
25
|
shared-key boundary is enabled. It is not a replacement for organization API
|
|
26
26
|
keys in managed SaaS.
|
|
27
27
|
|
|
28
|
-
A full organization API key can provision workspaces, members and asUser sessions; /v1/access/me reports this as credential.effectiveWorkspacePermissions.
|
|
29
|
-
|
|
30
28
|
## Minimal Server-Side Session Client
|
|
31
29
|
|
|
32
30
|
```ts
|
|
@@ -249,12 +247,6 @@ Never distribute an OpenGeni credential to a Connected Machine or try to inject
|
|
|
249
247
|
|
|
250
248
|
## Billing And Limits
|
|
251
249
|
|
|
252
|
-
For per-seat plans, team budgets, administrator splits, and top-ups, read
|
|
253
|
-
[Usage allowances](usage-allowances.md). Amounts are integer USD micros,
|
|
254
|
-
configuration/member writes are versioned, grants are operation-keyed, and
|
|
255
|
-
the conversation proxy exposes only `/usage/me`. Verify actual debit/reset
|
|
256
|
-
and webhook behavior before promising enforcement or notifications.
|
|
257
|
-
|
|
258
250
|
Managed SaaS uses prepaid Stripe credits and local usage/cost accounting. Client behavior should be simple:
|
|
259
251
|
|
|
260
252
|
- Show billing/credit status from `/v1/billing` when the user has billing permission.
|
|
@@ -31,22 +31,9 @@ console routes and 404 on the product origin. Never pass them to a raw `<a>`.
|
|
|
31
31
|
proxy `sandboxFiles: true` (default off) plus `files:read`; they are confined
|
|
32
32
|
to the selected working directory, including on Connected Machines, and
|
|
33
33
|
refuse symlinked paths. Disabled sandbox links render unavailable.
|
|
34
|
-
-
|
|
35
|
-
`
|
|
36
|
-
`
|
|
37
|
-
(for example the main area beside an assistant panel, a full-screen sheet on
|
|
38
|
-
phones) and pass `onOpenArtifact` to `SessionConversation` (or
|
|
39
|
-
`viewerLinkResolver` to `MessageTimeline`). Enable the proxy's
|
|
40
|
-
`artifacts: true`; editors also need the document, spreadsheet, and
|
|
41
|
-
presentation runtimes (`@opengeni/artifact-kernel-wasm-document`,
|
|
42
|
-
`@opengeni/artifact-kernel-wasm-spreadsheet`,
|
|
43
|
-
`@opengeni/artifact-kernel-wasm-presentation`) plus the SDK Worker URL
|
|
44
|
-
(`editableRuntimes`). A custom host proxy reports the viewer capability with
|
|
45
|
-
`artifactViewerCapability` from `@opengeni/sdk`. Close the viewer when the session changes.
|
|
46
|
-
Translate its copy with `labels` (partial `ArtifactLabels`) or
|
|
47
|
-
`ArtifactLabelsProvider`.
|
|
48
|
-
- Other routing: `resolveLink={(target) => ... ({ href } | { open } | null)}`
|
|
49
|
-
on `SessionConversation` or `MessageTimeline`, or `OpenGeniLinkProvider` for a
|
|
34
|
+
- Route editable artifacts and Sites to the product's own UI with
|
|
35
|
+
`resolveLink={(target) => ... ({ href } | { open } | null)}` on
|
|
36
|
+
`SessionConversation` or `MessageTimeline`, or `OpenGeniLinkProvider` for a
|
|
50
37
|
subtree; it also covers `Markdown` inside a custom `renderMessageText`.
|
|
51
38
|
Unresolved targets render as unavailable text, not broken links.
|
|
52
39
|
- `MessageTimeline` alone has no defaults; add
|
|
@@ -1,34 +1,15 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
|
|
3
3
|
type Observer = (providerId: string, response: Response) => void;
|
|
4
|
-
|
|
5
|
-
const observers = new AsyncLocalStorage<{
|
|
6
|
-
observe: Observer;
|
|
7
|
-
prepare?: Prepare;
|
|
8
|
-
}>();
|
|
4
|
+
const observers = new AsyncLocalStorage<Observer>();
|
|
9
5
|
|
|
10
6
|
/** Like Codex usage headers: free observations within this turn's provider context. */
|
|
11
|
-
export function withClaudeUsageObserver<T>(
|
|
12
|
-
observer
|
|
13
|
-
run: () => Promise<T>,
|
|
14
|
-
prepare?: Prepare,
|
|
15
|
-
): Promise<T> {
|
|
16
|
-
return observers.run({ observe: observer, ...(prepare ? { prepare } : {}) }, run);
|
|
17
|
-
}
|
|
18
|
-
export async function prepareClaudeSubscriptionRequest(
|
|
19
|
-
providerId: string,
|
|
20
|
-
input: Parameters<typeof fetch>[0],
|
|
21
|
-
init?: RequestInit,
|
|
22
|
-
) {
|
|
23
|
-
const prepare = observers.getStore()?.prepare;
|
|
24
|
-
if (!prepare) return init;
|
|
25
|
-
const headers = new Headers(input instanceof Request ? input.headers : undefined);
|
|
26
|
-
new Headers(init?.headers).forEach((value, key) => headers.set(key, value));
|
|
27
|
-
return { ...init, headers: await prepare(providerId, headers) };
|
|
7
|
+
export function withClaudeUsageObserver<T>(observer: Observer, run: () => Promise<T>): Promise<T> {
|
|
8
|
+
return observers.run(observer, run);
|
|
28
9
|
}
|
|
29
10
|
export function observeClaudeUsageResponse(providerId: string, response: Response): void {
|
|
30
11
|
try {
|
|
31
|
-
observers.getStore()?.
|
|
12
|
+
observers.getStore()?.(providerId, response);
|
|
32
13
|
} catch {
|
|
33
14
|
// Usage telemetry must never change or consume a model response.
|
|
34
15
|
}
|
package/src/index.ts
CHANGED
|
@@ -281,7 +281,6 @@ import {
|
|
|
281
281
|
createSandboxClient,
|
|
282
282
|
isModalTaskExecStartPreDispatchUnavailableError,
|
|
283
283
|
isRoutingMutationOutcomeUnknownError,
|
|
284
|
-
renderRoutingMutationOutcomeUnknownToolResult,
|
|
285
284
|
repairSerializedRunStateExposedPorts,
|
|
286
285
|
restoredSandboxSessionStateFromEntry,
|
|
287
286
|
setOpenSandboxApplyDiff,
|
|
@@ -370,13 +369,10 @@ import {
|
|
|
370
369
|
ModelRequestCaptureProvider,
|
|
371
370
|
notifyModelRequestCapture,
|
|
372
371
|
withModelRequestCapture,
|
|
373
|
-
withModelCallLifecycle,
|
|
374
|
-
type ModelCallLifecycle,
|
|
375
372
|
type ModelRequestCapture,
|
|
376
373
|
nextModelContextCaptureIndex,
|
|
377
374
|
} from "./model-request-capture";
|
|
378
375
|
import { decodeValidatedViewImageDataUrl } from "./view-image-validation";
|
|
379
|
-
export { beforeModelRequest as awaitModelCallAdmission } from "./model-request-capture";
|
|
380
376
|
import {
|
|
381
377
|
baseModelInputFilterForSettings,
|
|
382
378
|
boundModelToolOutputsFilterForSettings,
|
|
@@ -462,7 +458,6 @@ export {
|
|
|
462
458
|
MultiProviderModelProvider,
|
|
463
459
|
OpenGeniChatCompletionsModel,
|
|
464
460
|
OpenGeniResponsesModel,
|
|
465
|
-
ResponsesStreamingTerminalError,
|
|
466
461
|
UNKNOWN_MODEL_FINISH_REASON_CODE,
|
|
467
462
|
UnknownModelFinishReasonError,
|
|
468
463
|
WorkspaceGatewayUnavailableError,
|
|
@@ -2327,7 +2322,6 @@ export function coreInstructions(
|
|
|
2327
2322
|
): string[] {
|
|
2328
2323
|
return [
|
|
2329
2324
|
"If the session has a goal, you own it: keep working until you call opengeni__goal_complete with concrete evidence or opengeni__goal_pause with a rationale; revise it with opengeni__goal_update; create one with opengeni__goal_set when given a long-running objective. Resume a paused goal with opengeni__goal_resume when the user asks you to continue, regardless of who paused it, or when the blocker you paused for has cleared. A question alone is not such a request: answer it and leave the goal paused.",
|
|
2330
|
-
"Goal completion records short ledger proof, not the user-facing deliverable. After goal_complete succeeds, finish the same turn with the requested answer, or a concise summary and retained artifact link. Never use evidence as the final reply. A later child result after completion is context to integrate, not a reason to stay silent or restart the completed goal.",
|
|
2331
2325
|
'Choose durable storage by purpose, including requests to "remember this" or keep something "for future sessions". Knowledge is retrieval-only information, not standing behavior. Use instruction_policy_get then instruction_policy_save for short always-on workspace rules, such as "Keep replies concise; expand when asked." Use Skills for reusable procedures and context-specific or personal behavioral preferences; make the Skill description state when it applies so the prompt index can guide skill_read. Do not save behavioral preferences as Knowledge by rephrasing them as facts like "the user prefers concise replies". Preserve the intended scope: do not turn a personal preference into a workspace-wide rule; use an authorized personal Skill when appropriate, or explain the unavailable scope. Split mixed requests into a short rule and detailed Skill steps without duplicating them in Knowledge.',
|
|
2332
2326
|
"Before changing workspace instructions, read the current instruction and exact baseline, preserve unrelated rules, append new rules, and use only a localized exact anchored edit for updates or removals. Agents cannot replace the complete instruction; whole-policy rewrites belong in the manual workspace editor. Do not bypass a destination's Agent learning setting, review, scope, limits, or unavailable tools by saving to another destination. Report the actual destination and receipt: active, pending review, or not saved. Do not promise future behavior from a Knowledge save.",
|
|
2333
2327
|
"Use knowledge_search and knowledge_get when retained information is relevant. For questions about what the workspace knows, ground the answer in authorized Knowledge and attached sources. Missing internal facts remain unknown; do not infer a person's role or cite unrelated public search results as evidence. Keep any relevant external research clearly separate from workspace records. Default retrieval returns published information. Before retaining or correcting anything, also search view=needs_review for existing pending entries and collections; read those with knowledge_get view=needs_review. Pending means unapproved: you may inspect and improve it, but do not present it as accepted knowledge or activate behavioral guidance from it. Reuse the existing entryId and current version instead of creating another proposal each run. Save durable facts, decisions, requirements, incidents, fixes and outcomes autonomously with knowledge_save only when they help a plausible future task. Do not retain routine approvals, acknowledgments, temporary task instructions, status chatter or raw screenshots merely because they occurred. Before saving, use knowledge_prepare_save when available to fetch the authorized collection map with descriptions and parent IDs plus related published and pending entries; otherwise search both views and browse collections. Skip unchanged duplicates, improve the existing entry when appropriate, and create a new entry only for distinct useful information. Read the current entry before correcting it and preserve uncertainty, conflicting evidence and existing relationships. When a user supplies or confirms a durable fact, use knowledge_retain_message to retain the actual message and cite its returned entryId/revisionId in the finding evidence. Preserve existing source evidence and relationships when correcting an entry; do not replace them with empty arrays merely because the user confirmed a new value. Explicit confirmation can supersede a conflicting pending proposal, but explain that outcome to the user. Preserve uncertainty and exact supporting evidence; the fact label is not a verification claim. Chat attachments retain their original files for the conversation without automatically publishing OCR or source text into Knowledge. Inspect an image visually in the current task; save only a useful supported observation, requirement or incident when warranted. Use knowledge_retain_file purpose=evidence only when a selected finding needs the original as supporting evidence, or purpose=reference when deliberately retaining a reusable source document. Supporting sources remain accessible through evidence links and explicit includeEvidence searches, but do not fill ordinary Knowledge discovery. An upload alone is not a reason to save Knowledge. A source entry contains retained original text; a finding states a useful conclusion and cites the exact source revision. Do not create both when they would simply repeat the same text. Reuse collections for customers, products, systems or subjects across sources, and link one entry to multiple collections instead of copying it. Technical incidents belong with the affected system and should include cause, fix and outcome when known. Reorganize references when useful; do not erase source evidence or revision history. Private tasks author personal Knowledge; shared tasks author workspace Knowledge. Automatic publishes immediately, Review first keeps a pending proposal without pausing your task, and Off prevents authoring while permitting retrieval. Never bypass review by making a new entry, switching tools, or asking for another approval. Reuse the same operationId and exact request after an uncertain save, including recovery. Use task_note_save for temporary coordination in this task tree. Conversation history is separate. Workspace instructions are concise standing rules; Skills are reusable procedures with their own Agent learning settings. Do not save the same content in multiple authorities.",
|
|
@@ -3879,12 +3873,6 @@ function buildAgentCapabilitiesFromComposition(
|
|
|
3879
3873
|
// readiness proof, which reaches bounded same-turn recovery.
|
|
3880
3874
|
execCommandErrorFunction: (_context, error) => {
|
|
3881
3875
|
if (isModalTaskExecStartPreDispatchUnavailableError(error)) throw error;
|
|
3882
|
-
if (isRoutingMutationOutcomeUnknownError(error)) {
|
|
3883
|
-
// The outer physical fence must retain the exact process before
|
|
3884
|
-
// rendering uncertainty. Platform/setup calls still throw normally.
|
|
3885
|
-
if (toolCancellation) throw error;
|
|
3886
|
-
return renderRoutingMutationOutcomeUnknownToolResult(error);
|
|
3887
|
-
}
|
|
3888
3876
|
const details = error instanceof Error ? error.toString() : String(error);
|
|
3889
3877
|
return `An error occurred while running the tool. Please try again. Error: ${details}`;
|
|
3890
3878
|
},
|
|
@@ -4390,7 +4378,6 @@ export async function prepareAgentTools(
|
|
|
4390
4378
|
settings.mcpServers.filter(
|
|
4391
4379
|
(config) =>
|
|
4392
4380
|
tools.some((tool) => tool.id === config.id) &&
|
|
4393
|
-
!config.connectionRef &&
|
|
4394
4381
|
!localRegistry.has(config.id) &&
|
|
4395
4382
|
!isFirstPartyMcpServer(settings, config) &&
|
|
4396
4383
|
!isCodexAppsMcpServer(config),
|
|
@@ -5014,7 +5001,6 @@ export function selectedSessionRemoteMcpTargets(
|
|
|
5014
5001
|
if (configs.length !== 1) return [];
|
|
5015
5002
|
const config = configs[0]!;
|
|
5016
5003
|
if (
|
|
5017
|
-
config.connectionRef ||
|
|
5018
5004
|
isFirstPartyMcpServer(settings, config) ||
|
|
5019
5005
|
isCodexAppsMcpServer(config) ||
|
|
5020
5006
|
BUILT_IN_MCP_BRIDGE_ADAPTERS.some((adapter) =>
|
|
@@ -8064,10 +8050,6 @@ export async function prepareRunInput(
|
|
|
8064
8050
|
}
|
|
8065
8051
|
|
|
8066
8052
|
export type RunAgentStreamOptions = {
|
|
8067
|
-
/** Producer-side gate before calling any resolved model/provider. */
|
|
8068
|
-
beforeModelRequest?: ModelCallLifecycle["beforeModelRequest"];
|
|
8069
|
-
/** Register terminal response settlement before the next producer model request. */
|
|
8070
|
-
onModelResponse?: ModelCallLifecycle["onModelResponse"];
|
|
8071
8053
|
/** Abort the provider/tool loop when the owning activity is cancelled. */
|
|
8072
8054
|
signal?: AbortSignal;
|
|
8073
8055
|
/** Nonblocking phase measurements for request preparation before provider I/O. */
|
|
@@ -8311,17 +8293,8 @@ export async function runAgentStream(
|
|
|
8311
8293
|
const scope = gate?.beginStream(overrides.signal);
|
|
8312
8294
|
try {
|
|
8313
8295
|
if (scope) agent.toolUseBehavior = scope.toolUseBehavior;
|
|
8314
|
-
const stream = await
|
|
8315
|
-
|
|
8316
|
-
...(overrides.beforeModelRequest
|
|
8317
|
-
? { beforeModelRequest: overrides.beforeModelRequest }
|
|
8318
|
-
: {}),
|
|
8319
|
-
...(overrides.onModelResponse ? { onModelResponse: overrides.onModelResponse } : {}),
|
|
8320
|
-
},
|
|
8321
|
-
() =>
|
|
8322
|
-
withPreparedCompactionRequest(agent, () =>
|
|
8323
|
-
runAgentStreamInternal(agent, input, settings, overrides, scope),
|
|
8324
|
-
),
|
|
8296
|
+
const stream = await withPreparedCompactionRequest(agent, () =>
|
|
8297
|
+
runAgentStreamInternal(agent, input, settings, overrides, scope),
|
|
8325
8298
|
);
|
|
8326
8299
|
// Observe the SDK's own settlement promise before exposing the stream. Do
|
|
8327
8300
|
// not wrap/replace SDK history, errors, cancellation, or stream iteration.
|
package/src/input-wait-yield.ts
CHANGED
|
@@ -127,13 +127,6 @@ export class InputWaitYield {
|
|
|
127
127
|
await this.drain(this.scope, signal);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
/** A settled stream may need one final-reply handoff before attempt closure.
|
|
131
|
-
* Drain already-admitted receipts without reopening that stream's admission.
|
|
132
|
-
*/
|
|
133
|
-
async drainForHandoff(signal = this.scope.signal): Promise<void> {
|
|
134
|
-
await this.drain(this.scope, signal);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
130
|
private endStream(scope: StreamScope): void {
|
|
138
131
|
scope.phase = "settled";
|
|
139
132
|
scope.ended = true;
|
package/src/interaction-tools.ts
CHANGED
|
@@ -681,7 +681,6 @@ export function createInteractionAttemptToolDefinitions(
|
|
|
681
681
|
raw,
|
|
682
682
|
context,
|
|
683
683
|
options.execute,
|
|
684
|
-
options.readOnly,
|
|
685
684
|
),
|
|
686
685
|
});
|
|
687
686
|
};
|
|
@@ -1916,7 +1915,6 @@ async function safeInteractionExecution<TInput extends z.ZodType, TOutput extend
|
|
|
1916
1915
|
value: z.output<TInput>,
|
|
1917
1916
|
context: AttemptToolExecutionContext,
|
|
1918
1917
|
) => Promise<z.input<TOutput> | InteractionExecutionResult<z.input<TOutput>>>,
|
|
1919
|
-
readOnly: boolean,
|
|
1920
1918
|
): Promise<AttemptToolResultValue> {
|
|
1921
1919
|
try {
|
|
1922
1920
|
const value = inputSchema.parse(raw);
|
|
@@ -1938,18 +1936,11 @@ async function safeInteractionExecution<TInput extends z.ZodType, TOutput extend
|
|
|
1938
1936
|
if (error instanceof z.ZodError) {
|
|
1939
1937
|
return interactionErrorResult("invalid_arguments", "Interaction tool arguments are invalid.");
|
|
1940
1938
|
}
|
|
1941
|
-
|
|
1942
|
-
// explanation; mutations and uncertain outcomes retain their failure path.
|
|
1943
|
-
if (
|
|
1944
|
-
error instanceof OpenGeniApiError &&
|
|
1945
|
-
!error.outcomeUnknown &&
|
|
1946
|
-
(error.status < 500 || readOnly)
|
|
1947
|
-
) {
|
|
1939
|
+
if (error instanceof OpenGeniApiError && !error.outcomeUnknown && error.status < 500) {
|
|
1948
1940
|
return interactionErrorResult(
|
|
1949
1941
|
error.code ?? `http_${error.status}`,
|
|
1950
1942
|
boundedErrorMessage(error.message),
|
|
1951
1943
|
error.retryable,
|
|
1952
|
-
error.correlationId,
|
|
1953
1944
|
);
|
|
1954
1945
|
}
|
|
1955
1946
|
throw error;
|
|
@@ -1974,9 +1965,8 @@ function interactionErrorResult(
|
|
|
1974
1965
|
code: string,
|
|
1975
1966
|
message: string,
|
|
1976
1967
|
retryable = false,
|
|
1977
|
-
requestId?: string,
|
|
1978
1968
|
): AttemptToolResultValue {
|
|
1979
|
-
const error = { code, message, retryable
|
|
1969
|
+
const error = { code, message, retryable };
|
|
1980
1970
|
return {
|
|
1981
1971
|
isError: true,
|
|
1982
1972
|
content: [{ type: "text" as const, text: JSON.stringify({ error }) }],
|