@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.
Files changed (92) hide show
  1. package/README.md +117 -2
  2. package/dist/artifacts.js +5 -5
  3. package/dist/automations-client.d.ts +17 -0
  4. package/dist/automations.d.ts +3 -0
  5. package/dist/automations.js +78 -0
  6. package/dist/automations.js.map +1 -0
  7. package/dist/{chunk-A5DC5WEM.js → chunk-C2H7HBNP.js} +22 -2
  8. package/dist/chunk-C2H7HBNP.js.map +1 -0
  9. package/dist/{chunk-GU6JF75T.js → chunk-C4DJPZRU.js} +1 -1
  10. package/dist/{chunk-GU6JF75T.js.map → chunk-C4DJPZRU.js.map} +1 -1
  11. package/dist/{chunk-TYZ4JL4J.js → chunk-G6LBVWKT.js} +2 -2
  12. package/dist/{chunk-4DV37UUA.js → chunk-GLDV5QY7.js} +16 -2
  13. package/dist/chunk-GLDV5QY7.js.map +1 -0
  14. package/dist/{chunk-ST5DDKJP.js → chunk-GW3EJ2GP.js} +52 -1
  15. package/dist/chunk-GW3EJ2GP.js.map +1 -0
  16. package/dist/{chunk-VWE2QIVO.js → chunk-XNG7YGR3.js} +23 -6
  17. package/dist/chunk-XNG7YGR3.js.map +1 -0
  18. package/dist/{chunk-YGH5P47G.js → chunk-YBQTKNTL.js} +696 -57
  19. package/dist/chunk-YBQTKNTL.js.map +1 -0
  20. package/dist/client.d.ts +151 -26
  21. package/dist/codex-realtime-controller.d.ts +1 -0
  22. package/dist/codex-realtime-controller.js +2 -2
  23. package/dist/company-brain.d.ts +32 -0
  24. package/dist/company-profile.d.ts +1 -1
  25. package/dist/core.js +4 -4
  26. package/dist/editable-artifacts/browser-session.d.ts +7 -3
  27. package/dist/editable-artifacts/controller.d.ts +4 -1
  28. package/dist/editable-artifacts/errors.d.ts +1 -1
  29. package/dist/editable-artifacts/http-live-transport.d.ts +6 -2
  30. package/dist/editable-artifacts/index.d.ts +2 -0
  31. package/dist/editable-artifacts/open-failure.d.ts +9 -0
  32. package/dist/editable-artifacts/types.d.ts +4 -3
  33. package/dist/editable-artifacts/worker/kernel-adapter.d.ts +1 -1
  34. package/dist/editable-artifacts-worker.js +44 -17
  35. package/dist/editable-artifacts-worker.js.map +1 -1
  36. package/dist/editable-artifacts.js +222 -119
  37. package/dist/editable-artifacts.js.map +1 -1
  38. package/dist/errors.d.ts +1 -1
  39. package/dist/index.d.ts +7 -4
  40. package/dist/index.js +61 -12
  41. package/dist/index.js.map +1 -1
  42. package/dist/interaction.d.ts +23 -0
  43. package/dist/interaction.js +4 -1
  44. package/dist/organization-private-session-settings.d.ts +6 -0
  45. package/dist/organization-private-session-settings.js +22 -0
  46. package/dist/organization-private-session-settings.js.map +1 -0
  47. package/dist/pr-review-client.d.ts +15 -0
  48. package/dist/pr-review.d.ts +4 -0
  49. package/dist/pr-review.js +56 -0
  50. package/dist/pr-review.js.map +1 -0
  51. package/dist/preference-registry.d.ts +8 -0
  52. package/dist/realtime.js +2 -2
  53. package/dist/retained-artifacts.d.ts +5 -1
  54. package/dist/types.d.ts +961 -13
  55. package/dist/workspace-instruction-policies.d.ts +22 -0
  56. package/dist/workspace-learning.d.ts +124 -0
  57. package/package.json +14 -2
  58. package/src/automations-client.ts +118 -0
  59. package/src/automations.ts +15 -0
  60. package/src/client.ts +974 -71
  61. package/src/codex-realtime-controller.ts +21 -0
  62. package/src/company-brain.ts +99 -0
  63. package/src/company-profile.ts +4 -1
  64. package/src/editable-artifacts/browser-session.ts +36 -22
  65. package/src/editable-artifacts/controller.ts +66 -45
  66. package/src/editable-artifacts/errors.ts +2 -0
  67. package/src/editable-artifacts/http-live-transport.ts +62 -37
  68. package/src/editable-artifacts/index.ts +6 -0
  69. package/src/editable-artifacts/open-failure.ts +79 -0
  70. package/src/editable-artifacts/storage.ts +31 -40
  71. package/src/editable-artifacts/types.ts +4 -3
  72. package/src/editable-artifacts/worker/kernel-adapter.ts +23 -7
  73. package/src/editable-artifacts/worker/runtime.ts +26 -13
  74. package/src/editable-artifacts/worker/wire-codec.ts +23 -5
  75. package/src/errors.ts +1 -1
  76. package/src/index.ts +131 -0
  77. package/src/interaction.ts +95 -0
  78. package/src/organization-private-session-settings.ts +33 -0
  79. package/src/pr-review-client.ts +84 -0
  80. package/src/pr-review.ts +15 -0
  81. package/src/preference-registry.ts +9 -0
  82. package/src/retained-artifacts.ts +101 -0
  83. package/src/stream.ts +13 -2
  84. package/src/types.ts +1101 -12
  85. package/src/workspace-instruction-policies.ts +24 -0
  86. package/src/workspace-learning.ts +138 -0
  87. package/dist/chunk-4DV37UUA.js.map +0 -1
  88. package/dist/chunk-A5DC5WEM.js.map +0 -1
  89. package/dist/chunk-ST5DDKJP.js.map +0 -1
  90. package/dist/chunk-VWE2QIVO.js.map +0 -1
  91. package/dist/chunk-YGH5P47G.js.map +0 -1
  92. /package/dist/{chunk-TYZ4JL4J.js.map → chunk-G6LBVWKT.js.map} +0 -0
@@ -36,6 +36,11 @@ export type WorkspaceInstructionPolicyHead = WorkspaceInstructionPolicyTarget &
36
36
  activationVersion: number;
37
37
  activatedAt: string;
38
38
  };
39
+ export type WorkspaceInstructionPolicyInactiveHead = WorkspaceInstructionPolicyTarget & {
40
+ workspaceId: string;
41
+ activationVersion: number;
42
+ deactivatedAt: string;
43
+ };
39
44
  export type WorkspaceInstructionPolicyActivationEvent = WorkspaceInstructionPolicyTarget & {
40
45
  id: string;
41
46
  operationId: string;
@@ -49,6 +54,18 @@ export type WorkspaceInstructionPolicyActivationEvent = WorkspaceInstructionPoli
49
54
  reason: string;
50
55
  createdAt: string;
51
56
  };
57
+ export type WorkspaceInstructionPolicyDeactivationEvent = WorkspaceInstructionPolicyTarget & {
58
+ id: string;
59
+ operationId: string;
60
+ accountId: string;
61
+ workspaceId: string;
62
+ type: "automatic_deactivate";
63
+ activationVersion: number;
64
+ oldRevision: WorkspaceInstructionPolicyRevisionIdentity;
65
+ actorSubjectId: string;
66
+ reason: string;
67
+ createdAt: string;
68
+ };
52
69
  export type CreateWorkspaceInstructionPolicyDraftRequest = WorkspaceInstructionPolicyTarget & {
53
70
  operationId?: string;
54
71
  content: string;
@@ -70,7 +87,12 @@ export type WorkspaceInstructionPolicyListOptions = {
70
87
  export type WorkspaceInstructionPolicyListResponse = {
71
88
  revisions: WorkspaceInstructionPolicyRevision[];
72
89
  activeHeads: WorkspaceInstructionPolicyHead[];
90
+ /** Additive current inactive target boundaries; absent on pre-controller servers. */
91
+ inactiveHeads?: WorkspaceInstructionPolicyInactiveHead[];
92
+ inactiveHeadsTruncated?: boolean;
73
93
  activationEvents: WorkspaceInstructionPolicyActivationEvent[];
94
+ /** Additive lifecycle history; absent on pre-controller servers. */
95
+ deactivationEvents?: WorkspaceInstructionPolicyDeactivationEvent[];
74
96
  nextAfterRevision: number | null;
75
97
  };
76
98
  export type WorkspaceInstructionPolicyDiffRequest = {
@@ -0,0 +1,124 @@
1
+ export type WorkspaceLearningMode = "off" | "suggest" | "automatic";
2
+ export type WorkspaceLearningOverrideMode = WorkspaceLearningMode | "inherit";
3
+ export type WorkspaceLearningSourceOverrideInput = {
4
+ kind: string;
5
+ id: string;
6
+ mode: WorkspaceLearningOverrideMode;
7
+ };
8
+ export type WorkspaceLearningSourceOverride = Omit<WorkspaceLearningSourceOverrideInput, "mode"> & {
9
+ mode: WorkspaceLearningMode;
10
+ };
11
+ export type WorkspaceLearningPolicyRevisionIdentity = {
12
+ id: string;
13
+ revision: number;
14
+ policyHash: string;
15
+ };
16
+ export type WorkspaceLearningPolicyRevision = WorkspaceLearningPolicyRevisionIdentity & {
17
+ operationId: string;
18
+ accountId: string;
19
+ workspaceId: string;
20
+ workspaceMode: WorkspaceLearningMode;
21
+ sourceOverrides: WorkspaceLearningSourceOverride[];
22
+ supersedesRevisionId: string | null;
23
+ createdBySubjectId: string;
24
+ createdAt: string;
25
+ };
26
+ export type WorkspaceLearningPolicyHead = Omit<WorkspaceLearningPolicyRevisionIdentity, "id"> & {
27
+ accountId: string;
28
+ workspaceId: string;
29
+ revisionId: string;
30
+ activationVersion: number;
31
+ activatedAt: string;
32
+ };
33
+ export type WorkspaceLearningPolicyEvent = {
34
+ id: string;
35
+ operationId: string;
36
+ accountId: string;
37
+ workspaceId: string;
38
+ type: "activate" | "rollback";
39
+ activationVersion: number;
40
+ oldRevision: WorkspaceLearningPolicyRevisionIdentity | null;
41
+ newRevision: WorkspaceLearningPolicyRevisionIdentity;
42
+ actorSubjectId: string;
43
+ reason: string;
44
+ createdAt: string;
45
+ };
46
+ export type GovernedLearningDecisionReceipt = {
47
+ id: string;
48
+ sourceKind: "scoped-knowledge-evidence" | "task-note";
49
+ sourceId: string;
50
+ proposalId: string;
51
+ policySnapshotId: string;
52
+ policyRevisionId: string | null;
53
+ policyActivationVersion: number;
54
+ effectiveMode: WorkspaceLearningMode;
55
+ confidenceBps: number;
56
+ conflictCount: number;
57
+ outcome: "off" | "suggest" | "automatic" | "confidence" | "conflict" | "stale" | "revoked";
58
+ reasons: string[];
59
+ automaticEligible: boolean;
60
+ createdAt: string;
61
+ };
62
+ export type GovernedLearningActivationReceipt = {
63
+ id: string;
64
+ decisionReceiptId: string;
65
+ initiatingHumanSubjectId: string;
66
+ serviceActorSubjectId: string;
67
+ sourceKind: "scoped-knowledge-evidence" | "task-note";
68
+ sourceId: string;
69
+ destination: "instruction_policy" | "preference";
70
+ destinationRevisionId: string;
71
+ destinationOldRevisionId: string | null;
72
+ destinationOldContentHash: string | null;
73
+ destinationOldVersion: number;
74
+ destinationNewContentHash: string;
75
+ destinationNewVersion: number;
76
+ effectiveAt: string;
77
+ createdAt: string;
78
+ };
79
+ export type GovernedLearningActivationUndoReceipt = {
80
+ id: string;
81
+ activationReceiptId: string;
82
+ initiatingHumanSubjectId: string;
83
+ serviceActorSubjectId: string;
84
+ destination: "instruction_policy" | "preference";
85
+ destinationActivatedRevisionId: string;
86
+ destinationRestoredRevisionId: string | null;
87
+ destinationOldVersion: number;
88
+ destinationNewVersion: number;
89
+ effectiveAt: string;
90
+ createdAt: string;
91
+ };
92
+ export type WorkspaceLearningHistoryResponse = {
93
+ head: WorkspaceLearningPolicyHead | null;
94
+ revisions: WorkspaceLearningPolicyRevision[];
95
+ policyEvents: WorkspaceLearningPolicyEvent[];
96
+ decisions: GovernedLearningDecisionReceipt[];
97
+ activations: GovernedLearningActivationReceipt[];
98
+ undos: GovernedLearningActivationUndoReceipt[];
99
+ truncated: boolean;
100
+ effectiveBoundary: "next_accepted_attempt";
101
+ };
102
+ export type CreateWorkspaceLearningPolicyRevisionRequest = {
103
+ operationId?: string;
104
+ workspaceMode: WorkspaceLearningMode;
105
+ sourceOverrides?: WorkspaceLearningSourceOverrideInput[];
106
+ supersedesRevisionId?: string | null;
107
+ };
108
+ export type ActivateWorkspaceLearningPolicyRevisionRequest = {
109
+ operationId?: string;
110
+ expectedCurrentRevisionId: string | null;
111
+ expectedActivationVersion: number;
112
+ reason: string;
113
+ };
114
+ export type RollbackWorkspaceLearningPolicyRevisionRequest = ActivateWorkspaceLearningPolicyRevisionRequest & {
115
+ targetRevisionId: string;
116
+ expectedCurrentRevisionId: string;
117
+ };
118
+ export type WorkspaceLearningPolicyMutationResponse = {
119
+ head: WorkspaceLearningPolicyHead;
120
+ event: WorkspaceLearningPolicyEvent;
121
+ };
122
+ export type WorkspaceLearningHistoryOptions = {
123
+ limit?: number;
124
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/sdk",
3
- "version": "1.0.1",
3
+ "version": "2.2.0-canary.0",
4
4
  "description": "Framework-agnostic TypeScript SDK for the OpenGeni API: typed client, session lifecycle, SSE event streaming with reconnect + replay-by-sequence, and proxy re-streaming helpers.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -38,6 +38,18 @@
38
38
  "types": "./dist/memory-slack.d.ts",
39
39
  "import": "./dist/memory-slack.js"
40
40
  },
41
+ "./automations": {
42
+ "types": "./dist/automations.d.ts",
43
+ "import": "./dist/automations.js"
44
+ },
45
+ "./pr-review": {
46
+ "types": "./dist/pr-review.d.ts",
47
+ "import": "./dist/pr-review.js"
48
+ },
49
+ "./organization-private-session-settings": {
50
+ "types": "./dist/organization-private-session-settings.d.ts",
51
+ "import": "./dist/organization-private-session-settings.js"
52
+ },
41
53
  "./realtime": {
42
54
  "types": "./dist/realtime.d.ts",
43
55
  "import": "./dist/realtime.js"
@@ -73,7 +85,7 @@
73
85
  "prepublishOnly": "bash ../../scripts/prepublish-guard"
74
86
  },
75
87
  "dependencies": {
76
- "@opengeni/contracts": "^1.0.1"
88
+ "@opengeni/contracts": "^2.2.0-canary.0"
77
89
  },
78
90
  "engines": {
79
91
  "node": ">=18"
@@ -0,0 +1,118 @@
1
+ import type {
2
+ AutomationRun,
3
+ AutomationSource,
4
+ AutomationTrigger,
5
+ AutomationWebhookResult,
6
+ CreateAutomationSourceRequest,
7
+ CreateAutomationTriggerRequest,
8
+ TriggerAutomationManuallyRequest,
9
+ UpdateAutomationSourceRequest,
10
+ UpdateAutomationTriggerRequest,
11
+ } from "@opengeni/contracts";
12
+ import type { OpenGeniClient as OpenGeniCoreClient } from "./client";
13
+
14
+ export type OpenGeniAutomationsTransport = Pick<OpenGeniCoreClient, "requestJson">;
15
+
16
+ export class OpenGeniAutomationsClient {
17
+ constructor(private readonly client: OpenGeniAutomationsTransport) {}
18
+
19
+ async listSources(workspaceId: string): Promise<AutomationSource[]> {
20
+ const result = await this.client.requestJson<{ sources: AutomationSource[] }>(
21
+ "GET",
22
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`,
23
+ );
24
+ return result.sources;
25
+ }
26
+
27
+ async createSource(
28
+ workspaceId: string,
29
+ request: CreateAutomationSourceRequest,
30
+ ): Promise<AutomationSource> {
31
+ return await this.client.requestJson(
32
+ "POST",
33
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources`,
34
+ request,
35
+ );
36
+ }
37
+
38
+ async updateSource(
39
+ workspaceId: string,
40
+ sourceId: string,
41
+ request: UpdateAutomationSourceRequest,
42
+ ): Promise<AutomationSource> {
43
+ return await this.client.requestJson(
44
+ "PATCH",
45
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,
46
+ request,
47
+ );
48
+ }
49
+
50
+ async disableSource(workspaceId: string, sourceId: string): Promise<void> {
51
+ await this.client.requestJson(
52
+ "DELETE",
53
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}`,
54
+ );
55
+ }
56
+
57
+ async listTriggers(workspaceId: string): Promise<AutomationTrigger[]> {
58
+ const result = await this.client.requestJson<{ triggers: AutomationTrigger[] }>(
59
+ "GET",
60
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`,
61
+ );
62
+ return result.triggers;
63
+ }
64
+
65
+ async createTrigger(
66
+ workspaceId: string,
67
+ request: CreateAutomationTriggerRequest,
68
+ ): Promise<AutomationTrigger> {
69
+ return await this.client.requestJson(
70
+ "POST",
71
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers`,
72
+ request,
73
+ );
74
+ }
75
+
76
+ async updateTrigger(
77
+ workspaceId: string,
78
+ triggerId: string,
79
+ request: UpdateAutomationTriggerRequest,
80
+ ): Promise<AutomationTrigger> {
81
+ return await this.client.requestJson(
82
+ "PATCH",
83
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}`,
84
+ request,
85
+ );
86
+ }
87
+
88
+ async disableTrigger(
89
+ workspaceId: string,
90
+ triggerId: string,
91
+ expectedRevision: number,
92
+ ): Promise<void> {
93
+ await this.client.requestJson(
94
+ "DELETE",
95
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/triggers/${encodeURIComponent(triggerId)}?expectedRevision=${expectedRevision}`,
96
+ );
97
+ }
98
+
99
+ async listRuns(workspaceId: string): Promise<AutomationRun[]> {
100
+ const result = await this.client.requestJson<{ runs: AutomationRun[] }>(
101
+ "GET",
102
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/runs`,
103
+ );
104
+ return result.runs;
105
+ }
106
+
107
+ async triggerManually(
108
+ workspaceId: string,
109
+ sourceId: string,
110
+ request: TriggerAutomationManuallyRequest,
111
+ ): Promise<AutomationWebhookResult> {
112
+ return await this.client.requestJson(
113
+ "POST",
114
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/automations/sources/${encodeURIComponent(sourceId)}/events`,
115
+ request,
116
+ );
117
+ }
118
+ }
@@ -0,0 +1,15 @@
1
+ export { OpenGeniAutomationsClient } from "./automations-client";
2
+ export type { OpenGeniAutomationsTransport } from "./automations-client";
3
+ export type {
4
+ AutomationAcceptedExecution,
5
+ AutomationNormalizedEvent,
6
+ AutomationRun,
7
+ AutomationSource,
8
+ AutomationTrigger,
9
+ AutomationWebhookResult,
10
+ CreateAutomationSourceRequest,
11
+ CreateAutomationTriggerRequest,
12
+ TriggerAutomationManuallyRequest,
13
+ UpdateAutomationSourceRequest,
14
+ UpdateAutomationTriggerRequest,
15
+ } from "@opengeni/contracts";