@opengeni/sdk 0.52.1 → 1.0.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 (300) hide show
  1. package/README.md +1078 -33
  2. package/dist/accounts.d.ts +153 -0
  3. package/dist/accounts.js +307 -0
  4. package/dist/accounts.js.map +1 -0
  5. package/dist/adapters/express.d.ts +31 -0
  6. package/dist/adapters/express.js +87 -0
  7. package/dist/adapters/express.js.map +1 -0
  8. package/dist/adapters/hono.d.ts +16 -0
  9. package/dist/adapters/hono.js +8 -0
  10. package/dist/adapters/hono.js.map +1 -0
  11. package/dist/adapters/next.d.ts +29 -0
  12. package/dist/adapters/next.js +22 -0
  13. package/dist/adapters/next.js.map +1 -0
  14. package/dist/allowance-refusal.d.ts +2 -0
  15. package/dist/allowance-refusal.js +50 -0
  16. package/dist/allowance-refusal.js.map +1 -0
  17. package/dist/artifact-catalog.d.ts +31 -0
  18. package/dist/artifact-client.d.ts +23 -11
  19. package/dist/artifacts.d.ts +1 -1
  20. package/dist/artifacts.js +7 -5
  21. package/dist/automations-client.d.ts +17 -0
  22. package/dist/automations.d.ts +3 -0
  23. package/dist/automations.js +84 -0
  24. package/dist/automations.js.map +1 -0
  25. package/dist/browser.d.ts +11 -0
  26. package/dist/browser.js +47 -0
  27. package/dist/browser.js.map +1 -0
  28. package/dist/chat/fold.d.ts +75 -0
  29. package/dist/chat/handler.d.ts +41 -0
  30. package/dist/chat/http.d.ts +67 -0
  31. package/dist/chat/ids.d.ts +34 -0
  32. package/dist/chat/index.d.ts +9 -0
  33. package/dist/chat/index.js +1694 -0
  34. package/dist/chat/index.js.map +1 -0
  35. package/dist/chat/openai.d.ts +30 -0
  36. package/dist/chat/opengeni.d.ts +128 -0
  37. package/dist/chat/types.d.ts +207 -0
  38. package/dist/chat/vercel.d.ts +49 -0
  39. package/dist/chats.d.ts +8 -0
  40. package/dist/{chunk-KIHGPM7H.js → chunk-2UXZUCEZ.js} +309 -46
  41. package/dist/chunk-2UXZUCEZ.js.map +1 -0
  42. package/dist/chunk-4SMEOV3P.js +246 -0
  43. package/dist/chunk-4SMEOV3P.js.map +1 -0
  44. package/dist/{chunk-FHI4DFIG.js → chunk-AH5D5Q5V.js} +31 -35
  45. package/dist/chunk-AH5D5Q5V.js.map +1 -0
  46. package/dist/chunk-APXVSSSY.js +301 -0
  47. package/dist/chunk-APXVSSSY.js.map +1 -0
  48. package/dist/chunk-DUVIYER4.js +639 -0
  49. package/dist/chunk-DUVIYER4.js.map +1 -0
  50. package/dist/{chunk-ILQZR5N6.js → chunk-FG3OO5LM.js} +3484 -750
  51. package/dist/chunk-FG3OO5LM.js.map +1 -0
  52. package/dist/chunk-GZYZT22T.js +260 -0
  53. package/dist/chunk-GZYZT22T.js.map +1 -0
  54. package/dist/chunk-HMGADJGZ.js +150 -0
  55. package/dist/chunk-HMGADJGZ.js.map +1 -0
  56. package/dist/{chunk-DXDL7EEW.js → chunk-KWADQ227.js} +198 -114
  57. package/dist/chunk-KWADQ227.js.map +1 -0
  58. package/dist/chunk-LY2K6ELJ.js +126 -0
  59. package/dist/chunk-LY2K6ELJ.js.map +1 -0
  60. package/dist/chunk-MOTJYIYL.js +340 -0
  61. package/dist/chunk-MOTJYIYL.js.map +1 -0
  62. package/dist/{chunk-MZWTWOX6.js → chunk-NC57YMUO.js} +447 -3
  63. package/dist/chunk-NC57YMUO.js.map +1 -0
  64. package/dist/chunk-RWKB6YZG.js +1270 -0
  65. package/dist/chunk-RWKB6YZG.js.map +1 -0
  66. package/dist/chunk-U6CV2SXO.js +195 -0
  67. package/dist/chunk-U6CV2SXO.js.map +1 -0
  68. package/dist/chunk-UM4ZXXJR.js +9 -0
  69. package/dist/chunk-UM4ZXXJR.js.map +1 -0
  70. package/dist/chunk-V6GIY62B.js +229 -0
  71. package/dist/chunk-V6GIY62B.js.map +1 -0
  72. package/dist/chunk-WU6GQG25.js +268 -0
  73. package/dist/chunk-WU6GQG25.js.map +1 -0
  74. package/dist/{chunk-VWE2QIVO.js → chunk-XNG7YGR3.js} +23 -6
  75. package/dist/chunk-XNG7YGR3.js.map +1 -0
  76. package/dist/{chunk-FRJFNDIR.js → chunk-YIKA2QT4.js} +37 -2
  77. package/dist/chunk-YIKA2QT4.js.map +1 -0
  78. package/dist/chunk-ZKPY6YAJ.js +135 -0
  79. package/dist/chunk-ZKPY6YAJ.js.map +1 -0
  80. package/dist/client.d.ts +843 -107
  81. package/dist/codex-realtime-controller.d.ts +6 -0
  82. package/dist/codex-realtime-controller.js +2 -2
  83. package/dist/codex-realtime-v3.d.ts +13 -2
  84. package/dist/company-brain.d.ts +22 -0
  85. package/dist/company-profile.d.ts +14 -1
  86. package/dist/core.d.ts +9 -3
  87. package/dist/core.js +28 -9
  88. package/dist/deprecation.d.ts +47 -0
  89. package/dist/desktop.d.ts +8 -0
  90. package/dist/document-authority-client.d.ts +51 -0
  91. package/dist/document-authority.d.ts +2 -0
  92. package/dist/document-authority.js +12 -0
  93. package/dist/document-authority.js.map +1 -0
  94. package/dist/editable-artifacts/browser-session.d.ts +7 -3
  95. package/dist/editable-artifacts/controller.d.ts +4 -1
  96. package/dist/editable-artifacts/errors.d.ts +1 -1
  97. package/dist/editable-artifacts/http-live-transport.d.ts +6 -2
  98. package/dist/editable-artifacts/index.d.ts +2 -0
  99. package/dist/editable-artifacts/open-failure.d.ts +9 -0
  100. package/dist/editable-artifacts/types.d.ts +6 -3
  101. package/dist/editable-artifacts/worker/kernel-adapter.d.ts +1 -1
  102. package/dist/editable-artifacts-worker.js +44 -17
  103. package/dist/editable-artifacts-worker.js.map +1 -1
  104. package/dist/editable-artifacts.js +243 -124
  105. package/dist/editable-artifacts.js.map +1 -1
  106. package/dist/embedding-client.d.ts +129 -0
  107. package/dist/errors.d.ts +36 -1
  108. package/dist/feedback.d.ts +23 -0
  109. package/dist/gateway-realtime-transport.d.ts +1 -0
  110. package/dist/gateway-realtime-transport.js +5 -3
  111. package/dist/github-repositories.d.ts +10 -0
  112. package/dist/github-repositories.js +36 -0
  113. package/dist/github-repositories.js.map +1 -0
  114. package/dist/index.d.ts +61 -12
  115. package/dist/index.js +277 -126
  116. package/dist/index.js.map +1 -1
  117. package/dist/interaction-revision-stream.d.ts +11 -0
  118. package/dist/interaction.d.ts +687 -5
  119. package/dist/interaction.js +32 -1
  120. package/dist/knowledge.d.ts +7 -0
  121. package/dist/knowledge.js +20 -0
  122. package/dist/knowledge.js.map +1 -0
  123. package/dist/message-links.d.ts +68 -0
  124. package/dist/model-context.d.ts +68 -0
  125. package/dist/model-display.d.ts +2 -0
  126. package/dist/model-display.js +15 -0
  127. package/dist/model-display.js.map +1 -0
  128. package/dist/model-picker-order.d.ts +1 -0
  129. package/dist/model-picker-order.js +10 -0
  130. package/dist/model-picker-order.js.map +1 -0
  131. package/dist/organization-integration-policy.d.ts +26 -0
  132. package/dist/organization-integration-policy.js +26 -0
  133. package/dist/organization-integration-policy.js.map +1 -0
  134. package/dist/organization-private-session-settings.d.ts +6 -0
  135. package/dist/organization-private-session-settings.js +22 -0
  136. package/dist/organization-private-session-settings.js.map +1 -0
  137. package/dist/organization-user-setup.d.ts +8 -0
  138. package/dist/organization-user-setup.js +16 -0
  139. package/dist/organization-user-setup.js.map +1 -0
  140. package/dist/pr-review-client.d.ts +16 -0
  141. package/dist/pr-review.d.ts +4 -0
  142. package/dist/pr-review.js +62 -0
  143. package/dist/pr-review.js.map +1 -0
  144. package/dist/preference-registry.d.ts +9 -1
  145. package/dist/proxy.d.ts +7 -5
  146. package/dist/realtime.d.ts +6 -4
  147. package/dist/realtime.js +10 -6
  148. package/dist/realtime.js.map +1 -1
  149. package/dist/retained-artifacts.d.ts +5 -1
  150. package/dist/session-history-import.d.ts +22 -0
  151. package/dist/session-history-import.js +36 -0
  152. package/dist/session-history-import.js.map +1 -0
  153. package/dist/session-list-entries.d.ts +1 -0
  154. package/dist/session-list-entries.js +7 -0
  155. package/dist/session-list-entries.js.map +1 -0
  156. package/dist/session-message-search.d.ts +53 -0
  157. package/dist/session-proxy-client.d.ts +24 -0
  158. package/dist/session-proxy.d.ts +245 -0
  159. package/dist/session-proxy.js +24 -0
  160. package/dist/session-proxy.js.map +1 -0
  161. package/dist/session-titles.d.ts +2 -0
  162. package/dist/site-browser-entry.d.ts +1 -0
  163. package/dist/site-browser-runtime.gen.d.ts +1 -0
  164. package/dist/site-document.d.ts +5 -0
  165. package/dist/site-document.js +20 -0
  166. package/dist/site-document.js.map +1 -0
  167. package/dist/site-document.test.d.ts +1 -0
  168. package/dist/site-http.d.ts +16 -0
  169. package/dist/site-tool-bridge.d.ts +44 -0
  170. package/dist/site.d.ts +101 -0
  171. package/dist/site.js +49 -0
  172. package/dist/site.js.map +1 -0
  173. package/dist/skills.d.ts +75 -0
  174. package/dist/stream.d.ts +2 -0
  175. package/dist/tenant-workspaces.d.ts +47 -0
  176. package/dist/tenant-workspaces.js +8 -0
  177. package/dist/tenant-workspaces.js.map +1 -0
  178. package/dist/tool-auth.d.ts +87 -0
  179. package/dist/tool-auth.js +23 -0
  180. package/dist/tool-auth.js.map +1 -0
  181. package/dist/tool-display-metadata.d.ts +3 -0
  182. package/dist/tools-FXBLUWAE.js +12 -0
  183. package/dist/tools-FXBLUWAE.js.map +1 -0
  184. package/dist/tools.d.ts +61 -0
  185. package/dist/types.d.ts +3048 -406
  186. package/dist/usage-allowances.d.ts +36 -0
  187. package/dist/usage-allowances.js +80 -0
  188. package/dist/usage-allowances.js.map +1 -0
  189. package/dist/workspace-artifacts.d.ts +33 -5
  190. package/dist/workspace-instruction-policies.d.ts +24 -2
  191. package/dist/workspace-integrations.d.ts +74 -0
  192. package/dist/workspace-integrations.js +65 -0
  193. package/dist/workspace-integrations.js.map +1 -0
  194. package/dist/workspace-learning.d.ts +124 -0
  195. package/dist/workspace-live-stream.d.ts +14 -0
  196. package/dist/workspace-state.d.ts +8 -71
  197. package/package.json +108 -3
  198. package/src/accounts.ts +443 -0
  199. package/src/adapters/express.ts +136 -0
  200. package/src/adapters/hono.ts +18 -0
  201. package/src/adapters/next.ts +42 -0
  202. package/src/allowance-refusal.ts +5 -0
  203. package/src/artifact-catalog.ts +41 -0
  204. package/src/artifact-client.ts +43 -52
  205. package/src/artifacts.ts +7 -1
  206. package/src/automations-client.ts +124 -0
  207. package/src/automations.ts +15 -0
  208. package/src/browser.ts +54 -0
  209. package/src/chat/fold.ts +431 -0
  210. package/src/chat/handler.ts +240 -0
  211. package/src/chat/http.ts +257 -0
  212. package/src/chat/ids.ts +85 -0
  213. package/src/chat/index.ts +87 -0
  214. package/src/chat/openai.ts +439 -0
  215. package/src/chat/opengeni.ts +722 -0
  216. package/src/chat/types.ts +219 -0
  217. package/src/chat/vercel.ts +204 -0
  218. package/src/chats.ts +16 -0
  219. package/src/client.ts +5162 -792
  220. package/src/codex-realtime-controller.ts +260 -12
  221. package/src/codex-realtime-lifecycle.ts +1 -0
  222. package/src/codex-realtime-v3.ts +162 -31
  223. package/src/codex-realtime.ts +1 -1
  224. package/src/company-brain.ts +59 -0
  225. package/src/company-profile.ts +17 -1
  226. package/src/core.ts +23 -1
  227. package/src/deprecation.ts +149 -0
  228. package/src/desktop.ts +11 -1
  229. package/src/document-authority-client.ts +219 -0
  230. package/src/document-authority.ts +17 -0
  231. package/src/editable-artifacts/browser-session.ts +36 -22
  232. package/src/editable-artifacts/controller.ts +102 -47
  233. package/src/editable-artifacts/errors.ts +2 -0
  234. package/src/editable-artifacts/http-live-transport.ts +62 -37
  235. package/src/editable-artifacts/index.ts +6 -0
  236. package/src/editable-artifacts/open-failure.ts +79 -0
  237. package/src/editable-artifacts/storage.ts +31 -40
  238. package/src/editable-artifacts/types.ts +6 -3
  239. package/src/editable-artifacts/worker/kernel-adapter.ts +23 -7
  240. package/src/editable-artifacts/worker/runtime.ts +26 -13
  241. package/src/editable-artifacts/worker/wire-codec.ts +23 -5
  242. package/src/embedding-client.ts +519 -0
  243. package/src/errors.ts +185 -4
  244. package/src/feedback.ts +20 -0
  245. package/src/gateway-realtime-transport.ts +253 -110
  246. package/src/github-repositories.ts +60 -0
  247. package/src/index.ts +603 -54
  248. package/src/interaction-revision-stream.ts +117 -0
  249. package/src/interaction.ts +1367 -51
  250. package/src/knowledge.ts +72 -0
  251. package/src/message-links.ts +178 -0
  252. package/src/model-context.ts +112 -0
  253. package/src/model-display.ts +10 -0
  254. package/src/model-picker-order.ts +6 -0
  255. package/src/organization-integration-policy.ts +54 -0
  256. package/src/organization-private-session-settings.ts +33 -0
  257. package/src/organization-user-setup.ts +31 -0
  258. package/src/pr-review-client.ts +92 -0
  259. package/src/pr-review.ts +17 -0
  260. package/src/preference-registry.ts +11 -0
  261. package/src/proxy.ts +17 -6
  262. package/src/realtime.ts +15 -4
  263. package/src/retained-artifacts.ts +101 -0
  264. package/src/session-history-import.ts +84 -0
  265. package/src/session-list-entries.ts +1 -0
  266. package/src/session-message-search.ts +47 -0
  267. package/src/session-proxy-client.ts +64 -0
  268. package/src/session-proxy.ts +1473 -0
  269. package/src/session-titles.ts +10 -0
  270. package/src/site-browser-entry.ts +6 -0
  271. package/src/site-browser-runtime.gen.ts +2 -0
  272. package/src/site-document.test.ts +64 -0
  273. package/src/site-document.ts +18 -0
  274. package/src/site-http.ts +162 -0
  275. package/src/site-tool-bridge.ts +146 -0
  276. package/src/site.ts +585 -0
  277. package/src/skills.ts +69 -0
  278. package/src/sse.ts +8 -2
  279. package/src/stream.ts +38 -4
  280. package/src/tenant-workspaces.ts +148 -0
  281. package/src/tool-auth.ts +301 -0
  282. package/src/tool-display-metadata.ts +19 -0
  283. package/src/tools.ts +396 -0
  284. package/src/types.ts +3607 -493
  285. package/src/usage-allowances.ts +189 -0
  286. package/src/workspace-artifacts.ts +40 -6
  287. package/src/workspace-instruction-policies.ts +26 -1
  288. package/src/workspace-integrations.ts +402 -0
  289. package/src/workspace-learning.ts +138 -0
  290. package/src/workspace-live-stream.ts +137 -0
  291. package/src/workspace-state.ts +8 -82
  292. package/dist/chunk-DXDL7EEW.js.map +0 -1
  293. package/dist/chunk-FHI4DFIG.js.map +0 -1
  294. package/dist/chunk-FRJFNDIR.js.map +0 -1
  295. package/dist/chunk-ILQZR5N6.js.map +0 -1
  296. package/dist/chunk-KIHGPM7H.js.map +0 -1
  297. package/dist/chunk-MZWTWOX6.js.map +0 -1
  298. package/dist/chunk-V5F253OG.js +0 -116
  299. package/dist/chunk-V5F253OG.js.map +0 -1
  300. package/dist/chunk-VWE2QIVO.js.map +0 -1
@@ -0,0 +1,72 @@
1
+ export type {
2
+ AgentLearningMode,
3
+ AgentLearningCategory,
4
+ AgentLearningDefaults,
5
+ AgentLearningOverrides,
6
+ AgentLearningContext,
7
+ AgentLearningOverridePatch,
8
+ AgentLearningSettingsRecord,
9
+ AgentLearningOverrideRecord,
10
+ SaveAgentLearningSettingsRequest,
11
+ KnowledgeFilePreparationResult,
12
+ KnowledgeSavePreparationRequest,
13
+ KnowledgeSavePreparationResponse,
14
+ KnowledgeOriginalFileDownload,
15
+ KnowledgeEntryKind,
16
+ KnowledgeEntryScope,
17
+ KnowledgeIndexStatus,
18
+ KnowledgeEntryContent,
19
+ KnowledgeEntrySource,
20
+ KnowledgeEntryEvidence,
21
+ KnowledgeEntryRelationship,
22
+ KnowledgeEntryRecord,
23
+ KnowledgeEntrySummary,
24
+ KnowledgeEntrySaveRequest,
25
+ KnowledgeEntryReviewRequest,
26
+ KnowledgeEntryBatchReviewRequest,
27
+ KnowledgeEntryRestoreRequest,
28
+ KnowledgeEntryWriteReceipt,
29
+ KnowledgeEntryListRequest,
30
+ KnowledgeEntryListResponse,
31
+ KnowledgeReviewBatch,
32
+ KnowledgeReviewBatchListRequest,
33
+ KnowledgeReviewBatchListResponse,
34
+ AgentInstructionReviewRequest,
35
+ AgentInstructionReceipt,
36
+ AgentInstructionReviewItem,
37
+ AgentInstructionReviewListResponse,
38
+ } from "@opengeni/contracts";
39
+
40
+ import type { OpenGeniClient } from "./client";
41
+ import type {
42
+ KnowledgeSavePreparationRequest,
43
+ KnowledgeSavePreparationResponse,
44
+ KnowledgeFilePreparationResult,
45
+ } from "@opengeni/contracts";
46
+
47
+ /** Agent-only source preparation is a focused transport surface, outside the browser client. */
48
+ export async function prepareKnowledgeFile(
49
+ client: Pick<OpenGeniClient, "requestJson">,
50
+ workspaceId: string,
51
+ fileId: string,
52
+ purpose?: "evidence" | "reference",
53
+ ): Promise<KnowledgeFilePreparationResult> {
54
+ return client.requestJson(
55
+ "POST",
56
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/knowledge/files/${encodeURIComponent(fileId)}/prepare`,
57
+ purpose ? { purpose } : undefined,
58
+ );
59
+ }
60
+
61
+ /** Read-only collection/duplicate discovery for a live selected agent or human Knowledge reviewer. */
62
+ export async function prepareKnowledgeSave(
63
+ client: Pick<OpenGeniClient, "requestJson">,
64
+ workspaceId: string,
65
+ request: KnowledgeSavePreparationRequest,
66
+ ): Promise<KnowledgeSavePreparationResponse> {
67
+ return client.requestJson(
68
+ "POST",
69
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/knowledge/entries/prepare-save`,
70
+ request,
71
+ );
72
+ }
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Links an agent writes into chat Markdown that point at OpenGeni-owned objects.
3
+ *
4
+ * Agents write these forms (tool receipts and bundled Skills teach them):
5
+ *
6
+ * - `artifact:<file uuid>` — a retained workspace file (exports, published files, images).
7
+ * - `sandbox:<path>[:<line>]` — a file in the session's sandbox or Connected Machine.
8
+ * - `/workspaces/<ws>/artifacts/editable/<32-hex id>` — a live editable document,
9
+ * workbook, or presentation.
10
+ * - `/workspaces/<ws>/artifacts/<uuid>` — a saved Site / published HTML artifact.
11
+ * - `/workspaces/<ws>/artifacts/files/<uuid>` — a retained file (console path form).
12
+ *
13
+ * None of them is a URL a browser can navigate on its own: the `/workspaces/...`
14
+ * forms are OpenGeni console routes, so inside another product they resolve
15
+ * against that product's origin and 404. Parse them with {@link parseOpenGeniLink}
16
+ * and route each target to the host's own UI (download, panel, page).
17
+ */
18
+ export type OpenGeniLinkTarget =
19
+ | { kind: "file"; fileId: string; workspaceId: string | null; fromSession?: string }
20
+ | { kind: "editable-artifact"; artifactId: string; workspaceId: string; fromSession?: string }
21
+ | { kind: "site"; artifactId: string; workspaceId: string; fromSession?: string }
22
+ | { kind: "sandbox-file"; path: string; line: number | null };
23
+
24
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
25
+ const EDITABLE_ID = /^[0-9a-f]{32}$/iu;
26
+ const WORKSPACE_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u;
27
+ const SANDBOX_SCHEME = "sandbox:";
28
+ const LEGACY_WORKSPACE_PREFIX = "/workspace/";
29
+ const TRAILING_LINE = /:([0-9]+)$/u;
30
+ const TRAILING_INVALID_LINE = /:-(?:[0-9]+)$|:[0-9]+-[0-9]+$/u;
31
+ const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/u;
32
+
33
+ /** Application scheme names are case-insensitive, unlike their payloads. */
34
+ export function openGeniLinkScheme(href: string | undefined): "artifact" | "sandbox" | null {
35
+ const scheme = /^([a-z]+):/iu.exec(href ?? "")?.[1]?.toLowerCase();
36
+ return scheme === "artifact" || scheme === "sandbox" ? scheme : null;
37
+ }
38
+
39
+ /** Reserved references must never fall back to navigation on a host origin. */
40
+ export function isReservedOpenGeniLink(href: string | undefined): boolean {
41
+ if (!href) return false;
42
+ if (openGeniLinkScheme(href) || href.startsWith(LEGACY_WORKSPACE_PREFIX)) return true;
43
+ // Decoding is for reservation only: encoded variants are not valid targets.
44
+ try {
45
+ return /^\/workspaces\/[^/]+\/artifacts(?:\/|[?#]|$)/u.test(decodeURIComponent(href));
46
+ } catch {
47
+ return /^\/workspaces\/[^/]+\/artifacts/u.test(href);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Parse an OpenGeni `sandbox:` href (plus the historical bare `/workspace/...`
53
+ * form). The decoded path is intentionally opaque: target selection, path
54
+ * policy, and filesystem authority belong to the session-aware host.
55
+ */
56
+ export function parseSandboxLink(
57
+ href: string | undefined,
58
+ ): { path: string; line: number | null } | null {
59
+ if (!href) return null;
60
+ const encodedLocation =
61
+ openGeniLinkScheme(href) === "sandbox"
62
+ ? href.slice(SANDBOX_SCHEME.length)
63
+ : href.startsWith(LEGACY_WORKSPACE_PREFIX)
64
+ ? href
65
+ : null;
66
+ if (!encodedLocation || encodedLocation.includes("?") || encodedLocation.includes("#")) {
67
+ return null;
68
+ }
69
+ if (TRAILING_INVALID_LINE.test(encodedLocation)) return null;
70
+ const lineMatch = TRAILING_LINE.exec(encodedLocation);
71
+ const encodedPath = lineMatch ? encodedLocation.slice(0, -lineMatch[0].length) : encodedLocation;
72
+ const line = lineMatch?.[1] ? Number(lineMatch[1]) : null;
73
+ if (line !== null && (!Number.isSafeInteger(line) || line < 1)) return null;
74
+ if (!encodedPath) return null;
75
+ try {
76
+ const path = decodeURIComponent(encodedPath);
77
+ return path && !CONTROL_CHARACTER.test(path) ? { path, line } : null;
78
+ } catch {
79
+ return null;
80
+ }
81
+ }
82
+
83
+ /** Return the retained-file id of an exact `artifact:<uuid>` reference. */
84
+ export function parseRetainedFileReference(href: string | undefined): string | null {
85
+ if (openGeniLinkScheme(href) !== "artifact") return null;
86
+ if (!href) return null;
87
+ const id = href.slice("artifact:".length);
88
+ return UUID.test(id) ? id.toLowerCase() : null;
89
+ }
90
+
91
+ /**
92
+ * Classify an agent-authored Markdown href. Returns `null` for ordinary links
93
+ * (`https://…`, `mailto:`, relative host links), which render as-is.
94
+ *
95
+ * Only root-relative console paths are recognized; an absolute URL is always an
96
+ * ordinary link, so a host's own `https://` routes are never reinterpreted.
97
+ * A validated `?fromSession=<uuid>` return hint is preserved.
98
+ */
99
+ export function parseOpenGeniLink(href: string | undefined): OpenGeniLinkTarget | null {
100
+ if (!href) return null;
101
+ const fileId = parseRetainedFileReference(href);
102
+ if (fileId) return { kind: "file", fileId, workspaceId: null };
103
+ if (openGeniLinkScheme(href) === "sandbox" || href.startsWith(LEGACY_WORKSPACE_PREFIX)) {
104
+ const location = parseSandboxLink(href);
105
+ return location ? { kind: "sandbox-file", ...location } : null;
106
+ }
107
+ if (!href.startsWith("/workspaces/") || href.includes("#")) return null;
108
+ const separator = href.indexOf("?");
109
+ const pathname = separator < 0 ? href : href.slice(0, separator);
110
+ const search = separator < 0 ? undefined : href.slice(separator + 1);
111
+ let fromSession: string | undefined;
112
+ if (search !== undefined) {
113
+ const params = new URLSearchParams(search);
114
+ const keys = [...params.keys()];
115
+ if (keys.some((key) => key !== "fromSession") || keys.length > 1) return null;
116
+ if (!UUID.test(params.get("fromSession") ?? "")) return null;
117
+ fromSession = params.get("fromSession")!.toLowerCase();
118
+ }
119
+ const parts = pathname.split("/");
120
+ const workspaceId = parts[2] ?? "";
121
+ if (parts[1] !== "workspaces" || parts[3] !== "artifacts" || !WORKSPACE_SEGMENT.test(workspaceId))
122
+ return null;
123
+ if (parts.length === 6 && parts[4] === "editable" && EDITABLE_ID.test(parts[5] ?? "")) {
124
+ return {
125
+ kind: "editable-artifact",
126
+ artifactId: parts[5]!.toLowerCase(),
127
+ workspaceId,
128
+ ...(fromSession ? { fromSession } : {}),
129
+ };
130
+ }
131
+ if (parts.length === 6 && parts[4] === "files" && UUID.test(parts[5] ?? "")) {
132
+ return {
133
+ kind: "file",
134
+ fileId: parts[5]!.toLowerCase(),
135
+ workspaceId,
136
+ ...(fromSession ? { fromSession } : {}),
137
+ };
138
+ }
139
+ if (parts.length === 5 && UUID.test(parts[4] ?? "")) {
140
+ return {
141
+ kind: "site",
142
+ artifactId: parts[4]!.toLowerCase(),
143
+ workspaceId,
144
+ ...(fromSession ? { fromSession } : {}),
145
+ };
146
+ }
147
+ return null;
148
+ }
149
+
150
+ /** The OpenGeni console route for a target (the form agents write). */
151
+ export function openGeniConsolePath(
152
+ target: OpenGeniLinkTarget,
153
+ workspaceId: string,
154
+ ): string | null {
155
+ const workspace = encodeURIComponent(
156
+ target.kind === "sandbox-file" ? workspaceId : (target.workspaceId ?? workspaceId),
157
+ );
158
+ const search =
159
+ target.kind !== "sandbox-file" && target.fromSession && UUID.test(target.fromSession)
160
+ ? `?fromSession=${encodeURIComponent(target.fromSession)}`
161
+ : "";
162
+ switch (target.kind) {
163
+ case "file":
164
+ return `/workspaces/${workspace}/artifacts/files/${target.fileId}${search}`;
165
+ case "editable-artifact":
166
+ return `/workspaces/${workspace}/artifacts/editable/${target.artifactId}${search}`;
167
+ case "site":
168
+ return `/workspaces/${workspace}/artifacts/${target.artifactId}${search}`;
169
+ case "sandbox-file":
170
+ return null;
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Request header naming the session an embedded artifact read belongs to.
176
+ * `createSessionProxyHandler` only serves artifacts OpenGeni lists for it.
177
+ */
178
+ export const SESSION_SCOPE_HEADER = "x-opengeni-session-id";
@@ -0,0 +1,112 @@
1
+ export type ModelContextInstructionLayerId =
2
+ | "operational_contract"
3
+ | "persona_and_core"
4
+ | "workspace_governance"
5
+ | "session_instructions"
6
+ | "workspace_memory"
7
+ | "skill_catalog"
8
+ | "codemode"
9
+ | "code_search"
10
+ | "git_bindings"
11
+ | "builtin_skills"
12
+ | "genesis_title"
13
+ | "sdk_capability_instructions"
14
+ | "sandbox_preamble"
15
+ | "sandbox_filesystem"
16
+ | "sent_system_instructions"
17
+ | "identity";
18
+
19
+ /** Sections of a modular operational contract, in composition order. */
20
+ export type AgentPromptModuleId =
21
+ | "base_behavior"
22
+ | "runtime_mechanics"
23
+ | "renderer_markdown"
24
+ | "sandbox"
25
+ | "connected_machine"
26
+ | "repositories"
27
+ | "workspace_environment"
28
+ | "rig"
29
+ | "artifacts"
30
+ | "media"
31
+ | "goals"
32
+ | "subagents"
33
+ | "knowledge"
34
+ | "skills"
35
+ | "admin"
36
+ | "attachments";
37
+
38
+ export type ModelContextInstructionModule = {
39
+ id: AgentPromptModuleId;
40
+ chars: number;
41
+ };
42
+
43
+ export type ModelContextInstructionLayer = {
44
+ id: ModelContextInstructionLayerId;
45
+ title: string;
46
+ content: string;
47
+ utf8Bytes: number;
48
+ estimatedTokens: number;
49
+ /** Present on the operational contract of sessions with an agent configuration. */
50
+ modules?: ModelContextInstructionModule[] | undefined;
51
+ };
52
+
53
+ export type ModelContextToolVisibility = "eager" | "searchable";
54
+
55
+ export type ModelContextTool = {
56
+ name: string;
57
+ type: string;
58
+ visibility: ModelContextToolVisibility;
59
+ description?: string | undefined;
60
+ namespace?: string | undefined;
61
+ schema?: unknown | undefined;
62
+ utf8Bytes: number;
63
+ estimatedTokens: number;
64
+ };
65
+
66
+ export type ModelContextSkillKind = "preference_descriptor" | "runtime_skill" | "native_tool_skill";
67
+
68
+ export type ModelContextSkill = {
69
+ kind: ModelContextSkillKind;
70
+ name: string;
71
+ description: string;
72
+ source?: string | undefined;
73
+ path?: string | undefined;
74
+ };
75
+
76
+ export type ModelContextTokenCounts = {
77
+ instructions: number;
78
+ tools: number;
79
+ prefix: number;
80
+ };
81
+
82
+ export type ModelContextSnapshot = {
83
+ providerRequest?:
84
+ | {
85
+ provider: string;
86
+ body: string | null;
87
+ unavailableReason?: string | undefined;
88
+ parts: {
89
+ key: string;
90
+ estimatedTokens: number | null;
91
+ utf8Bytes: number;
92
+ itemEstimatedTokens?: (number | null)[] | undefined;
93
+ }[];
94
+ }
95
+ | undefined;
96
+ version: 1;
97
+ capturedAt: string;
98
+ source: "model_request";
99
+ requestIndex: number;
100
+ instructions: string;
101
+ layers: ModelContextInstructionLayer[];
102
+ tools: ModelContextTool[];
103
+ skills: ModelContextSkill[];
104
+ tokens: ModelContextTokenCounts;
105
+ };
106
+
107
+ export type SessionModelContextResponse = {
108
+ sessionId: string;
109
+ attemptId: string | null;
110
+ turnId: string | null;
111
+ snapshot: ModelContextSnapshot | null;
112
+ };
@@ -0,0 +1,10 @@
1
+ /** One clean model name and maker for every surface outside model settings. */
2
+ export {
3
+ humanizeModelSlug,
4
+ isRawModelLabel,
5
+ modelDisplayName,
6
+ modelSlug,
7
+ modelVendor,
8
+ type ModelDisplayInput,
9
+ type ModelVendor,
10
+ } from "@opengeni/contracts/model-display";
@@ -0,0 +1,6 @@
1
+ export {
2
+ compareModelPickerOrder,
3
+ modelPickerBillingClassFor,
4
+ type ModelPickerBillingCandidate,
5
+ type ModelPickerBillingClass,
6
+ } from "@opengeni/contracts/model-picker-order";
@@ -0,0 +1,54 @@
1
+ import type { OpenGeniClient } from "./client";
2
+
3
+ export type OrganizationIntegrationPolicy = {
4
+ mode: "unrestricted" | "restricted";
5
+ allowedIntegrationKeys: string[];
6
+ revision: number;
7
+ };
8
+
9
+ export type UpdateOrganizationIntegrationPolicyRequest = {
10
+ mode: "unrestricted" | "restricted";
11
+ allowedIntegrationKeys: string[];
12
+ expectedRevision: number;
13
+ operationId: string;
14
+ };
15
+
16
+ type PolicyClient = Pick<OpenGeniClient, "requestJson">;
17
+
18
+ export type OrganizationIntegrationCatalog = {
19
+ integrations: Array<{ key: string; label: string; kind: "curated" | "custom" }>;
20
+ };
21
+
22
+ /** Discover stable policy identities; integrations must not guess provider identifiers. */
23
+ export async function getOrganizationIntegrationCatalog(
24
+ client: PolicyClient,
25
+ organizationId: string,
26
+ ): Promise<OrganizationIntegrationCatalog> {
27
+ return client.requestJson(
28
+ "GET",
29
+ `/v1/organizations/${encodeURIComponent(organizationId)}/integration-policy/catalog`,
30
+ );
31
+ }
32
+
33
+ export async function getOrganizationIntegrationPolicy(
34
+ client: PolicyClient,
35
+ organizationId: string,
36
+ ): Promise<OrganizationIntegrationPolicy> {
37
+ return client.requestJson(
38
+ "GET",
39
+ `/v1/organizations/${encodeURIComponent(organizationId)}/integration-policy`,
40
+ );
41
+ }
42
+
43
+ /** Retain operationId and the exact request when reconciling an uncertain outcome. */
44
+ export async function updateOrganizationIntegrationPolicy(
45
+ client: PolicyClient,
46
+ organizationId: string,
47
+ request: UpdateOrganizationIntegrationPolicyRequest,
48
+ ): Promise<OrganizationIntegrationPolicy> {
49
+ return client.requestJson(
50
+ "PUT",
51
+ `/v1/organizations/${encodeURIComponent(organizationId)}/integration-policy`,
52
+ request,
53
+ );
54
+ }
@@ -0,0 +1,33 @@
1
+ import type { OpenGeniClient } from "./client";
2
+ import type {
3
+ OrganizationPrivateSessionSettings,
4
+ UpdateOrganizationPrivateSessionSettingsRequest,
5
+ } from "./types";
6
+
7
+ type OrganizationPrivateSessionSettingsClient = Pick<OpenGeniClient, "requestJson">;
8
+
9
+ function settingsPath(organizationId: string): string {
10
+ return `/v1/organizations/${organizationId}/private-session-settings`;
11
+ }
12
+
13
+ export async function getOrganizationPrivateSessionSettings(
14
+ client: OrganizationPrivateSessionSettingsClient,
15
+ organizationId: string,
16
+ ): Promise<OrganizationPrivateSessionSettings> {
17
+ return await client.requestJson<OrganizationPrivateSessionSettings>(
18
+ "GET",
19
+ settingsPath(organizationId),
20
+ );
21
+ }
22
+
23
+ export async function updateOrganizationPrivateSessionSettings(
24
+ client: OrganizationPrivateSessionSettingsClient,
25
+ organizationId: string,
26
+ request: UpdateOrganizationPrivateSessionSettingsRequest,
27
+ ): Promise<OrganizationPrivateSessionSettings> {
28
+ return await client.requestJson<OrganizationPrivateSessionSettings>(
29
+ "PATCH",
30
+ settingsPath(organizationId),
31
+ request,
32
+ );
33
+ }
@@ -0,0 +1,31 @@
1
+ import type { OpenGeniClient } from "./client";
2
+ import type {
3
+ OrganizationUserSetupDelivery,
4
+ OrganizationUserSetupPreview,
5
+ PreviewOrganizationUserSetupRequest,
6
+ RetryOrganizationUserSetupDeliveryRequest,
7
+ } from "./types";
8
+
9
+ type OrganizationUserSetupClient = Pick<OpenGeniClient, "requestJson">;
10
+
11
+ /** Safe signed-out projection of the exact organization role and shared access in a setup link. */
12
+ export function previewOrganizationUserSetup(
13
+ client: OrganizationUserSetupClient,
14
+ request: PreviewOrganizationUserSetupRequest,
15
+ ): Promise<OrganizationUserSetupPreview> {
16
+ return client.requestJson("POST", "/v1/auth/organization-setup/preview", request);
17
+ }
18
+
19
+ /** Retry a failed or explicitly outcome-unknown delivery with its stable provider key. */
20
+ export function retryOrganizationUserSetupDelivery(
21
+ client: OrganizationUserSetupClient,
22
+ organizationId: string,
23
+ invitationId: string,
24
+ request: RetryOrganizationUserSetupDeliveryRequest,
25
+ ): Promise<OrganizationUserSetupDelivery> {
26
+ return client.requestJson(
27
+ "POST",
28
+ `/v1/organizations/${organizationId}/invitations/${invitationId}/delivery/retry`,
29
+ request,
30
+ );
31
+ }
@@ -0,0 +1,92 @@
1
+ import type { OpenGeniClient as OpenGeniCoreClient } from "./client";
2
+ import type {
3
+ CreatePrReviewAppRegistrationRequest,
4
+ CreatePrReviewRepositoryBindingRequest,
5
+ PrReviewAppRegistration,
6
+ PrReviewRepositoryBinding,
7
+ ListPrReviewConfigurationResponse,
8
+ PrReviewManagedGitHubSetup,
9
+ UpdatePrReviewAppRegistrationRequest,
10
+ UpdatePrReviewRepositoryBindingRequest,
11
+ } from "./types";
12
+
13
+ export type OpenGeniPrReviewTransport = Pick<OpenGeniCoreClient, "requestJson" | "requestVoid">;
14
+
15
+ /** Optional OpenGeni Review Bot API surface, isolated from the eager core client graph. */
16
+ export class OpenGeniPrReviewClient {
17
+ constructor(private readonly client: OpenGeniPrReviewTransport) {}
18
+
19
+ async listConfiguration(workspaceId: string): Promise<ListPrReviewConfigurationResponse> {
20
+ return await this.client.requestJson<ListPrReviewConfigurationResponse>(
21
+ "GET",
22
+ `/v1/workspaces/${workspaceId}/pr-review/registrations`,
23
+ );
24
+ }
25
+
26
+ async getManagedGitHubSetup(workspaceId: string): Promise<PrReviewManagedGitHubSetup> {
27
+ return await this.client.requestJson<PrReviewManagedGitHubSetup>(
28
+ "GET",
29
+ `/v1/workspaces/${workspaceId}/pr-review/github`,
30
+ );
31
+ }
32
+
33
+ async createAppRegistration(
34
+ workspaceId: string,
35
+ request: CreatePrReviewAppRegistrationRequest,
36
+ ): Promise<PrReviewAppRegistration> {
37
+ return await this.client.requestJson<PrReviewAppRegistration>(
38
+ "POST",
39
+ `/v1/workspaces/${workspaceId}/pr-review/registrations`,
40
+ request,
41
+ );
42
+ }
43
+
44
+ async updateAppRegistration(
45
+ workspaceId: string,
46
+ registrationId: string,
47
+ request: UpdatePrReviewAppRegistrationRequest,
48
+ ): Promise<PrReviewAppRegistration> {
49
+ return await this.client.requestJson<PrReviewAppRegistration>(
50
+ "PATCH",
51
+ `/v1/workspaces/${workspaceId}/pr-review/registrations/${encodeURIComponent(registrationId)}`,
52
+ request,
53
+ );
54
+ }
55
+
56
+ async deleteAppRegistration(workspaceId: string, registrationId: string): Promise<void> {
57
+ await this.client.requestVoid(
58
+ "DELETE",
59
+ `/v1/workspaces/${workspaceId}/pr-review/registrations/${encodeURIComponent(registrationId)}`,
60
+ );
61
+ }
62
+
63
+ async createRepositoryBinding(
64
+ workspaceId: string,
65
+ request: CreatePrReviewRepositoryBindingRequest,
66
+ ): Promise<PrReviewRepositoryBinding> {
67
+ return await this.client.requestJson<PrReviewRepositoryBinding>(
68
+ "POST",
69
+ `/v1/workspaces/${workspaceId}/pr-review/repositories`,
70
+ request,
71
+ );
72
+ }
73
+
74
+ async updateRepositoryBinding(
75
+ workspaceId: string,
76
+ bindingId: string,
77
+ request: UpdatePrReviewRepositoryBindingRequest,
78
+ ): Promise<PrReviewRepositoryBinding> {
79
+ return await this.client.requestJson<PrReviewRepositoryBinding>(
80
+ "PATCH",
81
+ `/v1/workspaces/${workspaceId}/pr-review/repositories/${encodeURIComponent(bindingId)}`,
82
+ request,
83
+ );
84
+ }
85
+
86
+ async deleteRepositoryBinding(workspaceId: string, bindingId: string): Promise<void> {
87
+ await this.client.requestVoid(
88
+ "DELETE",
89
+ `/v1/workspaces/${workspaceId}/pr-review/repositories/${encodeURIComponent(bindingId)}`,
90
+ );
91
+ }
92
+ }
@@ -0,0 +1,17 @@
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
+ PrReviewManagedGitHubInstallation,
11
+ PrReviewManagedGitHubSetup,
12
+ PrReviewRepositoryBinding,
13
+ PrReviewWebhookAuthKind,
14
+ ListPrReviewConfigurationResponse,
15
+ UpdatePrReviewAppRegistrationRequest,
16
+ UpdatePrReviewRepositoryBindingRequest,
17
+ } from "./types";
@@ -10,6 +10,8 @@ export type PreferenceRegistryProvenanceSource =
10
10
  | "human"
11
11
  | "onboarding"
12
12
  | "knowledge_proposal"
13
+ | "agent"
14
+ | "portable_skill"
13
15
  | "imported_document"
14
16
  | "slack"
15
17
  | "meeting_transcript"
@@ -101,6 +103,8 @@ export type PreferenceRegistryEvent = {
101
103
  createdAt: string;
102
104
  };
103
105
 
106
+ export type PreferenceRegistryActivationAuthority = "human_confirmed" | "automatic";
107
+
104
108
  export type PreferenceRegistryDescriptor = {
105
109
  id: string;
106
110
  stableKey: string;
@@ -112,6 +116,13 @@ export type PreferenceRegistryDescriptor = {
112
116
  contentHash: string;
113
117
  precedence: PreferenceRegistryPrecedence;
114
118
  provenance: PreferenceRegistryDescriptorProvenance;
119
+ /**
120
+ * How the active revision became active. `provenance.trust` stays the frozen
121
+ * creation-time fact; this is the separate activation question. Null when the
122
+ * revision became active outside governed learning, or when the descriptor
123
+ * predates this field.
124
+ */
125
+ activationAuthority: PreferenceRegistryActivationAuthority | null;
115
126
  expiresAt: string | null;
116
127
  retrievalHandle: string;
117
128
  };