@opengeni/sdk 0.23.0 → 0.25.5
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 +52 -0
- package/dist/index.d.ts +206 -14
- package/dist/index.js +286 -75
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +302 -81
- package/src/errors.ts +89 -12
- package/src/index.ts +18 -0
- package/src/types.ts +236 -6
package/src/errors.ts
CHANGED
|
@@ -1,16 +1,101 @@
|
|
|
1
1
|
/** Error for a non-2xx OpenGeni API response. */
|
|
2
2
|
export class OpenGeniApiError extends Error {
|
|
3
3
|
readonly status: number;
|
|
4
|
+
readonly code: string | undefined;
|
|
5
|
+
readonly retryable: boolean;
|
|
6
|
+
readonly correlationId: string | undefined;
|
|
7
|
+
/** True only when an uncontrolled transport failed after a mutation may have been accepted. */
|
|
8
|
+
readonly outcomeUnknown: boolean;
|
|
4
9
|
readonly body: string;
|
|
5
10
|
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
11
|
+
constructor(
|
|
12
|
+
status: number,
|
|
13
|
+
body: string,
|
|
14
|
+
options: {
|
|
15
|
+
code?: string | undefined;
|
|
16
|
+
retryable?: boolean | undefined;
|
|
17
|
+
correlationId?: string | undefined;
|
|
18
|
+
outcomeUnknown?: boolean | undefined;
|
|
19
|
+
displayMessage?: string | undefined;
|
|
20
|
+
mutation?: boolean | undefined;
|
|
21
|
+
} = {},
|
|
22
|
+
) {
|
|
23
|
+
const decoded = decodeApiErrorBody(body);
|
|
24
|
+
const correlationId = decoded?.requestId ?? boundedCorrelationId(options.correlationId);
|
|
25
|
+
const gatewayFailure = status >= 502 && status <= 504;
|
|
26
|
+
const fromResponse = options.mutation !== undefined;
|
|
27
|
+
const message = decoded?.message ?? (fromResponse ? "Request failed." : body || "(empty body)");
|
|
28
|
+
const displayMessage =
|
|
29
|
+
options.displayMessage ??
|
|
30
|
+
(gatewayFailure && fromResponse
|
|
31
|
+
? "OpenGeni is temporarily unavailable — retry."
|
|
32
|
+
: `OpenGeni API ${status}: ${message}`);
|
|
33
|
+
super(correlationId ? `${displayMessage} Reference: ${correlationId}.` : displayMessage);
|
|
8
34
|
this.name = "OpenGeniApiError";
|
|
9
35
|
this.status = status;
|
|
10
|
-
this.
|
|
36
|
+
this.code =
|
|
37
|
+
options.code ??
|
|
38
|
+
decoded?.code ??
|
|
39
|
+
(gatewayFailure && fromResponse ? "upstream_unavailable" : undefined);
|
|
40
|
+
this.retryable = options.retryable ?? decoded?.retryable ?? retryableApiStatus(status);
|
|
41
|
+
this.correlationId = correlationId;
|
|
42
|
+
this.outcomeUnknown =
|
|
43
|
+
options.outcomeUnknown ?? (gatewayFailure && !!options.mutation && !decoded);
|
|
44
|
+
this.body = !fromResponse || decoded ? body : "";
|
|
11
45
|
}
|
|
12
46
|
}
|
|
13
47
|
|
|
48
|
+
function decodeApiErrorBody(body: string): {
|
|
49
|
+
code: string | undefined;
|
|
50
|
+
message: string | undefined;
|
|
51
|
+
requestId: string | undefined;
|
|
52
|
+
retryable: boolean | undefined;
|
|
53
|
+
} | null {
|
|
54
|
+
if (!body) return null;
|
|
55
|
+
try {
|
|
56
|
+
const decoded: unknown = JSON.parse(body);
|
|
57
|
+
if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) return null;
|
|
58
|
+
const record = decoded as Record<string, unknown>;
|
|
59
|
+
const nested =
|
|
60
|
+
record.error && typeof record.error === "object" && !Array.isArray(record.error)
|
|
61
|
+
? (record.error as Record<string, unknown>)
|
|
62
|
+
: record;
|
|
63
|
+
const code = boundedApiField(nested.code);
|
|
64
|
+
const message = boundedApiField(nested.message);
|
|
65
|
+
const requestId = boundedCorrelationId(nested.requestId);
|
|
66
|
+
const retryable = typeof nested.retryable === "boolean" ? nested.retryable : undefined;
|
|
67
|
+
if (!code && !message && !requestId && retryable === undefined) return null;
|
|
68
|
+
return {
|
|
69
|
+
code,
|
|
70
|
+
message,
|
|
71
|
+
requestId,
|
|
72
|
+
retryable,
|
|
73
|
+
};
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function boundedApiField(value: unknown): string | undefined {
|
|
80
|
+
if (typeof value !== "string") return;
|
|
81
|
+
const bytes = new TextEncoder().encode(value);
|
|
82
|
+
return bytes.byteLength <= 512 ? value : new TextDecoder().decode(bytes.slice(0, 512));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function retryableApiStatus(status: number): boolean {
|
|
86
|
+
return status === 408 || status === 409 || status === 425 || status === 429 || status >= 500;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function boundedCorrelationId(value: unknown): string | undefined {
|
|
90
|
+
if (typeof value !== "string" || value.length > 128 || !/^[\w.:-]+$/.test(value)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** A short-lived session-list snapshot cursor can no longer be continued. */
|
|
97
|
+
export class OpenGeniSessionListCursorError extends OpenGeniApiError {}
|
|
98
|
+
|
|
14
99
|
/** The browser bundle and API disagree about their state-changing wire contract. */
|
|
15
100
|
export class OpenGeniApiContractMismatchError extends Error {
|
|
16
101
|
readonly expected: string;
|
|
@@ -46,14 +131,6 @@ export function isAbortError(error: unknown): boolean {
|
|
|
46
131
|
* permanent and surface to the caller instead.
|
|
47
132
|
*/
|
|
48
133
|
export function isRetryableStreamError(error: unknown): boolean {
|
|
49
|
-
if (error instanceof OpenGeniApiError)
|
|
50
|
-
return (
|
|
51
|
-
error.status === 408 ||
|
|
52
|
-
error.status === 409 ||
|
|
53
|
-
error.status === 425 ||
|
|
54
|
-
error.status === 429 ||
|
|
55
|
-
error.status >= 500
|
|
56
|
-
);
|
|
57
|
-
}
|
|
134
|
+
if (error instanceof OpenGeniApiError) return error.retryable;
|
|
58
135
|
return error instanceof TypeError;
|
|
59
136
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type {
|
|
|
10
10
|
export {
|
|
11
11
|
OpenGeniApiContractMismatchError,
|
|
12
12
|
OpenGeniApiError,
|
|
13
|
+
OpenGeniSessionListCursorError,
|
|
13
14
|
OpenGeniStreamError,
|
|
14
15
|
isRetryableStreamError,
|
|
15
16
|
} from "./errors";
|
|
@@ -85,6 +86,7 @@ export {
|
|
|
85
86
|
KNOWN_USAGE_EVENT_TYPES,
|
|
86
87
|
OPENGENI_API_CONTRACT_HEADER,
|
|
87
88
|
OPENGENI_API_CONTRACT_REVISION,
|
|
89
|
+
OPENGENI_CORRELATION_HEADER,
|
|
88
90
|
RETAINED_OUTPUT_DEFAULT_PAGE_BYTES,
|
|
89
91
|
RETAINED_OUTPUT_MAX_PAGE_BYTES,
|
|
90
92
|
SESSION_EVENT_TYPES,
|
|
@@ -142,6 +144,11 @@ export type {
|
|
|
142
144
|
CodexConnectionStatus,
|
|
143
145
|
CodexConnectStart,
|
|
144
146
|
CodexConnectPoll,
|
|
147
|
+
CodexFleetConfidence,
|
|
148
|
+
CodexFleetCacheState,
|
|
149
|
+
CodexFleetDecisionEventPayload,
|
|
150
|
+
CodexFleetDecisionScore,
|
|
151
|
+
CodexFleetShadowComparison,
|
|
145
152
|
CodexOverviewResponse,
|
|
146
153
|
CodexResetCredit,
|
|
147
154
|
CodexResetRedemptionRecovery,
|
|
@@ -169,6 +176,7 @@ export type {
|
|
|
169
176
|
CreateFileUploadResponse,
|
|
170
177
|
CreateGitHubAppManifestRequest,
|
|
171
178
|
CreateGitHubAppManifestResponse,
|
|
179
|
+
CreateKnowledgeDropRequest,
|
|
172
180
|
CreateKnowledgeMemoryRequest,
|
|
173
181
|
CreateScheduledTaskRequest,
|
|
174
182
|
CreateSessionRequest,
|
|
@@ -178,11 +186,15 @@ export type {
|
|
|
178
186
|
DiscoverMcpCapabilitiesResponse,
|
|
179
187
|
Document,
|
|
180
188
|
DocumentBase,
|
|
189
|
+
DocumentCuration,
|
|
190
|
+
DocumentCurationStatus,
|
|
181
191
|
DocumentSearchMode,
|
|
182
192
|
DocumentSearchRequest,
|
|
183
193
|
DocumentSearchResponse,
|
|
184
194
|
DocumentSearchResult,
|
|
185
195
|
DocumentStatus,
|
|
196
|
+
DocumentVisibility,
|
|
197
|
+
MoveDocumentRequest,
|
|
186
198
|
EnableCapabilityRequest,
|
|
187
199
|
EnablePackRequest,
|
|
188
200
|
Entitlements,
|
|
@@ -200,7 +212,9 @@ export type {
|
|
|
200
212
|
FileUploadData,
|
|
201
213
|
GetPackResponse,
|
|
202
214
|
GitHubAppInfo,
|
|
215
|
+
GitHubBindingStatus,
|
|
203
216
|
GitHubInstallationBinding,
|
|
217
|
+
GitHubInstallationLifecycle,
|
|
204
218
|
GitHubRepositoriesResponse,
|
|
205
219
|
GitHubRepository,
|
|
206
220
|
GitHubRepositoryScope,
|
|
@@ -276,7 +290,10 @@ export type {
|
|
|
276
290
|
EffectiveControlResumeOption,
|
|
277
291
|
EffectiveSessionControl,
|
|
278
292
|
MoveSessionQueueItemRequest,
|
|
293
|
+
NewSessionDraft,
|
|
294
|
+
NewSessionDraftOptions,
|
|
279
295
|
SaveComposerDraftRequest,
|
|
296
|
+
SaveNewSessionDraftRequest,
|
|
280
297
|
SessionCommandReceipt,
|
|
281
298
|
SteerSessionQueueItemRequest,
|
|
282
299
|
WorkspaceInferenceControlResponse,
|
|
@@ -402,6 +419,7 @@ export type {
|
|
|
402
419
|
UpdateSessionMcpApprovalPolicyResponse,
|
|
403
420
|
UpdateSessionPinRequest,
|
|
404
421
|
UpdateSessionRequest,
|
|
422
|
+
UpdateSessionToolPolicyRequest,
|
|
405
423
|
UpdateVariableSetRequest,
|
|
406
424
|
UpdateWorkspaceEnvironmentRequest,
|
|
407
425
|
UpdateWorkspaceMemberRequest,
|
package/src/types.ts
CHANGED
|
@@ -65,6 +65,9 @@ export type SessionCapabilities = {
|
|
|
65
65
|
os: SandboxOs;
|
|
66
66
|
liveness: "cold" | "warming" | "warm" | "draining";
|
|
67
67
|
leaseEpoch: number;
|
|
68
|
+
workspaceGeneration: number | null;
|
|
69
|
+
archiveGeneration: number | null;
|
|
70
|
+
archiveComplete: boolean;
|
|
68
71
|
viewerHeartbeatIntervalMs: number;
|
|
69
72
|
FileSystem: {
|
|
70
73
|
available: boolean;
|
|
@@ -182,6 +185,9 @@ export type ViewerHolder = {
|
|
|
182
185
|
sandboxGroupId: string;
|
|
183
186
|
liveness: "cold" | "warming" | "warm" | "draining";
|
|
184
187
|
leaseEpoch: number;
|
|
188
|
+
workspaceGeneration: number | null;
|
|
189
|
+
archiveGeneration: number | null;
|
|
190
|
+
archiveComplete: boolean;
|
|
185
191
|
viewerHeartbeatIntervalMs: number;
|
|
186
192
|
dataPlaneUrl: string | null;
|
|
187
193
|
};
|
|
@@ -270,6 +276,18 @@ export type SessionToolPolicy = {
|
|
|
270
276
|
inheritedFromSessionId: string | null;
|
|
271
277
|
};
|
|
272
278
|
|
|
279
|
+
export type UpdateSessionToolPolicyRequest =
|
|
280
|
+
| {
|
|
281
|
+
mode: "workspace_default";
|
|
282
|
+
expectedVersion: number;
|
|
283
|
+
}
|
|
284
|
+
| {
|
|
285
|
+
/** Omitted for compatibility with the original explicit-only API. */
|
|
286
|
+
mode?: "explicit" | undefined;
|
|
287
|
+
tools: ToolRef[];
|
|
288
|
+
expectedVersion: number;
|
|
289
|
+
};
|
|
290
|
+
|
|
273
291
|
export type SessionEffectiveToolPolicy = {
|
|
274
292
|
mode: SessionToolPolicy["mode"];
|
|
275
293
|
inheritedFromSessionId: string | null;
|
|
@@ -466,6 +484,7 @@ export type Session = {
|
|
|
466
484
|
resources: ResourceRef[];
|
|
467
485
|
tools: ToolRef[];
|
|
468
486
|
toolPolicy?: SessionToolPolicy | undefined;
|
|
487
|
+
toolPolicyVersion?: number | undefined;
|
|
469
488
|
effectiveToolPolicy?: SessionEffectiveToolPolicy | undefined;
|
|
470
489
|
metadata: Record<string, unknown>;
|
|
471
490
|
/** Frozen creator fact; later turns carry their own independent initiator. */
|
|
@@ -487,6 +506,13 @@ export type Session = {
|
|
|
487
506
|
firstPartyMcpPermissions: string[] | null;
|
|
488
507
|
mcpServers: SessionMcpServerMetadata[];
|
|
489
508
|
parentSessionId: string | null;
|
|
509
|
+
/** Immutable server-authored nested-agent lineage and policy snapshot. */
|
|
510
|
+
rootSessionId: string;
|
|
511
|
+
nestedAgentDepth: number;
|
|
512
|
+
maxNestedAgentDepthOverride: number | null;
|
|
513
|
+
effectiveMaxNestedAgentDepth: number;
|
|
514
|
+
nestedAgentDepthPolicySource: "session" | "workspace" | "deployment" | "default";
|
|
515
|
+
nestedAgentDepthPolicySessionId: string | null;
|
|
490
516
|
createIdempotencyKey: string | null;
|
|
491
517
|
temporalWorkflowId: string | null;
|
|
492
518
|
activeTurnId: string | null;
|
|
@@ -749,10 +775,13 @@ export const SESSION_EVENT_TYPES = [
|
|
|
749
775
|
"terminal.pty.exited",
|
|
750
776
|
"session.title_set",
|
|
751
777
|
"session.mcp.approval_policy.updated",
|
|
778
|
+
"session.tool_policy.updated",
|
|
752
779
|
// Multi-account Codex (P1): the session's inference account changed.
|
|
753
780
|
"codex.account.switched",
|
|
754
781
|
// credential allocator metadata-only per-turn credential selection audit.
|
|
755
782
|
"codex.credential.selected",
|
|
783
|
+
// Bounded, identity-free deterministic shadow/replay decision.
|
|
784
|
+
"codex.fleet.decision",
|
|
756
785
|
// credential allocator durable zero-capacity wait lifecycle. These are system/runtime
|
|
757
786
|
// events, never synthetic user messages.
|
|
758
787
|
"codex.capacity.waiting",
|
|
@@ -957,6 +986,89 @@ export type AgentToolCallCreatedPayload = {
|
|
|
957
986
|
export type AgentToolCallOutputPayload = { id: string | null; output: unknown };
|
|
958
987
|
export type SessionStatusChangedPayload = { status: SessionStatus };
|
|
959
988
|
|
|
989
|
+
// Adaptive-fleet shadow event. This is the typed, identity-free view
|
|
990
|
+
// consumed by UI/manager tooling; the durable replay record also contains the
|
|
991
|
+
// complete normalized policy/input needed for offline deterministic replay.
|
|
992
|
+
export type CodexFleetConfidence = "unknown" | "low" | "medium" | "high";
|
|
993
|
+
export type CodexFleetCacheState = "unknown" | "healthy" | "collapsed";
|
|
994
|
+
export type CodexFleetShadowComparison =
|
|
995
|
+
| "match"
|
|
996
|
+
| "different_candidate"
|
|
997
|
+
| "different_outcome"
|
|
998
|
+
| "not_comparable_truncated";
|
|
999
|
+
export type CodexFleetDecisionScore = {
|
|
1000
|
+
candidateKey: string;
|
|
1001
|
+
eligible: boolean;
|
|
1002
|
+
rejectionReason:
|
|
1003
|
+
| "allocator_disabled"
|
|
1004
|
+
| "unavailable"
|
|
1005
|
+
| "cooling"
|
|
1006
|
+
| "quota_ceiling"
|
|
1007
|
+
| "overlay_isolation"
|
|
1008
|
+
| null;
|
|
1009
|
+
quotaPressure: number;
|
|
1010
|
+
leasePressure: number;
|
|
1011
|
+
observedBurnPressure: number;
|
|
1012
|
+
inferredBurnPressure: number;
|
|
1013
|
+
runwayPressure: number;
|
|
1014
|
+
uncertaintyPressure: number;
|
|
1015
|
+
cacheAffinityBenefit: number;
|
|
1016
|
+
cacheState: CodexFleetCacheState;
|
|
1017
|
+
overlayPreferenceBenefit: number;
|
|
1018
|
+
total: number;
|
|
1019
|
+
confidence: CodexFleetConfidence;
|
|
1020
|
+
};
|
|
1021
|
+
export type CodexFleetDecisionEventPayload = {
|
|
1022
|
+
schemaVersion: 1;
|
|
1023
|
+
mode: "shadow";
|
|
1024
|
+
actual: {
|
|
1025
|
+
outcome: "selected" | "waiting" | "none";
|
|
1026
|
+
candidateKey: string | null;
|
|
1027
|
+
reason: "lease_reused" | "pin" | "rotation" | "active" | "all_capped" | "none";
|
|
1028
|
+
};
|
|
1029
|
+
comparison: CodexFleetShadowComparison;
|
|
1030
|
+
replay: {
|
|
1031
|
+
schemaVersion: 1;
|
|
1032
|
+
policyVersion: "adaptive-shadow-v1";
|
|
1033
|
+
mode: "shadow";
|
|
1034
|
+
input: { candidates: Array<{ key: string }> } & Record<string, unknown>;
|
|
1035
|
+
truncatedCandidateCount: number;
|
|
1036
|
+
inputFingerprint: string;
|
|
1037
|
+
decisionFingerprint: string;
|
|
1038
|
+
decision: {
|
|
1039
|
+
outcome: "selected" | "paced" | "none";
|
|
1040
|
+
selectedCandidateKey: string | null;
|
|
1041
|
+
reason:
|
|
1042
|
+
| "fenced_in_flight"
|
|
1043
|
+
| "fenced_candidate_missing"
|
|
1044
|
+
| "admission_paced"
|
|
1045
|
+
| "no_eligible_candidate"
|
|
1046
|
+
| "overlay_isolated_empty"
|
|
1047
|
+
| "best_score"
|
|
1048
|
+
| "affinity_best"
|
|
1049
|
+
| "hysteresis_hold";
|
|
1050
|
+
admission: {
|
|
1051
|
+
outcome: "admit" | "pace";
|
|
1052
|
+
reason:
|
|
1053
|
+
| "fenced_in_flight"
|
|
1054
|
+
| "pacing_disabled"
|
|
1055
|
+
| "capacity_unknown"
|
|
1056
|
+
| "capacity_available"
|
|
1057
|
+
| "work_conserving_borrow"
|
|
1058
|
+
| "manager_priority"
|
|
1059
|
+
| "standard_starvation_bound"
|
|
1060
|
+
| "capacity_saturated"
|
|
1061
|
+
| "emergency_fuse";
|
|
1062
|
+
borrowedIdleCapacity: boolean;
|
|
1063
|
+
};
|
|
1064
|
+
borrowedOverlayCapacity: boolean;
|
|
1065
|
+
strandedEligibleCount: number;
|
|
1066
|
+
confidence: CodexFleetConfidence;
|
|
1067
|
+
scores: CodexFleetDecisionScore[];
|
|
1068
|
+
};
|
|
1069
|
+
} & Record<string, unknown>;
|
|
1070
|
+
};
|
|
1071
|
+
|
|
960
1072
|
// Recording payloads (P4.3 — plain TS mirror of the contracts Zod schemas; the
|
|
961
1073
|
// SDK is zero-runtime-dep so these are TYPES, not Zod, F15). The contract-parity
|
|
962
1074
|
// test asserts the event-type literals; these shapes document the wire payloads.
|
|
@@ -1046,7 +1158,7 @@ export type TerminalPtyOutputDeltaPayload = {
|
|
|
1046
1158
|
export type TerminalPtyExitedPayload = {
|
|
1047
1159
|
ptyId: string;
|
|
1048
1160
|
exitCode: number | null;
|
|
1049
|
-
reason: "exit" | "killed" | "owner_gone" | "timeout";
|
|
1161
|
+
reason: "exit" | "killed" | "owner_gone" | "timeout" | "lost";
|
|
1050
1162
|
};
|
|
1051
1163
|
|
|
1052
1164
|
// A2 FileSystem request/response.
|
|
@@ -1333,8 +1445,8 @@ export type TerminalExecRequest = {
|
|
|
1333
1445
|
export type TerminalExecResponse = {
|
|
1334
1446
|
stdout: string;
|
|
1335
1447
|
stderr: string;
|
|
1336
|
-
exitCode: number
|
|
1337
|
-
running:
|
|
1448
|
+
exitCode: number;
|
|
1449
|
+
running: false;
|
|
1338
1450
|
wallTimeSeconds: number;
|
|
1339
1451
|
};
|
|
1340
1452
|
export type PtyOpenRequest = {
|
|
@@ -1398,6 +1510,7 @@ export type ScheduledTaskAgentConfig = {
|
|
|
1398
1510
|
reasoningEffort?: ReasoningEffort | undefined;
|
|
1399
1511
|
sandboxBackend?: SandboxBackend | undefined;
|
|
1400
1512
|
goal?: GoalSpec | undefined;
|
|
1513
|
+
maxNestedAgentDepth?: number | undefined;
|
|
1401
1514
|
};
|
|
1402
1515
|
|
|
1403
1516
|
export type ScheduledTask = {
|
|
@@ -1459,6 +1572,10 @@ export type CreateSessionRequest = {
|
|
|
1459
1572
|
// double-submit/retry of the same logical create collapse to one session.
|
|
1460
1573
|
// Distinct from the per-call clientEventId.
|
|
1461
1574
|
idempotencyKey?: string | undefined;
|
|
1575
|
+
// Exact actor-private pre-session draft revision represented by this create.
|
|
1576
|
+
// The server consumes only this revision after durable initialization.
|
|
1577
|
+
expectedNewSessionDraftRevision?: number | undefined;
|
|
1578
|
+
maxNestedAgentDepth?: number | undefined;
|
|
1462
1579
|
firstPartyMcpPermissions?: string[] | undefined;
|
|
1463
1580
|
mcpServers?: SessionMcpServerInput[] | undefined;
|
|
1464
1581
|
// Shared-sandbox placement (mirror of `@opengeni/contracts` CreateSessionRequest.sandbox,
|
|
@@ -1890,6 +2007,8 @@ export type ClientAuthConfig =
|
|
|
1890
2007
|
// parity suite. The SDK has no runtime dependency on the Zod contracts package.
|
|
1891
2008
|
export const OPENGENI_API_CONTRACT_REVISION = "2026-07-turn-instructions-v1" as const;
|
|
1892
2009
|
export const OPENGENI_API_CONTRACT_HEADER = "x-opengeni-api-contract" as const;
|
|
2010
|
+
/** Bounded request/response identifier shared by browser, ingress, and API diagnostics. */
|
|
2011
|
+
export const OPENGENI_CORRELATION_HEADER = "x-opengeni-correlation-id" as const;
|
|
1893
2012
|
|
|
1894
2013
|
/**
|
|
1895
2014
|
* Public, unauthenticated-by-default client bootstrap config returned by
|
|
@@ -1978,12 +2097,14 @@ export type Workspace = {
|
|
|
1978
2097
|
export type WorkspaceSettings = {
|
|
1979
2098
|
memoryEnabled?: boolean | undefined;
|
|
1980
2099
|
transcription?: WorkspaceTranscriptionPolicy | undefined;
|
|
2100
|
+
maxNestedAgentDepth?: number | null | undefined;
|
|
1981
2101
|
[key: string]: unknown;
|
|
1982
2102
|
};
|
|
1983
2103
|
|
|
1984
2104
|
export type UpdateWorkspaceSettingsRequest = {
|
|
1985
2105
|
memoryEnabled?: boolean | undefined;
|
|
1986
2106
|
transcription?: WorkspaceTranscriptionPolicy | undefined;
|
|
2107
|
+
maxNestedAgentDepth?: number | null | undefined;
|
|
1987
2108
|
[key: string]: unknown;
|
|
1988
2109
|
};
|
|
1989
2110
|
|
|
@@ -2068,6 +2189,36 @@ export type SessionGoalStatus = "active" | "paused" | "completed";
|
|
|
2068
2189
|
|
|
2069
2190
|
export type SessionGoalCreatedBy = "api" | "agent" | "scheduled_task";
|
|
2070
2191
|
|
|
2192
|
+
export type SessionGoalContinuationState =
|
|
2193
|
+
| "inactive"
|
|
2194
|
+
| "scheduled"
|
|
2195
|
+
| "running"
|
|
2196
|
+
| "blocked"
|
|
2197
|
+
| "invariant_broken";
|
|
2198
|
+
|
|
2199
|
+
export type SessionGoalContinuationReason =
|
|
2200
|
+
| "goal_inactive"
|
|
2201
|
+
| "wake_pending"
|
|
2202
|
+
| "continuation_pending"
|
|
2203
|
+
| "human_work_pending"
|
|
2204
|
+
| "goal_turn_running"
|
|
2205
|
+
| "human_turn_running"
|
|
2206
|
+
| "workstream_paused"
|
|
2207
|
+
| "approval_required"
|
|
2208
|
+
| "provider_backpressure"
|
|
2209
|
+
| "session_cancelled"
|
|
2210
|
+
| "system_work_pending"
|
|
2211
|
+
| "missing_obligation";
|
|
2212
|
+
|
|
2213
|
+
export type SessionGoalContinuation = {
|
|
2214
|
+
state: SessionGoalContinuationState;
|
|
2215
|
+
reason: SessionGoalContinuationReason;
|
|
2216
|
+
wakeRevision: number;
|
|
2217
|
+
observedRevision: number;
|
|
2218
|
+
nextAttemptAt: string | null;
|
|
2219
|
+
lastError: string | null;
|
|
2220
|
+
};
|
|
2221
|
+
|
|
2071
2222
|
export type SessionGoal = {
|
|
2072
2223
|
id: string;
|
|
2073
2224
|
accountId: string;
|
|
@@ -2085,6 +2236,8 @@ export type SessionGoal = {
|
|
|
2085
2236
|
noProgressStreak: number;
|
|
2086
2237
|
maxAutoContinuations: number | null;
|
|
2087
2238
|
metadata: Record<string, unknown>;
|
|
2239
|
+
/** Optional for source compatibility; the API always supplies this projection. */
|
|
2240
|
+
continuation?: SessionGoalContinuation | undefined;
|
|
2088
2241
|
createdAt: string;
|
|
2089
2242
|
updatedAt: string;
|
|
2090
2243
|
};
|
|
@@ -2172,6 +2325,29 @@ export type ComposerDraft = {
|
|
|
2172
2325
|
updatedAt: string | null;
|
|
2173
2326
|
};
|
|
2174
2327
|
|
|
2328
|
+
export type NewSessionDraftOptions = {
|
|
2329
|
+
sandboxBackend?: SandboxBackend | undefined;
|
|
2330
|
+
targetSandboxId?: string | undefined;
|
|
2331
|
+
workingDir?: string | undefined;
|
|
2332
|
+
variableSetId?: string | undefined;
|
|
2333
|
+
rigId?: string | undefined;
|
|
2334
|
+
goal?: GoalSpec | undefined;
|
|
2335
|
+
firstPartyMcpPermissions?: Permission[] | undefined;
|
|
2336
|
+
};
|
|
2337
|
+
|
|
2338
|
+
export type NewSessionDraft = {
|
|
2339
|
+
revision: number;
|
|
2340
|
+
text: string;
|
|
2341
|
+
resources: ResourceRef[];
|
|
2342
|
+
tools: ToolRef[];
|
|
2343
|
+
/** False inherits the workspace-default MCP policy; true preserves an explicit array. */
|
|
2344
|
+
toolsProvided: boolean;
|
|
2345
|
+
model: string;
|
|
2346
|
+
reasoningEffort: ReasoningEffort;
|
|
2347
|
+
options: NewSessionDraftOptions;
|
|
2348
|
+
updatedAt: string | null;
|
|
2349
|
+
};
|
|
2350
|
+
|
|
2175
2351
|
export type SessionQueueSnapshot = {
|
|
2176
2352
|
version: number;
|
|
2177
2353
|
effectiveControl: EffectiveSessionControl;
|
|
@@ -2300,6 +2476,10 @@ export type SaveComposerDraftRequest = Omit<
|
|
|
2300
2476
|
"revision" | "sourceTurnId" | "sourceTurnVersion" | "updatedAt"
|
|
2301
2477
|
> & { expectedRevision: number };
|
|
2302
2478
|
|
|
2479
|
+
export type SaveNewSessionDraftRequest = Omit<NewSessionDraft, "revision" | "updatedAt"> & {
|
|
2480
|
+
expectedRevision: number;
|
|
2481
|
+
};
|
|
2482
|
+
|
|
2303
2483
|
// --- Scheduled tasks: requests + runs ----------------------------------------
|
|
2304
2484
|
|
|
2305
2485
|
/** Input shape for agent config on create/update (server applies defaults). */
|
|
@@ -2312,6 +2492,7 @@ export type ScheduledTaskAgentConfigInput = {
|
|
|
2312
2492
|
reasoningEffort?: ReasoningEffort | undefined;
|
|
2313
2493
|
sandboxBackend?: SandboxBackend | undefined;
|
|
2314
2494
|
goal?: GoalSpec | undefined;
|
|
2495
|
+
maxNestedAgentDepth?: number | undefined;
|
|
2315
2496
|
};
|
|
2316
2497
|
|
|
2317
2498
|
export type CreateScheduledTaskRequest = {
|
|
@@ -2660,6 +2841,19 @@ export type KnowledgeSourceKind =
|
|
|
2660
2841
|
| "other";
|
|
2661
2842
|
export type DocumentSearchMode = "hybrid" | "vector" | "keyword";
|
|
2662
2843
|
|
|
2844
|
+
export type DocumentVisibility = "workspace" | "private";
|
|
2845
|
+
|
|
2846
|
+
export type DocumentCurationStatus = "none" | "pending" | "suggested" | "auto_filed" | "failed";
|
|
2847
|
+
|
|
2848
|
+
export type DocumentCuration = {
|
|
2849
|
+
suggestedBaseId: string | null;
|
|
2850
|
+
suggestedBaseName: string | null;
|
|
2851
|
+
confidence: number;
|
|
2852
|
+
reason: string | null;
|
|
2853
|
+
originalTitle: string | null;
|
|
2854
|
+
model: string | null;
|
|
2855
|
+
};
|
|
2856
|
+
|
|
2663
2857
|
export type DocumentBase = {
|
|
2664
2858
|
id: string;
|
|
2665
2859
|
workspaceId: string;
|
|
@@ -2688,6 +2882,13 @@ export type Document = {
|
|
|
2688
2882
|
sourceUpdatedAt: string | null;
|
|
2689
2883
|
sourceVersion: string | null;
|
|
2690
2884
|
aclTags: string[];
|
|
2885
|
+
visibility: DocumentVisibility;
|
|
2886
|
+
createdBy: string | null;
|
|
2887
|
+
agentAccess: boolean;
|
|
2888
|
+
summary: string | null;
|
|
2889
|
+
topics: string[];
|
|
2890
|
+
curationStatus: DocumentCurationStatus;
|
|
2891
|
+
curation: DocumentCuration | null;
|
|
2691
2892
|
createdAt: string;
|
|
2692
2893
|
updatedAt: string;
|
|
2693
2894
|
};
|
|
@@ -2734,6 +2935,21 @@ export type AddDocumentRequest = {
|
|
|
2734
2935
|
sourceUpdatedAt?: string | undefined;
|
|
2735
2936
|
sourceVersion?: string | undefined;
|
|
2736
2937
|
aclTags?: string[] | undefined;
|
|
2938
|
+
visibility?: DocumentVisibility | undefined;
|
|
2939
|
+
agentAccess?: boolean | undefined;
|
|
2940
|
+
};
|
|
2941
|
+
|
|
2942
|
+
export type CreateKnowledgeDropRequest = {
|
|
2943
|
+
text?: string | undefined;
|
|
2944
|
+
fileId?: string | undefined;
|
|
2945
|
+
filename?: string | undefined;
|
|
2946
|
+
title?: string | undefined;
|
|
2947
|
+
visibility?: DocumentVisibility | undefined;
|
|
2948
|
+
agentAccess?: boolean | undefined;
|
|
2949
|
+
};
|
|
2950
|
+
|
|
2951
|
+
export type MoveDocumentRequest = {
|
|
2952
|
+
targetBaseId?: string | undefined;
|
|
2737
2953
|
};
|
|
2738
2954
|
|
|
2739
2955
|
export type DocumentSearchRequest = {
|
|
@@ -3170,10 +3386,16 @@ export type GitHubRepository = {
|
|
|
3170
3386
|
|
|
3171
3387
|
export type GitHubRepositoryScope = "all" | "selected";
|
|
3172
3388
|
|
|
3389
|
+
export type GitHubBindingStatus = "disabled" | "unbound" | "bound";
|
|
3390
|
+
|
|
3391
|
+
export type GitHubInstallationLifecycle = "active" | "suspended" | "deleted" | "unverified";
|
|
3392
|
+
|
|
3173
3393
|
export type GitHubInstallationBinding = {
|
|
3174
3394
|
installationId: number;
|
|
3395
|
+
githubAccountId: number | null;
|
|
3175
3396
|
accountLogin: string | null;
|
|
3176
3397
|
accountType: string | null;
|
|
3398
|
+
lifecycle: GitHubInstallationLifecycle;
|
|
3177
3399
|
repositoryScope: GitHubRepositoryScope;
|
|
3178
3400
|
repositoryCount: number;
|
|
3179
3401
|
createdAt: string;
|
|
@@ -3182,12 +3404,14 @@ export type GitHubInstallationBinding = {
|
|
|
3182
3404
|
|
|
3183
3405
|
export type GitHubAppInfo = {
|
|
3184
3406
|
configured: boolean;
|
|
3407
|
+
/** Truthful workspace binding state; server App credentials alone are not a binding. */
|
|
3408
|
+
status: GitHubBindingStatus;
|
|
3185
3409
|
appId: string | null;
|
|
3186
3410
|
clientId: string | null;
|
|
3187
3411
|
appSlug: string | null;
|
|
3188
|
-
/**
|
|
3412
|
+
/** Fresh GitHub-controlled installation/configuration consent entry point. */
|
|
3189
3413
|
installUrl: string | null;
|
|
3190
|
-
/**
|
|
3414
|
+
/** Compatibility alias for installUrl; no repository-admin chooser is exposed. */
|
|
3191
3415
|
linkUrl: string | null;
|
|
3192
3416
|
/** Installation bindings owned independently by this workspace. */
|
|
3193
3417
|
installations: GitHubInstallationBinding[];
|
|
@@ -3379,6 +3603,9 @@ export type MachineView = {
|
|
|
3379
3603
|
state: MachineState;
|
|
3380
3604
|
active: boolean;
|
|
3381
3605
|
isSessionGroup: boolean;
|
|
3606
|
+
workspaceGeneration: number | null;
|
|
3607
|
+
archiveGeneration: number | null;
|
|
3608
|
+
archiveComplete: boolean;
|
|
3382
3609
|
os: string;
|
|
3383
3610
|
arch: string;
|
|
3384
3611
|
hasDisplay: boolean;
|
|
@@ -3428,7 +3655,10 @@ export type SwapActiveSandboxResponse = {
|
|
|
3428
3655
|
| "offline_enrollment"
|
|
3429
3656
|
| "unsupported_backend_context"
|
|
3430
3657
|
| "transient_establishment"
|
|
3431
|
-
| "concurrent_swap"
|
|
3658
|
+
| "concurrent_swap"
|
|
3659
|
+
| "recovery_in_progress"
|
|
3660
|
+
| "recovery_degraded"
|
|
3661
|
+
| "recovery_unrecoverable";
|
|
3432
3662
|
};
|
|
3433
3663
|
|
|
3434
3664
|
// ── Self-hosted enrollment UX (design 11) ────────────────────────────────────
|