@opengeni/sdk 3.3.2-canary.1 → 3.4.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 +1007 -72
- package/dist/adapters/express.d.ts +31 -0
- package/dist/adapters/express.js +87 -0
- package/dist/adapters/express.js.map +1 -0
- package/dist/adapters/hono.d.ts +16 -0
- package/dist/adapters/hono.js +8 -0
- package/dist/adapters/hono.js.map +1 -0
- package/dist/adapters/next.d.ts +29 -0
- package/dist/adapters/next.js +22 -0
- package/dist/adapters/next.js.map +1 -0
- package/dist/allowance-refusal.d.ts +2 -0
- package/dist/allowance-refusal.js +50 -0
- package/dist/allowance-refusal.js.map +1 -0
- package/dist/app-links.d.ts +42 -0
- package/dist/app-links.js +66 -0
- package/dist/app-links.js.map +1 -0
- package/dist/artifact-catalog.d.ts +40 -0
- package/dist/artifact-client.d.ts +20 -8
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +8 -6
- package/dist/automations.js +8 -2
- package/dist/automations.js.map +1 -1
- package/dist/azure-live-transport.d.ts +32 -0
- package/dist/browser.d.ts +6 -2
- package/dist/browser.js +25 -5
- package/dist/chat/fold.d.ts +75 -0
- package/dist/chat/handler.d.ts +41 -0
- package/dist/chat/http.d.ts +67 -0
- package/dist/chat/ids.d.ts +34 -0
- package/dist/chat/index.d.ts +9 -0
- package/dist/chat/index.js +1369 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/openai.d.ts +30 -0
- package/dist/chat/opengeni.d.ts +129 -0
- package/dist/chat/types.d.ts +207 -0
- package/dist/chat/vercel.d.ts +49 -0
- package/dist/chats.d.ts +8 -0
- package/dist/chunk-4AHR4KGA.js +301 -0
- package/dist/chunk-4AHR4KGA.js.map +1 -0
- package/dist/chunk-6GYGMLX4.js +332 -0
- package/dist/chunk-6GYGMLX4.js.map +1 -0
- package/dist/chunk-7EWT3PV6.js +368 -0
- package/dist/chunk-7EWT3PV6.js.map +1 -0
- package/dist/chunk-FTWVVPR6.js +1665 -0
- package/dist/chunk-FTWVVPR6.js.map +1 -0
- package/dist/{chunk-VYCTL62C.js → chunk-GZQSWAKD.js} +1 -1
- package/dist/chunk-GZQSWAKD.js.map +1 -0
- package/dist/chunk-KGEABAID.js +71 -0
- package/dist/chunk-KGEABAID.js.map +1 -0
- package/dist/{chunk-YKZME56C.js → chunk-KWADQ227.js} +3 -3
- package/dist/{chunk-YKZME56C.js.map → chunk-KWADQ227.js.map} +1 -1
- package/dist/{chunk-E5BNEG2D.js → chunk-NCU5OAN7.js} +27 -2
- package/dist/chunk-NCU5OAN7.js.map +1 -0
- package/dist/{chunk-BESZFWMU.js → chunk-OI5YLASH.js} +73 -2
- package/dist/chunk-OI5YLASH.js.map +1 -0
- package/dist/chunk-OV3POE62.js +359 -0
- package/dist/chunk-OV3POE62.js.map +1 -0
- package/dist/chunk-P7UWKORG.js +561 -0
- package/dist/chunk-P7UWKORG.js.map +1 -0
- package/dist/chunk-QGEIL4TR.js +195 -0
- package/dist/chunk-QGEIL4TR.js.map +1 -0
- package/dist/{chunk-GY6RQPCG.js → chunk-S2NLS3ES.js} +3598 -1278
- package/dist/chunk-S2NLS3ES.js.map +1 -0
- package/dist/chunk-UM4ZXXJR.js +9 -0
- package/dist/chunk-UM4ZXXJR.js.map +1 -0
- package/dist/{chunk-TFCLHRZK.js → chunk-UME3X7CP.js} +28 -32
- package/dist/chunk-UME3X7CP.js.map +1 -0
- package/dist/chunk-VT4YM4XQ.js +210 -0
- package/dist/chunk-VT4YM4XQ.js.map +1 -0
- package/dist/chunk-WSYYXONG.js +1602 -0
- package/dist/chunk-WSYYXONG.js.map +1 -0
- package/dist/{chunk-6NEPJ7NC.js → chunk-WVCJRSGJ.js} +119 -14
- package/dist/chunk-WVCJRSGJ.js.map +1 -0
- package/dist/chunk-X5ITQVXE.js +15 -0
- package/dist/chunk-X5ITQVXE.js.map +1 -0
- package/dist/chunk-XA7HVIHI.js +126 -0
- package/dist/chunk-XA7HVIHI.js.map +1 -0
- package/dist/{chunk-QTBAMHEF.js → chunk-YJCHB7R3.js} +60 -12
- package/dist/chunk-YJCHB7R3.js.map +1 -0
- package/dist/chunk-YKIHNLWD.js +153 -0
- package/dist/chunk-YKIHNLWD.js.map +1 -0
- package/dist/chunk-ZDUBPV33.js +277 -0
- package/dist/chunk-ZDUBPV33.js.map +1 -0
- package/dist/client.d.ts +1056 -118
- package/dist/codex-realtime-controller.d.ts +13 -0
- package/dist/codex-realtime-controller.js +4 -2
- package/dist/codex-realtime-v3-wire.d.ts +3 -2
- package/dist/codex-realtime.d.ts +5 -1
- package/dist/company-brain.d.ts +1 -11
- package/dist/core.d.ts +6 -2
- package/dist/core.js +23 -6
- package/dist/deprecation.d.ts +47 -0
- package/dist/document-authority-client.d.ts +24 -2
- package/dist/document-authority.js +7 -5
- package/dist/editable-artifacts/index.d.ts +1 -1
- package/dist/editable-artifacts/types.d.ts +12 -2
- package/dist/editable-artifacts.js +19 -3
- package/dist/editable-artifacts.js.map +1 -1
- package/dist/embedding-client.d.ts +129 -0
- package/dist/errors.d.ts +64 -1
- package/dist/external-vault-receiver.d.ts +203 -0
- package/dist/external-vault-receiver.js +564 -0
- package/dist/external-vault-receiver.js.map +1 -0
- package/dist/feedback.d.ts +23 -0
- package/dist/gateway-realtime-transport.js +1 -1
- package/dist/github-repositories.d.ts +10 -0
- package/dist/github-repositories.js +36 -0
- package/dist/github-repositories.js.map +1 -0
- package/dist/index.d.ts +61 -11
- package/dist/index.js +555 -338
- package/dist/index.js.map +1 -1
- package/dist/insights-usage.d.ts +33 -0
- package/dist/insights-usage.js +7 -0
- package/dist/insights-usage.js.map +1 -0
- package/dist/interaction.d.ts +165 -71
- package/dist/interaction.js +2 -2
- package/dist/knowledge.d.ts +7 -0
- package/dist/knowledge.js +20 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/known-tools.d.ts +4 -0
- package/dist/message-links.d.ts +68 -0
- package/dist/model-context.d.ts +68 -0
- package/dist/model-display.d.ts +2 -0
- package/dist/model-display.js +17 -0
- package/dist/model-display.js.map +1 -0
- package/dist/organization-integration-policy.d.ts +26 -0
- package/dist/organization-integration-policy.js +26 -0
- package/dist/organization-integration-policy.js.map +1 -0
- package/dist/pr-review-client.d.ts +1 -1
- package/dist/pr-review.d.ts +1 -1
- package/dist/pr-review.js.map +1 -1
- package/dist/preference-registry.d.ts +1 -1
- package/dist/prepared-mcp-setup.d.ts +5 -0
- package/dist/proxy.d.ts +13 -11
- package/dist/realtime.d.ts +1 -1
- package/dist/realtime.js +253 -7
- package/dist/realtime.js.map +1 -1
- package/dist/session-history-import.d.ts +22 -0
- package/dist/session-history-import.js +36 -0
- package/dist/session-history-import.js.map +1 -0
- package/dist/session-list-entries.d.ts +1 -0
- package/dist/session-list-entries.js +7 -0
- package/dist/session-list-entries.js.map +1 -0
- package/dist/session-message-search.d.ts +53 -0
- package/dist/session-proxy-client.d.ts +28 -0
- package/dist/session-proxy.d.ts +334 -0
- package/dist/session-proxy.js +24 -0
- package/dist/session-proxy.js.map +1 -0
- package/dist/session-titles.d.ts +2 -28
- package/dist/session-usage-limits.d.ts +10 -0
- package/dist/session-usage-limits.js +43 -0
- package/dist/session-usage-limits.js.map +1 -0
- package/dist/shared-catalog-loader.d.ts +34 -0
- package/dist/site-ai.d.ts +35 -0
- package/dist/site-bridge-host.d.ts +112 -0
- package/dist/site-bridge-host.js +286 -0
- package/dist/site-bridge-host.js.map +1 -0
- package/dist/site-browser-entry.d.ts +1 -0
- package/dist/site-browser-runtime.gen.d.ts +1 -0
- package/dist/site-data.d.ts +178 -0
- package/dist/site-document.d.ts +5 -0
- package/dist/site-document.js +20 -0
- package/dist/site-document.js.map +1 -0
- package/dist/site-document.test.d.ts +1 -0
- package/dist/site-http.d.ts +17 -0
- package/dist/site-sql.d.ts +31 -0
- package/dist/site-tool-bridge.d.ts +57 -0
- package/dist/site.d.ts +186 -0
- package/dist/site.js +63 -0
- package/dist/site.js.map +1 -0
- package/dist/skills.d.ts +75 -0
- package/dist/sse.d.ts +1 -1
- package/dist/stream.d.ts +2 -0
- package/dist/tenant-workspaces.d.ts +47 -0
- package/dist/tenant-workspaces.js +8 -0
- package/dist/tenant-workspaces.js.map +1 -0
- package/dist/tool-auth.d.ts +87 -0
- package/dist/tool-auth.js +23 -0
- package/dist/tool-auth.js.map +1 -0
- package/dist/tool-display-metadata.d.ts +3 -0
- package/dist/tools-37DCTCNZ.js +12 -0
- package/dist/tools-37DCTCNZ.js.map +1 -0
- package/dist/tools.d.ts +81 -0
- package/dist/transcription.d.ts +1 -1
- package/dist/types.d.ts +2785 -592
- package/dist/usage-allowances.d.ts +36 -0
- package/dist/usage-allowances.js +80 -0
- package/dist/usage-allowances.js.map +1 -0
- package/dist/vault-types.d.ts +324 -0
- package/dist/vaults-api.d.ts +65 -0
- package/dist/workspace-artifacts.d.ts +47 -5
- package/dist/workspace-instruction-policies.d.ts +2 -2
- package/dist/workspace-integrations.d.ts +74 -0
- package/dist/workspace-integrations.js +67 -0
- package/dist/workspace-integrations.js.map +1 -0
- package/dist/workspace-state.d.ts +8 -71
- package/package.json +99 -5
- package/src/adapters/express.ts +136 -0
- package/src/adapters/hono.ts +18 -0
- package/src/adapters/next.ts +42 -0
- package/src/allowance-refusal.ts +5 -0
- package/src/app-links.ts +117 -0
- package/src/artifact-catalog.ts +51 -0
- package/src/artifact-client.ts +40 -49
- package/src/artifacts.ts +1 -0
- package/src/automations-client.ts +8 -2
- package/src/azure-live-transport.ts +286 -0
- package/src/browser.ts +35 -0
- package/src/chat/fold.ts +431 -0
- package/src/chat/handler.ts +240 -0
- package/src/chat/http.ts +257 -0
- package/src/chat/ids.ts +85 -0
- package/src/chat/index.ts +88 -0
- package/src/chat/openai.ts +439 -0
- package/src/chat/opengeni.ts +737 -0
- package/src/chat/types.ts +219 -0
- package/src/chat/vercel.ts +204 -0
- package/src/chats.ts +16 -0
- package/src/client.ts +5595 -1847
- package/src/codex-realtime-controller.ts +163 -8
- package/src/codex-realtime-v3-wire.ts +4 -3
- package/src/codex-realtime-v3.ts +12 -3
- package/src/codex-realtime.ts +11 -3
- package/src/company-brain.ts +0 -40
- package/src/core.ts +18 -0
- package/src/deprecation.ts +149 -0
- package/src/document-authority-client.ts +104 -1
- package/src/editable-artifacts/controller.ts +36 -2
- package/src/editable-artifacts/index.ts +1 -0
- package/src/editable-artifacts/types.ts +29 -16
- package/src/embedding-client.ts +519 -0
- package/src/errors.ts +281 -5
- package/src/external-vault-receiver.ts +914 -0
- package/src/feedback.ts +20 -0
- package/src/gateway-realtime-transport.ts +3 -3
- package/src/github-repositories.ts +60 -0
- package/src/index.ts +592 -65
- package/src/insights-usage.ts +64 -0
- package/src/interaction.ts +315 -93
- package/src/knowledge.ts +72 -0
- package/src/known-tools.ts +279 -0
- package/src/message-links.ts +178 -0
- package/src/model-context.ts +113 -0
- package/src/model-display.ts +11 -0
- package/src/organization-integration-policy.ts +54 -0
- package/src/pr-review-client.ts +1 -1
- package/src/pr-review.ts +1 -1
- package/src/preference-registry.ts +2 -0
- package/src/prepared-mcp-setup.ts +123 -0
- package/src/proxy.ts +23 -12
- package/src/realtime.ts +15 -6
- package/src/session-history-import.ts +84 -0
- package/src/session-list-entries.ts +1 -0
- package/src/session-message-search.ts +47 -0
- package/src/session-proxy-client.ts +68 -0
- package/src/session-proxy.ts +2098 -0
- package/src/session-titles.ts +8 -82
- package/src/session-usage-limits.ts +71 -0
- package/src/shared-catalog-loader.ts +169 -0
- package/src/site-ai.ts +284 -0
- package/src/site-bridge-host.ts +422 -0
- package/src/site-browser-entry.ts +6 -0
- package/src/site-browser-runtime.gen.ts +2 -0
- package/src/site-data.ts +372 -0
- package/src/site-document.test.ts +64 -0
- package/src/site-document.ts +18 -0
- package/src/site-http.ts +171 -0
- package/src/site-sql.ts +153 -0
- package/src/site-tool-bridge.ts +401 -0
- package/src/site.ts +878 -0
- package/src/skills.ts +69 -0
- package/src/sse.ts +9 -3
- package/src/stream.ts +33 -10
- package/src/tenant-workspaces.ts +148 -0
- package/src/tool-auth.ts +301 -0
- package/src/tool-display-metadata.ts +27 -0
- package/src/tools.ts +452 -0
- package/src/transcription.ts +3 -0
- package/src/types.ts +3142 -594
- package/src/usage-allowances.ts +189 -0
- package/src/vault-types.ts +379 -0
- package/src/vaults-api.ts +339 -0
- package/src/workspace-artifacts.ts +55 -6
- package/src/workspace-instruction-policies.ts +2 -1
- package/src/workspace-integrations.ts +402 -0
- package/src/workspace-state.ts +8 -82
- package/dist/chunk-6NEPJ7NC.js.map +0 -1
- package/dist/chunk-BESZFWMU.js.map +0 -1
- package/dist/chunk-E5BNEG2D.js.map +0 -1
- package/dist/chunk-GY6RQPCG.js.map +0 -1
- package/dist/chunk-OO5LPTO7.js +0 -132
- package/dist/chunk-OO5LPTO7.js.map +0 -1
- package/dist/chunk-QTBAMHEF.js.map +0 -1
- package/dist/chunk-TFCLHRZK.js.map +0 -1
- package/dist/chunk-VYCTL62C.js.map +0 -1
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OPENGENI_DELIVERY_ID_HEADER,
|
|
3
|
+
OPENGENI_EVENT_ID_HEADER,
|
|
4
|
+
OPENGENI_SIGNATURE_HEADER,
|
|
5
|
+
OPENGENI_WEBHOOK_TEST_EVENT_TYPE,
|
|
6
|
+
verifyOpenGeniSignature,
|
|
7
|
+
} from "@opengeni/contracts/workspace-integration-wire";
|
|
8
|
+
import type { CredentialProviderRequest, WorkspaceWebhookEvent } from "@opengeni/contracts";
|
|
9
|
+
import type { OpenGeniClient } from "./client";
|
|
10
|
+
import type {
|
|
11
|
+
CreateOrganizationWebhookRequest,
|
|
12
|
+
CreateOrganizationWebhookResponse,
|
|
13
|
+
GetOrganizationCredentialProviderResponse,
|
|
14
|
+
ListOrganizationWebhookDeliveriesResponse,
|
|
15
|
+
ListOrganizationWebhooksResponse,
|
|
16
|
+
OrganizationWebhook,
|
|
17
|
+
OrganizationWebhookDelivery,
|
|
18
|
+
PutOrganizationCredentialProviderRequest,
|
|
19
|
+
PutOrganizationCredentialProviderResponse,
|
|
20
|
+
RotateWorkspaceCredentialProviderSecretResponse,
|
|
21
|
+
RotateOrganizationCredentialProviderSecretResponse,
|
|
22
|
+
RotateWorkspaceWebhookSecretResponse,
|
|
23
|
+
RotateOrganizationWebhookSecretResponse,
|
|
24
|
+
TestWorkspaceCredentialProviderResponse,
|
|
25
|
+
TestWorkspaceWebhookResponse,
|
|
26
|
+
UpdateOrganizationWebhookRequest,
|
|
27
|
+
WorkspaceInheritedIntegrationsResponse,
|
|
28
|
+
WorkspaceWebhook,
|
|
29
|
+
} from "@opengeni/contracts";
|
|
30
|
+
|
|
31
|
+
export type {
|
|
32
|
+
CreateOrganizationWebhookRequest,
|
|
33
|
+
CreateOrganizationWebhookResponse,
|
|
34
|
+
CreateWorkspaceWebhookRequest,
|
|
35
|
+
CreateWorkspaceWebhookResponse,
|
|
36
|
+
CredentialProviderRequest,
|
|
37
|
+
CredentialProviderInitiatorContext,
|
|
38
|
+
CredentialProviderResponse,
|
|
39
|
+
CredentialProviderMcpHeaders,
|
|
40
|
+
CredentialProviderMcpMaterial,
|
|
41
|
+
GetOrganizationCredentialProviderResponse,
|
|
42
|
+
GetWorkspaceCredentialProviderResponse,
|
|
43
|
+
InitiatingHuman,
|
|
44
|
+
IntegrationEndpointTestResult,
|
|
45
|
+
IntegrationWorkspaceFilter,
|
|
46
|
+
ListOrganizationWebhookDeliveriesResponse,
|
|
47
|
+
ListOrganizationWebhooksResponse,
|
|
48
|
+
ListWorkspaceWebhookDeliveriesResponse,
|
|
49
|
+
ListWorkspaceWebhooksResponse,
|
|
50
|
+
PutWorkspaceCredentialProviderRequest,
|
|
51
|
+
PutWorkspaceCredentialProviderResponse,
|
|
52
|
+
PutOrganizationCredentialProviderRequest,
|
|
53
|
+
PutOrganizationCredentialProviderResponse,
|
|
54
|
+
RotateWorkspaceCredentialProviderSecretResponse,
|
|
55
|
+
RotateOrganizationCredentialProviderSecretResponse,
|
|
56
|
+
RotateWorkspaceWebhookSecretResponse,
|
|
57
|
+
RotateOrganizationWebhookSecretResponse,
|
|
58
|
+
TestWorkspaceCredentialProviderResponse,
|
|
59
|
+
TestWorkspaceWebhookResponse,
|
|
60
|
+
OrganizationCredentialProvider,
|
|
61
|
+
OrganizationWebhook,
|
|
62
|
+
OrganizationWebhookDelivery,
|
|
63
|
+
UpdateOrganizationWebhookRequest,
|
|
64
|
+
UpdateWorkspaceWebhookRequest,
|
|
65
|
+
WorkspaceCredentialProvider,
|
|
66
|
+
WorkspaceInheritedIntegrationsResponse,
|
|
67
|
+
WorkspaceTestWebhookEvent,
|
|
68
|
+
WorkspaceWebhook,
|
|
69
|
+
WorkspaceWebhookDelivery,
|
|
70
|
+
WorkspaceWebhookEvent,
|
|
71
|
+
WorkspaceWebhookEventType,
|
|
72
|
+
SessionWorkspaceWebhookEvent,
|
|
73
|
+
WorkspaceUsageWebhookEvent,
|
|
74
|
+
} from "@opengeni/contracts";
|
|
75
|
+
export {
|
|
76
|
+
OPENGENI_DELIVERY_ID_HEADER,
|
|
77
|
+
OPENGENI_EVENT_ID_HEADER,
|
|
78
|
+
OPENGENI_SIGNATURE_HEADER,
|
|
79
|
+
OPENGENI_TEST_REQUEST_NIL_ID,
|
|
80
|
+
OPENGENI_WEBHOOK_TEST_EVENT_TYPE,
|
|
81
|
+
WORKSPACE_WEBHOOK_EVENT_TYPES,
|
|
82
|
+
signOpenGeniPayload,
|
|
83
|
+
verifyOpenGeniSignature,
|
|
84
|
+
} from "@opengeni/contracts/workspace-integration-wire";
|
|
85
|
+
|
|
86
|
+
export type WorkspaceSandboxImages = { images: string[]; selected: string | null };
|
|
87
|
+
|
|
88
|
+
export class OpenGeniSignatureError extends Error {
|
|
89
|
+
constructor() {
|
|
90
|
+
super("Opengeni signature verification failed");
|
|
91
|
+
this.name = "OpenGeniSignatureError";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type SignedRequest = {
|
|
96
|
+
/** The exact raw request body. Parse it only after verification. */
|
|
97
|
+
body: string;
|
|
98
|
+
headers: Headers | Record<string, string | string[] | undefined>;
|
|
99
|
+
secret: string;
|
|
100
|
+
toleranceSeconds?: number;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
function header(headers: SignedRequest["headers"], name: string): string | null {
|
|
104
|
+
if (headers instanceof Headers) return headers.get(name);
|
|
105
|
+
const wanted = name.toLowerCase();
|
|
106
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
107
|
+
if (key.toLowerCase() === wanted) {
|
|
108
|
+
return Array.isArray(value) ? (value[0] ?? null) : (value ?? null);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function verifiedObject(input: SignedRequest): Promise<Record<string, unknown>> {
|
|
115
|
+
const valid = await verifyOpenGeniSignature({
|
|
116
|
+
secret: input.secret,
|
|
117
|
+
body: input.body,
|
|
118
|
+
signature: header(input.headers, OPENGENI_SIGNATURE_HEADER),
|
|
119
|
+
...(input.toleranceSeconds !== undefined ? { toleranceSeconds: input.toleranceSeconds } : {}),
|
|
120
|
+
});
|
|
121
|
+
if (!valid) throw new OpenGeniSignatureError();
|
|
122
|
+
const parsed: unknown = JSON.parse(input.body);
|
|
123
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
124
|
+
throw new OpenGeniSignatureError();
|
|
125
|
+
}
|
|
126
|
+
return parsed as Record<string, unknown>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Verify and parse one webhook delivery. Delivery is at least once: dedupe on
|
|
131
|
+
* `event.id` (also sent as the `OpenGeni-Event-Id` header). A `webhook.test`
|
|
132
|
+
* event (from "Send test event") names no session: acknowledge it with 2xx.
|
|
133
|
+
*/
|
|
134
|
+
export async function verifyWebhookEvent(input: SignedRequest): Promise<{
|
|
135
|
+
event: WorkspaceWebhookEvent;
|
|
136
|
+
deliveryId: string | null;
|
|
137
|
+
}> {
|
|
138
|
+
const event = await verifiedObject(input);
|
|
139
|
+
const usageEvent = typeof event.type === "string" && event.type.startsWith("usage.");
|
|
140
|
+
const lane = event.lane === undefined ? "workspace" : event.lane;
|
|
141
|
+
if (
|
|
142
|
+
typeof event.id !== "string" ||
|
|
143
|
+
typeof event.type !== "string" ||
|
|
144
|
+
typeof event.workspaceId !== "string" ||
|
|
145
|
+
(lane !== "workspace" && lane !== "organization") ||
|
|
146
|
+
(usageEvent && lane !== "workspace") ||
|
|
147
|
+
!(
|
|
148
|
+
typeof event.sessionId === "string" ||
|
|
149
|
+
((event.sessionId === null || event.sessionId === undefined) &&
|
|
150
|
+
[
|
|
151
|
+
"usage.threshold_reached",
|
|
152
|
+
"usage.exhausted",
|
|
153
|
+
"usage.period_reset",
|
|
154
|
+
OPENGENI_WEBHOOK_TEST_EVENT_TYPE,
|
|
155
|
+
].includes(event.type))
|
|
156
|
+
)
|
|
157
|
+
) {
|
|
158
|
+
throw new OpenGeniSignatureError();
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
event: { ...event, lane } as WorkspaceWebhookEvent,
|
|
162
|
+
deliveryId: header(input.headers, OPENGENI_DELIVERY_ID_HEADER),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Verify the exact bytes and parse a provider request, including its frozen
|
|
168
|
+
* initiatorContext when sent by an upgraded worker. Provenance grants no access.
|
|
169
|
+
*/
|
|
170
|
+
export async function verifyCredentialProviderRequest(
|
|
171
|
+
input: SignedRequest,
|
|
172
|
+
): Promise<CredentialProviderRequest> {
|
|
173
|
+
const parsed = await verifiedObject(input);
|
|
174
|
+
if (parsed.type !== "credentials.request" || typeof parsed.workspaceId !== "string") {
|
|
175
|
+
throw new OpenGeniSignatureError();
|
|
176
|
+
}
|
|
177
|
+
return parsed as CredentialProviderRequest;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Identity header names, for receivers that log or dedupe. */
|
|
181
|
+
export const OPENGENI_WEBHOOK_HEADERS = {
|
|
182
|
+
signature: OPENGENI_SIGNATURE_HEADER,
|
|
183
|
+
eventId: OPENGENI_EVENT_ID_HEADER,
|
|
184
|
+
deliveryId: OPENGENI_DELIVERY_ID_HEADER,
|
|
185
|
+
} as const;
|
|
186
|
+
|
|
187
|
+
/** Server-side integration administration is opt-in, outside the eager browser client. */
|
|
188
|
+
export async function getOrganizationCredentialProvider(
|
|
189
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
190
|
+
organizationId: string,
|
|
191
|
+
): Promise<GetOrganizationCredentialProviderResponse> {
|
|
192
|
+
return client.requestJson(
|
|
193
|
+
"GET",
|
|
194
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/credential-provider`,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Replace configuration; explicit filter required. Store the first returned signing secret. */
|
|
199
|
+
export async function putOrganizationCredentialProvider(
|
|
200
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
201
|
+
organizationId: string,
|
|
202
|
+
request: PutOrganizationCredentialProviderRequest,
|
|
203
|
+
): Promise<PutOrganizationCredentialProviderResponse> {
|
|
204
|
+
return client.requestJson(
|
|
205
|
+
"PUT",
|
|
206
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/credential-provider`,
|
|
207
|
+
request,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export async function deleteOrganizationCredentialProvider(
|
|
212
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
213
|
+
organizationId: string,
|
|
214
|
+
): Promise<void> {
|
|
215
|
+
await client.requestJson<void>(
|
|
216
|
+
"DELETE",
|
|
217
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/credential-provider`,
|
|
218
|
+
undefined,
|
|
219
|
+
{},
|
|
220
|
+
{ responseType: "void" },
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export async function listOrganizationWebhooks(
|
|
225
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
226
|
+
organizationId: string,
|
|
227
|
+
): Promise<ListOrganizationWebhooksResponse> {
|
|
228
|
+
return client.requestJson(
|
|
229
|
+
"GET",
|
|
230
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/webhooks`,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** Create a webhook and return its signing secret once. */
|
|
235
|
+
export async function createOrganizationWebhook(
|
|
236
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
237
|
+
organizationId: string,
|
|
238
|
+
request: CreateOrganizationWebhookRequest,
|
|
239
|
+
): Promise<CreateOrganizationWebhookResponse> {
|
|
240
|
+
return client.requestJson(
|
|
241
|
+
"POST",
|
|
242
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/webhooks`,
|
|
243
|
+
request,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export async function getOrganizationWebhook(
|
|
248
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
249
|
+
organizationId: string,
|
|
250
|
+
webhookId: string,
|
|
251
|
+
): Promise<OrganizationWebhook> {
|
|
252
|
+
return client.requestJson(
|
|
253
|
+
"GET",
|
|
254
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export async function updateOrganizationWebhook(
|
|
259
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
260
|
+
organizationId: string,
|
|
261
|
+
webhookId: string,
|
|
262
|
+
request: UpdateOrganizationWebhookRequest,
|
|
263
|
+
): Promise<OrganizationWebhook> {
|
|
264
|
+
return client.requestJson(
|
|
265
|
+
"PATCH",
|
|
266
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
267
|
+
request,
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export async function deleteOrganizationWebhook(
|
|
272
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
273
|
+
organizationId: string,
|
|
274
|
+
webhookId: string,
|
|
275
|
+
): Promise<void> {
|
|
276
|
+
await client.requestJson<void>(
|
|
277
|
+
"DELETE",
|
|
278
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/webhooks/${encodeURIComponent(webhookId)}`,
|
|
279
|
+
undefined,
|
|
280
|
+
{},
|
|
281
|
+
{ responseType: "void" },
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export async function listOrganizationWebhookDeliveries(
|
|
286
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
287
|
+
organizationId: string,
|
|
288
|
+
webhookId: string,
|
|
289
|
+
options: { limit?: number } = {},
|
|
290
|
+
): Promise<ListOrganizationWebhookDeliveriesResponse> {
|
|
291
|
+
return client.requestJson(
|
|
292
|
+
"GET",
|
|
293
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/webhooks/${encodeURIComponent(webhookId)}/deliveries`,
|
|
294
|
+
undefined,
|
|
295
|
+
options.limit !== undefined ? { limit: String(options.limit) } : {},
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** Requeue a settled delivery with a fresh attempt budget. */
|
|
300
|
+
export async function redeliverOrganizationWebhookDelivery(
|
|
301
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
302
|
+
organizationId: string,
|
|
303
|
+
webhookId: string,
|
|
304
|
+
deliveryId: string,
|
|
305
|
+
): Promise<OrganizationWebhookDelivery> {
|
|
306
|
+
return client.requestJson(
|
|
307
|
+
"POST",
|
|
308
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/webhooks/${encodeURIComponent(webhookId)}/deliveries/${encodeURIComponent(deliveryId)}/redeliver`,
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export async function getWorkspaceWebhook(
|
|
313
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
314
|
+
workspaceId: string,
|
|
315
|
+
webhookId: string,
|
|
316
|
+
): Promise<WorkspaceWebhook> {
|
|
317
|
+
return client.requestJson("GET", `/v1/workspaces/${workspaceId}/webhooks/${webhookId}`);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Rotate immediately. Store the new secret; the old signing secret stops working. */
|
|
321
|
+
export async function rotateWorkspaceCredentialProviderSecret(
|
|
322
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
323
|
+
workspaceId: string,
|
|
324
|
+
): Promise<RotateWorkspaceCredentialProviderSecretResponse> {
|
|
325
|
+
return client.requestJson(
|
|
326
|
+
"POST",
|
|
327
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/credential-provider/rotate-secret`,
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export async function rotateOrganizationCredentialProviderSecret(
|
|
332
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
333
|
+
organizationId: string,
|
|
334
|
+
): Promise<RotateOrganizationCredentialProviderSecretResponse> {
|
|
335
|
+
return client.requestJson(
|
|
336
|
+
"POST",
|
|
337
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/credential-provider/rotate-secret`,
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export async function rotateOrganizationWebhookSecret(
|
|
342
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
343
|
+
organizationId: string,
|
|
344
|
+
webhookId: string,
|
|
345
|
+
): Promise<RotateOrganizationWebhookSecretResponse> {
|
|
346
|
+
return client.requestJson(
|
|
347
|
+
"POST",
|
|
348
|
+
`/v1/organizations/${encodeURIComponent(organizationId)}/webhooks/${encodeURIComponent(webhookId)}/rotate-secret`,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export async function rotateWorkspaceWebhookSecret(
|
|
353
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
354
|
+
workspaceId: string,
|
|
355
|
+
webhookId: string,
|
|
356
|
+
): Promise<RotateWorkspaceWebhookSecretResponse> {
|
|
357
|
+
return client.requestJson(
|
|
358
|
+
"POST",
|
|
359
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/webhooks/${encodeURIComponent(webhookId)}/rotate-secret`,
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Send one signed `webhook.test` event to a workspace webhook now and return
|
|
365
|
+
* what the endpoint answered. Nothing is queued or retried.
|
|
366
|
+
*/
|
|
367
|
+
export async function testWorkspaceWebhook(
|
|
368
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
369
|
+
workspaceId: string,
|
|
370
|
+
webhookId: string,
|
|
371
|
+
): Promise<TestWorkspaceWebhookResponse> {
|
|
372
|
+
return client.requestJson(
|
|
373
|
+
"POST",
|
|
374
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/webhooks/${encodeURIComponent(webhookId)}/test`,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Send one signed `purpose: "test"` request to the credential provider this
|
|
380
|
+
* workspace's runs use (its own, else the organization's). Only the names of
|
|
381
|
+
* returned credentials come back, never their values.
|
|
382
|
+
*/
|
|
383
|
+
export async function testWorkspaceCredentialProvider(
|
|
384
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
385
|
+
workspaceId: string,
|
|
386
|
+
): Promise<TestWorkspaceCredentialProviderResponse> {
|
|
387
|
+
return client.requestJson(
|
|
388
|
+
"POST",
|
|
389
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/credential-provider/test`,
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Organization registrations that reach this workspace. Workspace administrators only. */
|
|
394
|
+
export async function getWorkspaceInheritedIntegrations(
|
|
395
|
+
client: Pick<OpenGeniClient, "requestJson">,
|
|
396
|
+
workspaceId: string,
|
|
397
|
+
): Promise<WorkspaceInheritedIntegrationsResponse> {
|
|
398
|
+
return client.requestJson(
|
|
399
|
+
"GET",
|
|
400
|
+
`/v1/workspaces/${encodeURIComponent(workspaceId)}/inherited-integrations`,
|
|
401
|
+
);
|
|
402
|
+
}
|
package/src/workspace-state.ts
CHANGED
|
@@ -4,57 +4,6 @@ import type {
|
|
|
4
4
|
WorkspaceInstructionPolicyScope,
|
|
5
5
|
} from "./workspace-instruction-policies";
|
|
6
6
|
|
|
7
|
-
export type WorkspaceStateDocumentStatusCounts = {
|
|
8
|
-
queued: number;
|
|
9
|
-
indexing: number;
|
|
10
|
-
ready: number;
|
|
11
|
-
failed: number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type WorkspaceStateSourceKindCounts = {
|
|
15
|
-
manual_upload: number;
|
|
16
|
-
meeting_transcript: number;
|
|
17
|
-
repository: number;
|
|
18
|
-
email: number;
|
|
19
|
-
chat: number;
|
|
20
|
-
document: number;
|
|
21
|
-
web: number;
|
|
22
|
-
other: number;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type WorkspaceStateDocumentAuthorityKindCounts = {
|
|
26
|
-
organization: number;
|
|
27
|
-
workspace: number;
|
|
28
|
-
personal: number;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type WorkspaceStateMemoryStatusCounts = {
|
|
32
|
-
proposed: number;
|
|
33
|
-
approved: number;
|
|
34
|
-
rejected: number;
|
|
35
|
-
active: number;
|
|
36
|
-
superseded: number;
|
|
37
|
-
archived: number;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type WorkspaceStateMemoryKindCounts = {
|
|
41
|
-
semantic: number;
|
|
42
|
-
episodic: number;
|
|
43
|
-
procedural: number;
|
|
44
|
-
decision: number;
|
|
45
|
-
preference: number;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export type WorkspaceStateGapCode =
|
|
49
|
-
| "no_document_bases"
|
|
50
|
-
| "no_visible_documents"
|
|
51
|
-
| "failed_documents"
|
|
52
|
-
| "processing_documents"
|
|
53
|
-
| "missing_topic_coverage"
|
|
54
|
-
| "no_memory_records"
|
|
55
|
-
| "pending_memory_review"
|
|
56
|
-
| "partial_inventory";
|
|
57
|
-
|
|
58
7
|
export type WorkspaceStateGovernanceDriftStatus =
|
|
59
8
|
| "identical"
|
|
60
9
|
| "changed"
|
|
@@ -188,39 +137,16 @@ export type WorkspaceStateResponse = {
|
|
|
188
137
|
}
|
|
189
138
|
| {
|
|
190
139
|
availability: "available";
|
|
140
|
+
authority: "knowledge_entries";
|
|
191
141
|
coverage: "complete" | "partial";
|
|
192
|
-
|
|
193
|
-
|
|
142
|
+
sampleLimit: 50;
|
|
143
|
+
entries: Array<{
|
|
194
144
|
id: string;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
basesTruncated: boolean;
|
|
201
|
-
inspectedVisibleDocumentCount: number;
|
|
202
|
-
documentStatusCounts: WorkspaceStateDocumentStatusCounts;
|
|
203
|
-
sourceKindCounts: WorkspaceStateSourceKindCounts;
|
|
204
|
-
authorityKindCounts: WorkspaceStateDocumentAuthorityKindCounts;
|
|
205
|
-
topics: Array<{ name: string; documentCount: number }>;
|
|
206
|
-
topicsTruncated: boolean;
|
|
207
|
-
latestDocumentUpdatedAt: string | null;
|
|
208
|
-
memorySample: {
|
|
209
|
-
recordCount: number;
|
|
210
|
-
sampleLimit: 100;
|
|
211
|
-
limitReached: boolean;
|
|
212
|
-
statusCounts: WorkspaceStateMemoryStatusCounts;
|
|
213
|
-
kindCounts: WorkspaceStateMemoryKindCounts;
|
|
214
|
-
preferenceAuthority: {
|
|
215
|
-
kindCountSource: "knowledge_memories_legacy_observations";
|
|
216
|
-
activeAuthority: "structured_preference_registry";
|
|
217
|
-
};
|
|
218
|
-
latestUpdatedAt: string | null;
|
|
219
|
-
};
|
|
220
|
-
gaps: Array<{
|
|
221
|
-
code: WorkspaceStateGapCode;
|
|
222
|
-
severity: "info" | "warning";
|
|
223
|
-
relatedCount: number | null;
|
|
145
|
+
revisionId: string;
|
|
146
|
+
title: string;
|
|
147
|
+
kind: "source" | "fact" | "decision" | "requirement" | "incident" | "note" | "group";
|
|
148
|
+
scope: "organization" | "workspace" | "personal";
|
|
149
|
+
updatedAt: string;
|
|
224
150
|
}>;
|
|
225
151
|
};
|
|
226
152
|
};
|