@opengeni/sdk 1.0.1 → 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 +117 -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-A5DC5WEM.js → chunk-C2H7HBNP.js} +22 -2
- 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-TYZ4JL4J.js → chunk-G6LBVWKT.js} +2 -2
- package/dist/{chunk-4DV37UUA.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-YGH5P47G.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 +1 -0
- package/dist/codex-realtime-controller.js +2 -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 +961 -13
- 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 +21 -0
- 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 +1101 -12
- package/src/workspace-instruction-policies.ts +24 -0
- package/src/workspace-learning.ts +138 -0
- package/dist/chunk-4DV37UUA.js.map +0 -1
- package/dist/chunk-A5DC5WEM.js.map +0 -1
- package/dist/chunk-ST5DDKJP.js.map +0 -1
- package/dist/chunk-VWE2QIVO.js.map +0 -1
- package/dist/chunk-YGH5P47G.js.map +0 -1
- /package/dist/{chunk-TYZ4JL4J.js.map → chunk-G6LBVWKT.js.map} +0 -0
package/README.md
CHANGED
|
@@ -37,6 +37,110 @@ for await (const event of client.streamEvents(workspaceId, session.id)) {
|
|
|
37
37
|
}
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
## Session visibility and forks
|
|
41
|
+
|
|
42
|
+
For organizations with session-tenancy activation, a canonical managed-cookie
|
|
43
|
+
owner can change a fully quiescent session between private and workspace
|
|
44
|
+
visibility or create an independent same-workspace private or workspace-visible fork. API keys and
|
|
45
|
+
delegated/service bearers are intentionally not authority for these methods.
|
|
46
|
+
The browser client below intentionally omits `apiKey`; its same-origin request
|
|
47
|
+
carries the authenticated managed-session cookie.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const browserClient = new OpenGeniClient({ baseUrl: window.location.origin });
|
|
51
|
+
const current = await browserClient.getSession(workspaceId, sessionId);
|
|
52
|
+
if (!current.tenancy) throw new Error("Session tenancy is not activated");
|
|
53
|
+
|
|
54
|
+
await browserClient.updateSessionVisibility(workspaceId, sessionId, {
|
|
55
|
+
visibility: "private",
|
|
56
|
+
expectedAuthorityEpoch: current.tenancy.authorityEpoch,
|
|
57
|
+
idempotencyKey: crypto.randomUUID(),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const fork = await browserClient.forkSession(workspaceId, sessionId, {
|
|
61
|
+
idempotencyKey: crypto.randomUUID(),
|
|
62
|
+
visibility: "workspace",
|
|
63
|
+
// Required when private conversation content is copied into workspace scope.
|
|
64
|
+
workspaceSharedAcknowledged: current.tenancy.visibility === "private",
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Retain each idempotency key until the request has a known outcome. If a
|
|
69
|
+
transport failure reports `outcomeUnknown`, retry the same operation with the
|
|
70
|
+
same key. An authority-epoch conflict requires a fresh `getSession` and a new
|
|
71
|
+
user decision. A quiescence conflict identifies the stable blocker after live
|
|
72
|
+
turns, goals, realtime, schedules, workspace writers, retained processes, and
|
|
73
|
+
sandbox access have been settled. Forks copy exact same-workspace durable
|
|
74
|
+
conversation content but no live turn, goal, credential, Connection/delegation,
|
|
75
|
+
personal grant, Variable Set, Rig, MCP server configuration, process, sandbox
|
|
76
|
+
identity, pin, or workflow. Destination visibility and acknowledgement are
|
|
77
|
+
idempotency-bound.
|
|
78
|
+
|
|
79
|
+
## Personal-resource grants
|
|
80
|
+
|
|
81
|
+
The same canonical managed-cookie owner can manage explicit personal-resource
|
|
82
|
+
delegations after organization activation. Pages are bounded to one exact kind;
|
|
83
|
+
the server derives the only valid action and returns the full credential-free
|
|
84
|
+
delegation to attach through the resource's ordinary session API.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const page = await browserClient.listUserResourceAuthorities(workspaceId, {
|
|
88
|
+
resourceKind: "connection",
|
|
89
|
+
limit: 50,
|
|
90
|
+
});
|
|
91
|
+
const authority = page.authorities[0];
|
|
92
|
+
if (!authority) throw new Error("No personal Connection is available");
|
|
93
|
+
|
|
94
|
+
const issued = await browserClient.issueUserResourceGrant(workspaceId, authority.authorityId, {
|
|
95
|
+
scope: "user",
|
|
96
|
+
resourceKind: "connection",
|
|
97
|
+
mode: "session",
|
|
98
|
+
context: "workspace_shared",
|
|
99
|
+
sessionId,
|
|
100
|
+
expectedAuthorityEpoch: current.tenancy.authorityEpoch,
|
|
101
|
+
workspaceSharedAcknowledged: true,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
await browserClient.revokeUserResourceGrant(workspaceId, issued.grant.grantId);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The SDK deliberately exposes only exact-session and standing (`always`) grant
|
|
108
|
+
management. It does not expose standalone `once`, custom expiry, scheduled or
|
|
109
|
+
cross-workspace authority, or an atomic create-session-and-attach workflow.
|
|
110
|
+
Revocation prevents future reads but cannot retract output already shared.
|
|
111
|
+
|
|
112
|
+
## Scheduled connection authority
|
|
113
|
+
|
|
114
|
+
Agent schedules may carry explicit personal Connection authority. The public
|
|
115
|
+
request contains only the credential-free server, Connection, and common-user
|
|
116
|
+
grant tuple returned by the authority-selection API; the SDK never receives or
|
|
117
|
+
stores provider credentials:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
const task = await client.createScheduledTask(workspaceId, {
|
|
121
|
+
name: "Daily triage",
|
|
122
|
+
schedule: { type: "calendar", hour: 8, minute: 0, timeZone: "Europe/Oslo" },
|
|
123
|
+
runMode: "reusable_session",
|
|
124
|
+
agentConfig: { prompt: "Triage the new support issues" },
|
|
125
|
+
connectionAuthorities: [selection],
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
PATCH semantics are deliberate: omit `connectionAuthorities` to preserve the
|
|
130
|
+
exact prior immutable selection, pass `[]` to clear it, or pass a non-empty
|
|
131
|
+
array to replace and revalidate it. Execution-changing edits that preserve
|
|
132
|
+
personal authority must be made by the same causal human; use an explicit fresh
|
|
133
|
+
selection when authority should move. `once` grants are consumed by the durable
|
|
134
|
+
scheduled occurrence, not by an activity attempt, so retries reuse the same run
|
|
135
|
+
receipt. `listScheduledTaskRuns` exposes terminal occurrence state while private
|
|
136
|
+
Connection ids, subjects, and authority snapshots stay server-side.
|
|
137
|
+
|
|
138
|
+
Deleting a task is externally idempotent and immediately removes it from live
|
|
139
|
+
lists and quota, but the server retains a tombstone plus run/session/turn audit
|
|
140
|
+
evidence until workspace/account retention cleanup. A stable `triggerId` is
|
|
141
|
+
still required when a caller wants manual-trigger retries to coalesce; ordinary
|
|
142
|
+
scheduled fires derive their producer identity from the Temporal fire workflow.
|
|
143
|
+
|
|
40
144
|
## Realtime browser controller (`@opengeni/sdk/realtime`)
|
|
41
145
|
|
|
42
146
|
The public realtime subpath owns the provider-neutral browser controller and
|
|
@@ -447,6 +551,17 @@ it is not public web search.
|
|
|
447
551
|
const goal = await client.getGoal(workspaceId, sessionId); // counters: autoContinuations, noProgressStreak
|
|
448
552
|
await client.pauseGoal(workspaceId, sessionId, { rationale: "manual review" });
|
|
449
553
|
await client.resumeGoal(workspaceId, sessionId); // resets counters, re-arms continuations
|
|
554
|
+
|
|
555
|
+
const revisions = await client.listGoalRevisions(workspaceId, sessionId); // legacy raw array
|
|
556
|
+
const page = await client.listGoalRevisionPage(workspaceId, sessionId, { limit: 25 });
|
|
557
|
+
await client.rejectGoalRevision(workspaceId, sessionId, proposalId, {
|
|
558
|
+
expectedObjectiveRevision: goal.objectiveRevision,
|
|
559
|
+
rationale: "Keep the existing objective",
|
|
560
|
+
});
|
|
561
|
+
await client.rollbackGoalRevision(workspaceId, sessionId, appliedRevisionId, {
|
|
562
|
+
expectedObjectiveRevision: goal.objectiveRevision,
|
|
563
|
+
rationale: "Restore the last known-good objective",
|
|
564
|
+
});
|
|
450
565
|
```
|
|
451
566
|
|
|
452
567
|
## Files
|
|
@@ -530,7 +645,7 @@ Every public endpoint group has typed methods:
|
|
|
530
645
|
| Sessions + events | `createSession`, `listSessions`, `listSessionPage`, `listAgentTopology`, `getSession`, `getSessionLineage`, `updateSession`, `listEvents`, `sendEvent`, `sendMessage`, `steerMessage`, `pauseSession`, `resumeSession`, `cancelSession`, `sendApprovalDecision`, `streamEvents`, `openEventStream` |
|
|
531
646
|
| Machines (bring-your-own-compute) | `listMachines`, `machineMetricsSeries`, `swapActiveSandbox`, `mintEnrollToken`, `lookupDeviceEnrollment`, `approveDeviceEnrollment`, `denyDeviceEnrollment` |
|
|
532
647
|
| Turn queue | `getQueue`, `moveQueueItem`, `editQueueItem`, `steerQueueItem`, `deleteQueueItem` |
|
|
533
|
-
| Goal | `getGoal`, `updateGoal`, `pauseGoal`, `resumeGoal` |
|
|
648
|
+
| Goal | `getGoal`, `updateGoal`, `pauseGoal`, `resumeGoal`, `listGoalRevisions`, `listGoalRevisionPage`, `applyGoalRevision`, `rejectGoalRevision`, `rollbackGoalRevision` |
|
|
534
649
|
| Scheduled tasks | `createScheduledTask`, `listScheduledTasks`, `getScheduledTask`, `updateScheduledTask`, `pauseScheduledTask`, `resumeScheduledTask`, `triggerScheduledTask`, `deleteScheduledTask`, `listScheduledTaskRuns` |
|
|
535
650
|
| Variable sets | `listVariableSets`, `createVariableSet`, `getVariableSet`, `updateVariableSet`, `deleteVariableSet`, `setVariableSetVariable`, `deleteVariableSetVariable`; generic reads are metadata-only, while dedicated permissioned exact-value reads are part of the held client train |
|
|
536
651
|
| Files | `uploadFile`, `beginFileUpload`, `completeFileUpload`, `getFile`, `createFileDownloadUrl` |
|
|
@@ -542,7 +657,7 @@ Every public endpoint group has typed methods:
|
|
|
542
657
|
| Remote Skills | `previewSkillImport`, `installSkill`, `previewSkillUninstall`, `uninstallSkill` |
|
|
543
658
|
| GitHub | `getGitHubApp`, `githubConnectUrl`, `listGitHubRepositories`, `syncGitHubRepositories`, `createGitHubAppManifest` |
|
|
544
659
|
| API keys | `listApiKeys`, `createApiKey`, `deleteApiKey` |
|
|
545
|
-
| Billing | `getBilling`, `getBillingUsage`, `getBillingEntitlements`, `createBillingCheckout` |
|
|
660
|
+
| Billing | `getBilling`, `getBillingUsage`, `getBillingEntitlements`, `createBillingCheckout`, `createBillingPortalSession` |
|
|
546
661
|
|
|
547
662
|
`listIntegrationDefinitions` returns safe Integration Definition metadata without any
|
|
548
663
|
deployment OAuth client credentials. API Integrations are multi-instance:
|
package/dist/artifacts.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OpenGeniClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-G6LBVWKT.js";
|
|
4
|
+
import "./chunk-YBQTKNTL.js";
|
|
5
|
+
import "./chunk-GLDV5QY7.js";
|
|
6
|
+
import "./chunk-GW3EJ2GP.js";
|
|
7
|
+
import "./chunk-C4DJPZRU.js";
|
|
8
8
|
export {
|
|
9
9
|
OpenGeniClient
|
|
10
10
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AutomationRun, AutomationSource, AutomationTrigger, AutomationWebhookResult, CreateAutomationSourceRequest, CreateAutomationTriggerRequest, TriggerAutomationManuallyRequest, UpdateAutomationSourceRequest, UpdateAutomationTriggerRequest } from "@opengeni/contracts";
|
|
2
|
+
import type { OpenGeniClient as OpenGeniCoreClient } from "./client.js";
|
|
3
|
+
export type OpenGeniAutomationsTransport = Pick<OpenGeniCoreClient, "requestJson">;
|
|
4
|
+
export declare class OpenGeniAutomationsClient {
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: OpenGeniAutomationsTransport);
|
|
7
|
+
listSources(workspaceId: string): Promise<AutomationSource[]>;
|
|
8
|
+
createSource(workspaceId: string, request: CreateAutomationSourceRequest): Promise<AutomationSource>;
|
|
9
|
+
updateSource(workspaceId: string, sourceId: string, request: UpdateAutomationSourceRequest): Promise<AutomationSource>;
|
|
10
|
+
disableSource(workspaceId: string, sourceId: string): Promise<void>;
|
|
11
|
+
listTriggers(workspaceId: string): Promise<AutomationTrigger[]>;
|
|
12
|
+
createTrigger(workspaceId: string, request: CreateAutomationTriggerRequest): Promise<AutomationTrigger>;
|
|
13
|
+
updateTrigger(workspaceId: string, triggerId: string, request: UpdateAutomationTriggerRequest): Promise<AutomationTrigger>;
|
|
14
|
+
disableTrigger(workspaceId: string, triggerId: string, expectedRevision: number): Promise<void>;
|
|
15
|
+
listRuns(workspaceId: string): Promise<AutomationRun[]>;
|
|
16
|
+
triggerManually(workspaceId: string, sourceId: string, request: TriggerAutomationManuallyRequest): Promise<AutomationWebhookResult>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { OpenGeniAutomationsClient } from "./automations-client.js";
|
|
2
|
+
export type { OpenGeniAutomationsTransport } from "./automations-client.js";
|
|
3
|
+
export type { AutomationAcceptedExecution, AutomationNormalizedEvent, AutomationRun, AutomationSource, AutomationTrigger, AutomationWebhookResult, CreateAutomationSourceRequest, CreateAutomationTriggerRequest, TriggerAutomationManuallyRequest, UpdateAutomationSourceRequest, UpdateAutomationTriggerRequest, } from "@opengeni/contracts";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/automations-client.ts
|
|
2
|
+
var OpenGeniAutomationsClient = class {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async listSources(workspaceId) {
|
|
7
|
+
const result = await this.client.requestJson(
|
|
8
|
+
"GET",
|
|
9
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`
|
|
10
|
+
);
|
|
11
|
+
return result.sources;
|
|
12
|
+
}
|
|
13
|
+
async createSource(workspaceId, request) {
|
|
14
|
+
return await this.client.requestJson(
|
|
15
|
+
"POST",
|
|
16
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`,
|
|
17
|
+
request
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
async updateSource(workspaceId, sourceId, request) {
|
|
21
|
+
return await this.client.requestJson(
|
|
22
|
+
"PATCH",
|
|
23
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,
|
|
24
|
+
request
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
async disableSource(workspaceId, sourceId) {
|
|
28
|
+
await this.client.requestJson(
|
|
29
|
+
"DELETE",
|
|
30
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
async listTriggers(workspaceId) {
|
|
34
|
+
const result = await this.client.requestJson(
|
|
35
|
+
"GET",
|
|
36
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`
|
|
37
|
+
);
|
|
38
|
+
return result.triggers;
|
|
39
|
+
}
|
|
40
|
+
async createTrigger(workspaceId, request) {
|
|
41
|
+
return await this.client.requestJson(
|
|
42
|
+
"POST",
|
|
43
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`,
|
|
44
|
+
request
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
async updateTrigger(workspaceId, triggerId, request) {
|
|
48
|
+
return await this.client.requestJson(
|
|
49
|
+
"PATCH",
|
|
50
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}`,
|
|
51
|
+
request
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
async disableTrigger(workspaceId, triggerId, expectedRevision) {
|
|
55
|
+
await this.client.requestJson(
|
|
56
|
+
"DELETE",
|
|
57
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}?expectedRevision=${expectedRevision}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
async listRuns(workspaceId) {
|
|
61
|
+
const result = await this.client.requestJson(
|
|
62
|
+
"GET",
|
|
63
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/runs`
|
|
64
|
+
);
|
|
65
|
+
return result.runs;
|
|
66
|
+
}
|
|
67
|
+
async triggerManually(workspaceId, sourceId, request) {
|
|
68
|
+
return await this.client.requestJson(
|
|
69
|
+
"POST",
|
|
70
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}/events`,
|
|
71
|
+
request
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
OpenGeniAutomationsClient
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=automations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/automations-client.ts"],"sourcesContent":["import type {\n AutomationRun,\n AutomationSource,\n AutomationTrigger,\n AutomationWebhookResult,\n CreateAutomationSourceRequest,\n CreateAutomationTriggerRequest,\n TriggerAutomationManuallyRequest,\n UpdateAutomationSourceRequest,\n UpdateAutomationTriggerRequest,\n} from \"@opengeni/contracts\";\nimport type { OpenGeniClient as OpenGeniCoreClient } from \"./client\";\n\nexport type OpenGeniAutomationsTransport = Pick<OpenGeniCoreClient, \"requestJson\">;\n\nexport class OpenGeniAutomationsClient {\n constructor(private readonly client: OpenGeniAutomationsTransport) {}\n\n async listSources(workspaceId: string): Promise<AutomationSource[]> {\n const result = await this.client.requestJson<{ sources: AutomationSource[] }>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`,\n );\n return result.sources;\n }\n\n async createSource(\n workspaceId: string,\n request: CreateAutomationSourceRequest,\n ): Promise<AutomationSource> {\n return await this.client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`,\n request,\n );\n }\n\n async updateSource(\n workspaceId: string,\n sourceId: string,\n request: UpdateAutomationSourceRequest,\n ): Promise<AutomationSource> {\n return await this.client.requestJson(\n \"PATCH\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,\n request,\n );\n }\n\n async disableSource(workspaceId: string, sourceId: string): Promise<void> {\n await this.client.requestJson(\n \"DELETE\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,\n );\n }\n\n async listTriggers(workspaceId: string): Promise<AutomationTrigger[]> {\n const result = await this.client.requestJson<{ triggers: AutomationTrigger[] }>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`,\n );\n return result.triggers;\n }\n\n async createTrigger(\n workspaceId: string,\n request: CreateAutomationTriggerRequest,\n ): Promise<AutomationTrigger> {\n return await this.client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`,\n request,\n );\n }\n\n async updateTrigger(\n workspaceId: string,\n triggerId: string,\n request: UpdateAutomationTriggerRequest,\n ): Promise<AutomationTrigger> {\n return await this.client.requestJson(\n \"PATCH\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}`,\n request,\n );\n }\n\n async disableTrigger(\n workspaceId: string,\n triggerId: string,\n expectedRevision: number,\n ): Promise<void> {\n await this.client.requestJson(\n \"DELETE\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}?expectedRevision=${expectedRevision}`,\n );\n }\n\n async listRuns(workspaceId: string): Promise<AutomationRun[]> {\n const result = await this.client.requestJson<{ runs: AutomationRun[] }>(\n \"GET\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/runs`,\n );\n return result.runs;\n }\n\n async triggerManually(\n workspaceId: string,\n sourceId: string,\n request: TriggerAutomationManuallyRequest,\n ): Promise<AutomationWebhookResult> {\n return await this.client.requestJson(\n \"POST\",\n `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}/events`,\n request,\n );\n }\n}\n"],"mappings":";AAeO,IAAM,4BAAN,MAAgC;AAAA,EACrC,YAA6B,QAAsC;AAAtC;AAAA,EAAuC;AAAA,EAEpE,MAAM,YAAY,aAAkD;AAClE,UAAM,SAAS,MAAM,KAAK,OAAO;AAAA,MAC/B;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,IACnD;AACA,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,aACJ,aACA,SAC2B;AAC3B,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,aACJ,aACA,UACA,SAC2B;AAC3B,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,wBAAwB,mBAAmB,QAAQ,CAAC;AAAA,MACrG;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,cAAc,aAAqB,UAAiC;AACxE,UAAM,KAAK,OAAO;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,wBAAwB,mBAAmB,QAAQ,CAAC;AAAA,IACvG;AAAA,EACF;AAAA,EAEA,MAAM,aAAa,aAAmD;AACpE,UAAM,SAAS,MAAM,KAAK,OAAO;AAAA,MAC/B;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,IACnD;AACA,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,cACJ,aACA,SAC4B;AAC5B,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,cACJ,aACA,WACA,SAC4B;AAC5B,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,yBAAyB,mBAAmB,SAAS,CAAC;AAAA,MACvG;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,eACJ,aACA,WACA,kBACe;AACf,UAAM,KAAK,OAAO;AAAA,MAChB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,yBAAyB,mBAAmB,SAAS,CAAC,qBAAqB,gBAAgB;AAAA,IAC9I;AAAA,EACF;AAAA,EAEA,MAAM,SAAS,aAA+C;AAC5D,UAAM,SAAS,MAAM,KAAK,OAAO;AAAA,MAC/B;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC;AAAA,IACnD;AACA,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,gBACJ,aACA,UACA,SACkC;AAClC,WAAO,MAAM,KAAK,OAAO;AAAA,MACvB;AAAA,MACA,kBAAkB,mBAAmB,WAAW,CAAC,wBAAwB,mBAAmB,QAAQ,CAAC;AAAA,MACrG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OpenGeniApiError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-C4DJPZRU.js";
|
|
4
4
|
|
|
5
5
|
// src/codex-realtime-v3-wire.ts
|
|
6
6
|
var CODEX_REALTIME_INITIAL_ITEMS_MAX_COUNT = 128;
|
|
@@ -1070,6 +1070,7 @@ var OUTBOUND_SYNC_INTERVAL_MS = 1e3;
|
|
|
1070
1070
|
var CODEX_REALTIME_NEGOTIATION_TIMEOUT_MS = 2e4;
|
|
1071
1071
|
var DEFAULT_CONNECTION_ROTATION_INTERVAL_MS = 15 * 6e4;
|
|
1072
1072
|
var DEFAULT_RECONNECT_BACKOFF_MS = [250, 1e3, 2e3, 5e3];
|
|
1073
|
+
var MAX_BROWSER_TIMEOUT_MS = 2147483647;
|
|
1073
1074
|
var OWNER_RECORD_VERSION = 1;
|
|
1074
1075
|
var OWNER_DELEGATION_REPLAY_VERSION = 1;
|
|
1075
1076
|
var OWNER_DELEGATION_REPLAY_MAX_CALLS = 4096;
|
|
@@ -1120,6 +1121,7 @@ function createCodexRealtimeController(options) {
|
|
|
1120
1121
|
);
|
|
1121
1122
|
const model = options.model ?? "gpt-live-1-boulder-alpha";
|
|
1122
1123
|
const randomUUID = options.randomUUID ?? defaultRandomUUID2;
|
|
1124
|
+
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
1123
1125
|
const scheduleInterval = options.setInterval ?? ((callback, delay) => globalThis.setInterval(callback, delay));
|
|
1124
1126
|
const unscheduleInterval = options.clearInterval ?? ((handle) => globalThis.clearInterval(handle));
|
|
1125
1127
|
const scheduleTimeout = options.setTimeout ?? ((callback, delay) => globalThis.setTimeout(callback, delay));
|
|
@@ -1160,6 +1162,7 @@ function createCodexRealtimeController(options) {
|
|
|
1160
1162
|
let rotationTimer = null;
|
|
1161
1163
|
let reconnectTimer = null;
|
|
1162
1164
|
let negotiationTimer = null;
|
|
1165
|
+
let lostOwnerExpiryTimer = null;
|
|
1163
1166
|
let closed = false;
|
|
1164
1167
|
let stopping = false;
|
|
1165
1168
|
let generation = 0;
|
|
@@ -1231,11 +1234,13 @@ function createCodexRealtimeController(options) {
|
|
|
1231
1234
|
if (rotationTimer !== null) unscheduleTimeout(rotationTimer);
|
|
1232
1235
|
if (reconnectTimer !== null) unscheduleTimeout(reconnectTimer);
|
|
1233
1236
|
if (negotiationTimer !== null) unscheduleTimeout(negotiationTimer);
|
|
1237
|
+
if (lostOwnerExpiryTimer !== null) unscheduleTimeout(lostOwnerExpiryTimer);
|
|
1234
1238
|
heartbeatTimer = null;
|
|
1235
1239
|
syncTimer = null;
|
|
1236
1240
|
rotationTimer = null;
|
|
1237
1241
|
reconnectTimer = null;
|
|
1238
1242
|
negotiationTimer = null;
|
|
1243
|
+
lostOwnerExpiryTimer = null;
|
|
1239
1244
|
};
|
|
1240
1245
|
const stopNegotiationTimers = () => {
|
|
1241
1246
|
if (heartbeatTimer !== null) unscheduleInterval(heartbeatTimer);
|
|
@@ -1902,6 +1907,12 @@ function createCodexRealtimeController(options) {
|
|
|
1902
1907
|
if (!record2 || record2.operationId !== lifecycle.operationId) {
|
|
1903
1908
|
closeBrowserResources();
|
|
1904
1909
|
owner = null;
|
|
1910
|
+
const leaseExpiresAt = Date.parse(lifecycle.leaseExpiresAt);
|
|
1911
|
+
const remainingLeaseMs = leaseExpiresAt - now().getTime();
|
|
1912
|
+
if (Number.isFinite(remainingLeaseMs) && remainingLeaseMs <= 0) {
|
|
1913
|
+
transitionEnded("Realtime lease expired");
|
|
1914
|
+
return;
|
|
1915
|
+
}
|
|
1905
1916
|
const message = "Realtime is active in another browser owner. It can resume after that owner stops or its lease expires.";
|
|
1906
1917
|
publish({
|
|
1907
1918
|
status: "lost_owner",
|
|
@@ -1911,6 +1922,15 @@ function createCodexRealtimeController(options) {
|
|
|
1911
1922
|
diagnostic: diagnostic("lost_owner", message, false),
|
|
1912
1923
|
error: message
|
|
1913
1924
|
});
|
|
1925
|
+
if (Number.isFinite(remainingLeaseMs) && remainingLeaseMs <= MAX_BROWSER_TIMEOUT_MS) {
|
|
1926
|
+
const observedRealtimeId = lifecycle.realtimeId;
|
|
1927
|
+
lostOwnerExpiryTimer = scheduleTimeout(() => {
|
|
1928
|
+
lostOwnerExpiryTimer = null;
|
|
1929
|
+
if (state.status === "lost_owner" && state.realtimeId === observedRealtimeId) {
|
|
1930
|
+
transitionEnded("Realtime lease expired");
|
|
1931
|
+
}
|
|
1932
|
+
}, remainingLeaseMs);
|
|
1933
|
+
}
|
|
1914
1934
|
return;
|
|
1915
1935
|
}
|
|
1916
1936
|
if (connectionTask || state.status === "starting") return;
|
|
@@ -2258,4 +2278,4 @@ export {
|
|
|
2258
2278
|
hasStoredSessionRealtimeOwnerProof,
|
|
2259
2279
|
createCodexRealtimeController
|
|
2260
2280
|
};
|
|
2261
|
-
//# sourceMappingURL=chunk-
|
|
2281
|
+
//# sourceMappingURL=chunk-C2H7HBNP.js.map
|