@opengeni/sdk 0.57.0 → 2.2.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -2
- package/dist/artifacts.js +5 -5
- package/dist/automations-client.d.ts +17 -0
- package/dist/automations.d.ts +3 -0
- package/dist/automations.js +78 -0
- package/dist/automations.js.map +1 -0
- package/dist/{chunk-JDLDDRNE.js → chunk-C2H7HBNP.js} +290 -33
- package/dist/chunk-C2H7HBNP.js.map +1 -0
- package/dist/{chunk-GU6JF75T.js → chunk-C4DJPZRU.js} +1 -1
- package/dist/{chunk-GU6JF75T.js.map → chunk-C4DJPZRU.js.map} +1 -1
- package/dist/{chunk-JRPFWI6T.js → chunk-G6LBVWKT.js} +2 -2
- package/dist/{chunk-HJ3HHUT5.js → chunk-GLDV5QY7.js} +16 -2
- package/dist/chunk-GLDV5QY7.js.map +1 -0
- package/dist/{chunk-ST5DDKJP.js → chunk-GW3EJ2GP.js} +52 -1
- package/dist/chunk-GW3EJ2GP.js.map +1 -0
- package/dist/{chunk-VWE2QIVO.js → chunk-XNG7YGR3.js} +23 -6
- package/dist/chunk-XNG7YGR3.js.map +1 -0
- package/dist/{chunk-PKQ377ED.js → chunk-YBQTKNTL.js} +696 -57
- package/dist/chunk-YBQTKNTL.js.map +1 -0
- package/dist/client.d.ts +151 -26
- package/dist/codex-realtime-controller.d.ts +3 -0
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/codex-realtime-v3.d.ts +13 -2
- package/dist/company-brain.d.ts +32 -0
- package/dist/company-profile.d.ts +1 -1
- package/dist/core.js +4 -4
- package/dist/editable-artifacts/browser-session.d.ts +7 -3
- package/dist/editable-artifacts/controller.d.ts +4 -1
- package/dist/editable-artifacts/errors.d.ts +1 -1
- package/dist/editable-artifacts/http-live-transport.d.ts +6 -2
- package/dist/editable-artifacts/index.d.ts +2 -0
- package/dist/editable-artifacts/open-failure.d.ts +9 -0
- package/dist/editable-artifacts/types.d.ts +4 -3
- package/dist/editable-artifacts/worker/kernel-adapter.d.ts +1 -1
- package/dist/editable-artifacts-worker.js +44 -17
- package/dist/editable-artifacts-worker.js.map +1 -1
- package/dist/editable-artifacts.js +222 -119
- package/dist/editable-artifacts.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +61 -12
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +23 -0
- package/dist/interaction.js +4 -1
- package/dist/organization-private-session-settings.d.ts +6 -0
- package/dist/organization-private-session-settings.js +22 -0
- package/dist/organization-private-session-settings.js.map +1 -0
- package/dist/pr-review-client.d.ts +15 -0
- package/dist/pr-review.d.ts +4 -0
- package/dist/pr-review.js +56 -0
- package/dist/pr-review.js.map +1 -0
- package/dist/preference-registry.d.ts +8 -0
- package/dist/realtime.js +2 -2
- package/dist/retained-artifacts.d.ts +5 -1
- package/dist/types.d.ts +976 -17
- package/dist/workspace-instruction-policies.d.ts +22 -0
- package/dist/workspace-learning.d.ts +124 -0
- package/package.json +14 -2
- package/src/automations-client.ts +118 -0
- package/src/automations.ts +15 -0
- package/src/client.ts +974 -71
- package/src/codex-realtime-controller.ts +235 -5
- package/src/codex-realtime-v3.ts +162 -31
- package/src/company-brain.ts +99 -0
- package/src/company-profile.ts +4 -1
- package/src/editable-artifacts/browser-session.ts +36 -22
- package/src/editable-artifacts/controller.ts +66 -45
- package/src/editable-artifacts/errors.ts +2 -0
- package/src/editable-artifacts/http-live-transport.ts +62 -37
- package/src/editable-artifacts/index.ts +6 -0
- package/src/editable-artifacts/open-failure.ts +79 -0
- package/src/editable-artifacts/storage.ts +31 -40
- package/src/editable-artifacts/types.ts +4 -3
- package/src/editable-artifacts/worker/kernel-adapter.ts +23 -7
- package/src/editable-artifacts/worker/runtime.ts +26 -13
- package/src/editable-artifacts/worker/wire-codec.ts +23 -5
- package/src/errors.ts +1 -1
- package/src/index.ts +131 -0
- package/src/interaction.ts +95 -0
- package/src/organization-private-session-settings.ts +33 -0
- package/src/pr-review-client.ts +84 -0
- package/src/pr-review.ts +15 -0
- package/src/preference-registry.ts +9 -0
- package/src/retained-artifacts.ts +101 -0
- package/src/stream.ts +13 -2
- package/src/types.ts +1117 -16
- package/src/workspace-instruction-policies.ts +24 -0
- package/src/workspace-learning.ts +138 -0
- package/dist/chunk-HJ3HHUT5.js.map +0 -1
- package/dist/chunk-JDLDDRNE.js.map +0 -1
- package/dist/chunk-PKQ377ED.js.map +0 -1
- package/dist/chunk-ST5DDKJP.js.map +0 -1
- package/dist/chunk-VWE2QIVO.js.map +0 -1
- /package/dist/{chunk-JRPFWI6T.js.map → chunk-G6LBVWKT.js.map} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { OpenGeniClient as OpenGeniCoreClient } from "./client";
|
|
2
|
+
import type {
|
|
3
|
+
CreatePrReviewAppRegistrationRequest,
|
|
4
|
+
CreatePrReviewRepositoryBindingRequest,
|
|
5
|
+
PrReviewAppRegistration,
|
|
6
|
+
PrReviewRepositoryBinding,
|
|
7
|
+
ListPrReviewConfigurationResponse,
|
|
8
|
+
UpdatePrReviewAppRegistrationRequest,
|
|
9
|
+
UpdatePrReviewRepositoryBindingRequest,
|
|
10
|
+
} from "./types";
|
|
11
|
+
|
|
12
|
+
export type OpenGeniPrReviewTransport = Pick<OpenGeniCoreClient, "requestJson" | "requestVoid">;
|
|
13
|
+
|
|
14
|
+
/** Optional OpenGeni Review Bot API surface, isolated from the eager core client graph. */
|
|
15
|
+
export class OpenGeniPrReviewClient {
|
|
16
|
+
constructor(private readonly client: OpenGeniPrReviewTransport) {}
|
|
17
|
+
|
|
18
|
+
async listConfiguration(workspaceId: string): Promise<ListPrReviewConfigurationResponse> {
|
|
19
|
+
return await this.client.requestJson<ListPrReviewConfigurationResponse>(
|
|
20
|
+
"GET",
|
|
21
|
+
`/v1/workspaces/${workspaceId}/pr-review/registrations`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async createAppRegistration(
|
|
26
|
+
workspaceId: string,
|
|
27
|
+
request: CreatePrReviewAppRegistrationRequest,
|
|
28
|
+
): Promise<PrReviewAppRegistration> {
|
|
29
|
+
return await this.client.requestJson<PrReviewAppRegistration>(
|
|
30
|
+
"POST",
|
|
31
|
+
`/v1/workspaces/${workspaceId}/pr-review/registrations`,
|
|
32
|
+
request,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async updateAppRegistration(
|
|
37
|
+
workspaceId: string,
|
|
38
|
+
registrationId: string,
|
|
39
|
+
request: UpdatePrReviewAppRegistrationRequest,
|
|
40
|
+
): Promise<PrReviewAppRegistration> {
|
|
41
|
+
return await this.client.requestJson<PrReviewAppRegistration>(
|
|
42
|
+
"PATCH",
|
|
43
|
+
`/v1/workspaces/${workspaceId}/pr-review/registrations/${encodeURIComponent(registrationId)}`,
|
|
44
|
+
request,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async deleteAppRegistration(workspaceId: string, registrationId: string): Promise<void> {
|
|
49
|
+
await this.client.requestVoid(
|
|
50
|
+
"DELETE",
|
|
51
|
+
`/v1/workspaces/${workspaceId}/pr-review/registrations/${encodeURIComponent(registrationId)}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async createRepositoryBinding(
|
|
56
|
+
workspaceId: string,
|
|
57
|
+
request: CreatePrReviewRepositoryBindingRequest,
|
|
58
|
+
): Promise<PrReviewRepositoryBinding> {
|
|
59
|
+
return await this.client.requestJson<PrReviewRepositoryBinding>(
|
|
60
|
+
"POST",
|
|
61
|
+
`/v1/workspaces/${workspaceId}/pr-review/repositories`,
|
|
62
|
+
request,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async updateRepositoryBinding(
|
|
67
|
+
workspaceId: string,
|
|
68
|
+
bindingId: string,
|
|
69
|
+
request: UpdatePrReviewRepositoryBindingRequest,
|
|
70
|
+
): Promise<PrReviewRepositoryBinding> {
|
|
71
|
+
return await this.client.requestJson<PrReviewRepositoryBinding>(
|
|
72
|
+
"PATCH",
|
|
73
|
+
`/v1/workspaces/${workspaceId}/pr-review/repositories/${encodeURIComponent(bindingId)}`,
|
|
74
|
+
request,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async deleteRepositoryBinding(workspaceId: string, bindingId: string): Promise<void> {
|
|
79
|
+
await this.client.requestVoid(
|
|
80
|
+
"DELETE",
|
|
81
|
+
`/v1/workspaces/${workspaceId}/pr-review/repositories/${encodeURIComponent(bindingId)}`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/pr-review.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Optional OpenGeni Review Bot API client; import this entry only where the capability is used. */
|
|
2
|
+
export { OpenGeniPrReviewClient } from "./pr-review-client";
|
|
3
|
+
export type { OpenGeniPrReviewTransport } from "./pr-review-client";
|
|
4
|
+
export type {
|
|
5
|
+
CreatePrReviewAppRegistrationRequest,
|
|
6
|
+
CreatePrReviewRepositoryBindingRequest,
|
|
7
|
+
PrReviewAppRegistration,
|
|
8
|
+
PrReviewCredentialKind,
|
|
9
|
+
PrReviewProvider,
|
|
10
|
+
PrReviewRepositoryBinding,
|
|
11
|
+
PrReviewWebhookAuthKind,
|
|
12
|
+
ListPrReviewConfigurationResponse,
|
|
13
|
+
UpdatePrReviewAppRegistrationRequest,
|
|
14
|
+
UpdatePrReviewRepositoryBindingRequest,
|
|
15
|
+
} from "./types";
|
|
@@ -101,6 +101,8 @@ export type PreferenceRegistryEvent = {
|
|
|
101
101
|
createdAt: string;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
export type PreferenceRegistryActivationAuthority = "human_confirmed" | "automatic";
|
|
105
|
+
|
|
104
106
|
export type PreferenceRegistryDescriptor = {
|
|
105
107
|
id: string;
|
|
106
108
|
stableKey: string;
|
|
@@ -112,6 +114,13 @@ export type PreferenceRegistryDescriptor = {
|
|
|
112
114
|
contentHash: string;
|
|
113
115
|
precedence: PreferenceRegistryPrecedence;
|
|
114
116
|
provenance: PreferenceRegistryDescriptorProvenance;
|
|
117
|
+
/**
|
|
118
|
+
* How the active revision became active. `provenance.trust` stays the frozen
|
|
119
|
+
* creation-time fact; this is the separate activation question. Null when the
|
|
120
|
+
* revision became active outside governed learning, or when the descriptor
|
|
121
|
+
* predates this field.
|
|
122
|
+
*/
|
|
123
|
+
activationAuthority: PreferenceRegistryActivationAuthority | null;
|
|
115
124
|
expiresAt: string | null;
|
|
116
125
|
retrievalHandle: string;
|
|
117
126
|
};
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
GeneratedVideoReceipt,
|
|
4
4
|
MediaGenerationResult,
|
|
5
5
|
RetainedArtifactReference,
|
|
6
|
+
SandboxFileArtifactReceipt,
|
|
6
7
|
} from "./types";
|
|
7
8
|
|
|
8
9
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
@@ -15,6 +16,94 @@ const MAX_VIDEO_BYTES = 512 * 1024 * 1024;
|
|
|
15
16
|
const MAX_DIMENSION = 16_384;
|
|
16
17
|
const MAX_PIXELS = 67_108_864;
|
|
17
18
|
const MAX_RANGE_BYTES = 1024 * 1024;
|
|
19
|
+
const MAX_SANDBOX_FILE_BYTES = 25 * 1024 * 1024 - 1;
|
|
20
|
+
|
|
21
|
+
/** Zero-dependency validation for a permanent generic workspace-file receipt. */
|
|
22
|
+
export function parseRetainedWorkspaceFileReference(
|
|
23
|
+
value: unknown,
|
|
24
|
+
expectedWorkspaceId?: string,
|
|
25
|
+
): RetainedArtifactReference | null {
|
|
26
|
+
if (!recordWithKeys(value, WORKSPACE_FILE_REFERENCE_KEYS)) return null;
|
|
27
|
+
const artifact = value as Record<string, unknown>;
|
|
28
|
+
if (
|
|
29
|
+
artifact.available !== true ||
|
|
30
|
+
artifact.kind !== "file" ||
|
|
31
|
+
typeof artifact.artifactId !== "string" ||
|
|
32
|
+
!UUID.test(artifact.artifactId) ||
|
|
33
|
+
typeof artifact.contentType !== "string" ||
|
|
34
|
+
!/^[a-z0-9][a-z0-9!#$&^_.+-]{0,62}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,62}$/.test(
|
|
35
|
+
artifact.contentType,
|
|
36
|
+
) ||
|
|
37
|
+
!safeIntegerBetween(artifact.originalBytes, 1, MAX_SANDBOX_FILE_BYTES) ||
|
|
38
|
+
typeof artifact.sha256 !== "string" ||
|
|
39
|
+
!SHA256.test(artifact.sha256) ||
|
|
40
|
+
typeof artifact.retainedAt !== "string" ||
|
|
41
|
+
artifact.retainedAt.length > 64 ||
|
|
42
|
+
!ISO_DATETIME_WITH_OFFSET.test(artifact.retainedAt) ||
|
|
43
|
+
!Number.isFinite(Date.parse(artifact.retainedAt)) ||
|
|
44
|
+
!recordWithKeys(artifact.retention, RETENTION_KEYS) ||
|
|
45
|
+
!recordWithKeys(artifact.retrieval, RETRIEVAL_KEYS)
|
|
46
|
+
) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const retention = artifact.retention as Record<string, unknown>;
|
|
50
|
+
if (retention.policy !== "workspace_file" || retention.expiresAt !== null) return null;
|
|
51
|
+
const retrieval = artifact.retrieval as Record<string, unknown>;
|
|
52
|
+
if (
|
|
53
|
+
retrieval.method !== "GET" ||
|
|
54
|
+
retrieval.acceptRanges !== "bytes" ||
|
|
55
|
+
retrieval.maxRangeBytes !== MAX_RANGE_BYTES ||
|
|
56
|
+
typeof retrieval.path !== "string" ||
|
|
57
|
+
retrieval.path.length > 256
|
|
58
|
+
) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const match = WORKSPACE_PATH.exec(retrieval.path);
|
|
62
|
+
if (
|
|
63
|
+
!match ||
|
|
64
|
+
!UUID.test(match[1] ?? "") ||
|
|
65
|
+
match[2] !== artifact.artifactId ||
|
|
66
|
+
(expectedWorkspaceId !== undefined && match[1] !== expectedWorkspaceId)
|
|
67
|
+
) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return value as RetainedArtifactReference;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Parse the closed result returned by sandbox_file_publish and the session API. */
|
|
74
|
+
export function parseSandboxFileArtifactReceipt(
|
|
75
|
+
value: unknown,
|
|
76
|
+
expectedWorkspaceId?: string,
|
|
77
|
+
): SandboxFileArtifactReceipt | null {
|
|
78
|
+
if (typeof value === "string" && value.length <= 8_192) {
|
|
79
|
+
try {
|
|
80
|
+
return parseSandboxFileArtifactReceipt(JSON.parse(value), expectedWorkspaceId);
|
|
81
|
+
} catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!recordWithKeys(value, SANDBOX_FILE_RECEIPT_KEYS)) return null;
|
|
86
|
+
const artifact = parseRetainedWorkspaceFileReference(value.artifact, expectedWorkspaceId);
|
|
87
|
+
const pathSegments = typeof value.sandboxPath === "string" ? value.sandboxPath.split("/") : [];
|
|
88
|
+
if (
|
|
89
|
+
value.type !== "sandbox_file" ||
|
|
90
|
+
typeof value.sandboxPath !== "string" ||
|
|
91
|
+
!value.sandboxPath.startsWith("/workspace/") ||
|
|
92
|
+
value.sandboxPath.length > 4_096 ||
|
|
93
|
+
value.sandboxPath.includes("\0") ||
|
|
94
|
+
pathSegments.some(
|
|
95
|
+
(segment, index) => index > 1 && (!segment || segment === "." || segment === ".."),
|
|
96
|
+
) ||
|
|
97
|
+
typeof value.filename !== "string" ||
|
|
98
|
+
value.filename.length < 1 ||
|
|
99
|
+
value.filename.length > 1_024 ||
|
|
100
|
+
pathSegments.at(-1) !== value.filename ||
|
|
101
|
+
!artifact
|
|
102
|
+
) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return value as SandboxFileArtifactReceipt;
|
|
106
|
+
}
|
|
18
107
|
|
|
19
108
|
/** Zero-dependency validation for the SDK's permanent generated-image wire receipt. */
|
|
20
109
|
export function parseRetainedGeneratedImageReference(
|
|
@@ -272,10 +361,22 @@ const GENERATED_IMAGE_REFERENCE_KEYS = new Set([
|
|
|
272
361
|
"retention",
|
|
273
362
|
"retrieval",
|
|
274
363
|
]);
|
|
364
|
+
const WORKSPACE_FILE_REFERENCE_KEYS = new Set([
|
|
365
|
+
"available",
|
|
366
|
+
"artifactId",
|
|
367
|
+
"kind",
|
|
368
|
+
"contentType",
|
|
369
|
+
"originalBytes",
|
|
370
|
+
"sha256",
|
|
371
|
+
"retainedAt",
|
|
372
|
+
"retention",
|
|
373
|
+
"retrieval",
|
|
374
|
+
]);
|
|
275
375
|
const DIMENSION_KEYS = new Set(["width", "height"]);
|
|
276
376
|
const RETENTION_KEYS = new Set(["policy", "expiresAt"]);
|
|
277
377
|
const RETRIEVAL_KEYS = new Set(["method", "path", "acceptRanges", "maxRangeBytes"]);
|
|
278
378
|
const GENERATED_IMAGE_RECEIPT_KEYS = new Set(["type", "artifact", "sandboxPath"]);
|
|
379
|
+
const SANDBOX_FILE_RECEIPT_KEYS = new Set(["type", "sandboxPath", "filename", "artifact"]);
|
|
279
380
|
const GENERATED_VIDEO_RECEIPT_KEYS = new Set([
|
|
280
381
|
"type",
|
|
281
382
|
"schemaVersion",
|
package/src/stream.ts
CHANGED
|
@@ -108,9 +108,11 @@ export async function* streamSessionEvents(
|
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
const event = parseSessionEvent(message.data);
|
|
111
|
-
if (!event
|
|
111
|
+
if (!event) {
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
|
+
const coveredSequence = eventResumeSequence(event);
|
|
115
|
+
if (coveredSequence <= cursor) continue;
|
|
114
116
|
if (event.sequence > cursor + 1) {
|
|
115
117
|
for await (const missed of backfillEvents(transport, cursor, event.sequence - 1)) {
|
|
116
118
|
cursor = missed.sequence;
|
|
@@ -120,7 +122,7 @@ export async function* streamSessionEvents(
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
|
-
cursor =
|
|
125
|
+
cursor = coveredSequence;
|
|
124
126
|
yield event;
|
|
125
127
|
}
|
|
126
128
|
if (!reconnect) {
|
|
@@ -281,6 +283,15 @@ function parseSessionEvent(data: string): SessionEvent | null {
|
|
|
281
283
|
return parsed as SessionEvent;
|
|
282
284
|
}
|
|
283
285
|
|
|
286
|
+
/** Raw durable cursor covered by a compact SSE event. */
|
|
287
|
+
function eventResumeSequence(event: SessionEvent): number {
|
|
288
|
+
if (!event.payload || typeof event.payload !== "object" || Array.isArray(event.payload)) {
|
|
289
|
+
return event.sequence;
|
|
290
|
+
}
|
|
291
|
+
const covered = Number((event.payload as Record<string, unknown>).coalescedUntil);
|
|
292
|
+
return Math.max(event.sequence, Number.isFinite(covered) ? Math.floor(covered) : event.sequence);
|
|
293
|
+
}
|
|
294
|
+
|
|
284
295
|
async function sleep(delayMs: number, signal: AbortSignal | undefined): Promise<void> {
|
|
285
296
|
if (signal?.aborted || delayMs <= 0) {
|
|
286
297
|
return;
|