@opengeni/sdk 0.25.5 → 0.26.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/dist/index.d.ts +121 -1
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +116 -0
- package/src/index.ts +24 -0
- package/src/types.ts +11 -0
- package/src/workspace-instruction-policies.ts +124 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.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": {
|
package/src/client.ts
CHANGED
|
@@ -46,6 +46,7 @@ import type {
|
|
|
46
46
|
CreateCapabilityCatalogItemRequest,
|
|
47
47
|
CreateCheckoutRequest,
|
|
48
48
|
CreateCheckoutResponse,
|
|
49
|
+
ConnectOpenGeniSlackBotRequest,
|
|
49
50
|
CreateConnectionRequest,
|
|
50
51
|
CreateDocumentBaseRequest,
|
|
51
52
|
CreateFileUploadRequest,
|
|
@@ -196,6 +197,18 @@ import type {
|
|
|
196
197
|
OAuthStartRequest,
|
|
197
198
|
OAuthStartResponse,
|
|
198
199
|
} from "./types";
|
|
200
|
+
import type {
|
|
201
|
+
ActivateWorkspaceInstructionPolicyRequest,
|
|
202
|
+
CreateWorkspaceInstructionPolicyDraftRequest,
|
|
203
|
+
ImportLegacyWorkspaceInstructionPolicyDraftRequest,
|
|
204
|
+
RollbackWorkspaceInstructionPolicyRequest,
|
|
205
|
+
WorkspaceInstructionPolicyActivationResponse,
|
|
206
|
+
WorkspaceInstructionPolicyDiffRequest,
|
|
207
|
+
WorkspaceInstructionPolicyDiffResponse,
|
|
208
|
+
WorkspaceInstructionPolicyListOptions,
|
|
209
|
+
WorkspaceInstructionPolicyListResponse,
|
|
210
|
+
WorkspaceInstructionPolicyRevision,
|
|
211
|
+
} from "./workspace-instruction-policies";
|
|
199
212
|
import {
|
|
200
213
|
OPENGENI_API_CONTRACT_HEADER,
|
|
201
214
|
OPENGENI_API_CONTRACT_REVISION,
|
|
@@ -1613,6 +1626,96 @@ export class OpenGeniClient {
|
|
|
1613
1626
|
return await this.requestJson<Workspace>("PATCH", `/v1/workspaces/${workspaceId}`, request);
|
|
1614
1627
|
}
|
|
1615
1628
|
|
|
1629
|
+
/** Inspect immutable instruction-policy history, active heads, and activation audit evidence. */
|
|
1630
|
+
async listWorkspaceInstructionPolicies(
|
|
1631
|
+
workspaceId: string,
|
|
1632
|
+
options: WorkspaceInstructionPolicyListOptions = {},
|
|
1633
|
+
): Promise<WorkspaceInstructionPolicyListResponse> {
|
|
1634
|
+
const params = new URLSearchParams();
|
|
1635
|
+
if (options.kind !== undefined) params.set("kind", options.kind);
|
|
1636
|
+
if (options.scope !== undefined) params.set("scope", options.scope);
|
|
1637
|
+
if (options.roleKey !== undefined) params.set("roleKey", options.roleKey);
|
|
1638
|
+
if (options.afterRevision !== undefined) {
|
|
1639
|
+
params.set("afterRevision", String(options.afterRevision));
|
|
1640
|
+
}
|
|
1641
|
+
if (options.limit !== undefined) params.set("limit", String(options.limit));
|
|
1642
|
+
const query = params.toString();
|
|
1643
|
+
return await this.requestJson<WorkspaceInstructionPolicyListResponse>(
|
|
1644
|
+
"GET",
|
|
1645
|
+
`/v1/workspaces/${workspaceId}/instruction-policies${query ? `?${query}` : ""}`,
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
async getWorkspaceInstructionPolicyRevision(
|
|
1650
|
+
workspaceId: string,
|
|
1651
|
+
revisionId: string,
|
|
1652
|
+
): Promise<WorkspaceInstructionPolicyRevision> {
|
|
1653
|
+
return await this.requestJson<WorkspaceInstructionPolicyRevision>(
|
|
1654
|
+
"GET",
|
|
1655
|
+
`/v1/workspaces/${workspaceId}/instruction-policies/${encodeURIComponent(revisionId)}`,
|
|
1656
|
+
);
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
async createWorkspaceInstructionPolicyDraft(
|
|
1660
|
+
workspaceId: string,
|
|
1661
|
+
request: CreateWorkspaceInstructionPolicyDraftRequest,
|
|
1662
|
+
): Promise<WorkspaceInstructionPolicyRevision> {
|
|
1663
|
+
return await this.requestJson<WorkspaceInstructionPolicyRevision>(
|
|
1664
|
+
"POST",
|
|
1665
|
+
`/v1/workspaces/${workspaceId}/instruction-policies/drafts`,
|
|
1666
|
+
request,
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
/** Import the stored legacy workspace override as an inactive charter draft. */
|
|
1671
|
+
async importLegacyWorkspaceInstructionPolicyDraft(
|
|
1672
|
+
workspaceId: string,
|
|
1673
|
+
request: ImportLegacyWorkspaceInstructionPolicyDraftRequest = {},
|
|
1674
|
+
): Promise<WorkspaceInstructionPolicyRevision> {
|
|
1675
|
+
return await this.requestJson<WorkspaceInstructionPolicyRevision>(
|
|
1676
|
+
"POST",
|
|
1677
|
+
`/v1/workspaces/${workspaceId}/instruction-policies/import-legacy`,
|
|
1678
|
+
request,
|
|
1679
|
+
);
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
async diffWorkspaceInstructionPolicyRevisions(
|
|
1683
|
+
workspaceId: string,
|
|
1684
|
+
request: WorkspaceInstructionPolicyDiffRequest,
|
|
1685
|
+
): Promise<WorkspaceInstructionPolicyDiffResponse> {
|
|
1686
|
+
const params = new URLSearchParams({
|
|
1687
|
+
fromRevisionId: request.fromRevisionId,
|
|
1688
|
+
toRevisionId: request.toRevisionId,
|
|
1689
|
+
});
|
|
1690
|
+
return await this.requestJson<WorkspaceInstructionPolicyDiffResponse>(
|
|
1691
|
+
"GET",
|
|
1692
|
+
`/v1/workspaces/${workspaceId}/instruction-policies/diff?${params}`,
|
|
1693
|
+
);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
async activateWorkspaceInstructionPolicyRevision(
|
|
1697
|
+
workspaceId: string,
|
|
1698
|
+
revisionId: string,
|
|
1699
|
+
request: ActivateWorkspaceInstructionPolicyRequest,
|
|
1700
|
+
): Promise<WorkspaceInstructionPolicyActivationResponse> {
|
|
1701
|
+
return await this.requestJson<WorkspaceInstructionPolicyActivationResponse>(
|
|
1702
|
+
"POST",
|
|
1703
|
+
`/v1/workspaces/${workspaceId}/instruction-policies/${encodeURIComponent(revisionId)}/activate`,
|
|
1704
|
+
request,
|
|
1705
|
+
);
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
async rollbackWorkspaceInstructionPolicyRevision(
|
|
1709
|
+
workspaceId: string,
|
|
1710
|
+
request: RollbackWorkspaceInstructionPolicyRequest,
|
|
1711
|
+
): Promise<WorkspaceInstructionPolicyActivationResponse> {
|
|
1712
|
+
return await this.requestJson<WorkspaceInstructionPolicyActivationResponse>(
|
|
1713
|
+
"POST",
|
|
1714
|
+
`/v1/workspaces/${workspaceId}/instruction-policies/rollback`,
|
|
1715
|
+
request,
|
|
1716
|
+
);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1616
1719
|
/**
|
|
1617
1720
|
* Delete a workspace and everything in it. Refused (409) for the account's
|
|
1618
1721
|
* only workspace and while it still has a running session. Irreversible.
|
|
@@ -2486,6 +2589,19 @@ export class OpenGeniClient {
|
|
|
2486
2589
|
return response.connection;
|
|
2487
2590
|
}
|
|
2488
2591
|
|
|
2592
|
+
/** Validate and store/reinstall the workspace-shared OpenGeni Slack bot credential. */
|
|
2593
|
+
async connectOpenGeniSlackBot(
|
|
2594
|
+
workspaceId: string,
|
|
2595
|
+
request: ConnectOpenGeniSlackBotRequest,
|
|
2596
|
+
): Promise<ConnectionMetadata> {
|
|
2597
|
+
const response = await this.requestJson<ConnectionResponse>(
|
|
2598
|
+
"POST",
|
|
2599
|
+
`/v1/workspaces/${workspaceId}/connections/slack-bot`,
|
|
2600
|
+
request,
|
|
2601
|
+
);
|
|
2602
|
+
return response.connection;
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2489
2605
|
async updateConnection(
|
|
2490
2606
|
workspaceId: string,
|
|
2491
2607
|
connectionId: string,
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,29 @@ export type {
|
|
|
53
53
|
} from "./stream";
|
|
54
54
|
export { streamWorkspaceControlEvents } from "./workspace-control-stream";
|
|
55
55
|
export type { WorkspaceControlStreamTransport } from "./workspace-control-stream";
|
|
56
|
+
export { normalizeWorkspaceInstructionPolicyRoleKey } from "./workspace-instruction-policies";
|
|
57
|
+
export type {
|
|
58
|
+
ActivateWorkspaceInstructionPolicyRequest,
|
|
59
|
+
CreateWorkspaceInstructionPolicyDraftRequest,
|
|
60
|
+
ImportLegacyWorkspaceInstructionPolicyDraftRequest,
|
|
61
|
+
RollbackWorkspaceInstructionPolicyRequest,
|
|
62
|
+
WorkspaceInstructionPolicyActivationEvent,
|
|
63
|
+
WorkspaceInstructionPolicyActivationResponse,
|
|
64
|
+
WorkspaceInstructionPolicyActivationType,
|
|
65
|
+
WorkspaceInstructionPolicyConflictResponse,
|
|
66
|
+
WorkspaceInstructionPolicyDiffRequest,
|
|
67
|
+
WorkspaceInstructionPolicyDiffResponse,
|
|
68
|
+
WorkspaceInstructionPolicyDraftProvenanceSource,
|
|
69
|
+
WorkspaceInstructionPolicyHead,
|
|
70
|
+
WorkspaceInstructionPolicyKind,
|
|
71
|
+
WorkspaceInstructionPolicyListOptions,
|
|
72
|
+
WorkspaceInstructionPolicyListResponse,
|
|
73
|
+
WorkspaceInstructionPolicyProvenanceSource,
|
|
74
|
+
WorkspaceInstructionPolicyRevision,
|
|
75
|
+
WorkspaceInstructionPolicyRevisionIdentity,
|
|
76
|
+
WorkspaceInstructionPolicyScope,
|
|
77
|
+
WorkspaceInstructionPolicyTarget,
|
|
78
|
+
} from "./workspace-instruction-policies";
|
|
56
79
|
export {
|
|
57
80
|
DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY,
|
|
58
81
|
authorizeTranscriptionAdapter,
|
|
@@ -168,6 +191,7 @@ export type {
|
|
|
168
191
|
CreateApiKeyRequest,
|
|
169
192
|
CreateApiKeyResponse,
|
|
170
193
|
CreateCapabilityCatalogItemRequest,
|
|
194
|
+
ConnectOpenGeniSlackBotRequest,
|
|
171
195
|
CreateConnectionRequest,
|
|
172
196
|
CreateCheckoutRequest,
|
|
173
197
|
CreateCheckoutResponse,
|
package/src/types.ts
CHANGED
|
@@ -389,6 +389,8 @@ export type ConnectionMetadata = {
|
|
|
389
389
|
lastUsedAt: string | null;
|
|
390
390
|
lastError: string | null;
|
|
391
391
|
version: number;
|
|
392
|
+
verifiedInstallAt?: string | null;
|
|
393
|
+
verifiedInstallVersion?: number | null;
|
|
392
394
|
metadata: Record<string, unknown>;
|
|
393
395
|
createdBySubjectId: string | null;
|
|
394
396
|
updatedBySubjectId: string | null;
|
|
@@ -406,6 +408,13 @@ export type CreateConnectionRequest = {
|
|
|
406
408
|
metadata?: Record<string, unknown> | undefined;
|
|
407
409
|
};
|
|
408
410
|
|
|
411
|
+
export type ConnectOpenGeniSlackBotRequest = {
|
|
412
|
+
/** Write-only Slack bot token. It is never returned by the API. */
|
|
413
|
+
token: string;
|
|
414
|
+
/** Existing OpenGeni Slack bot connection to reinstall in place. */
|
|
415
|
+
connectionId?: string | undefined;
|
|
416
|
+
};
|
|
417
|
+
|
|
409
418
|
export type UpdateConnectionRequest = {
|
|
410
419
|
providerDomain?: string | undefined;
|
|
411
420
|
subjectId?: string | null | undefined;
|
|
@@ -1506,6 +1515,7 @@ export type ScheduledTaskAgentConfig = {
|
|
|
1506
1515
|
resources: ResourceRef[];
|
|
1507
1516
|
tools: ToolRef[];
|
|
1508
1517
|
metadata: Record<string, unknown>;
|
|
1518
|
+
slackBotConnectionId?: string | undefined;
|
|
1509
1519
|
model?: string | undefined;
|
|
1510
1520
|
reasoningEffort?: ReasoningEffort | undefined;
|
|
1511
1521
|
sandboxBackend?: SandboxBackend | undefined;
|
|
@@ -2488,6 +2498,7 @@ export type ScheduledTaskAgentConfigInput = {
|
|
|
2488
2498
|
resources?: ResourceRef[] | undefined;
|
|
2489
2499
|
tools?: ToolRef[] | undefined;
|
|
2490
2500
|
metadata?: Record<string, unknown> | undefined;
|
|
2501
|
+
slackBotConnectionId?: string | undefined;
|
|
2491
2502
|
model?: string | undefined;
|
|
2492
2503
|
reasoningEffort?: ReasoningEffort | undefined;
|
|
2493
2504
|
sandboxBackend?: SandboxBackend | undefined;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export type WorkspaceInstructionPolicyKind = "charter" | "policy";
|
|
2
|
+
export type WorkspaceInstructionPolicyScope = "global" | "role";
|
|
3
|
+
export type WorkspaceInstructionPolicyProvenanceSource =
|
|
4
|
+
| "human"
|
|
5
|
+
| "onboarding"
|
|
6
|
+
| "knowledge_proposal"
|
|
7
|
+
| "legacy_import";
|
|
8
|
+
export type WorkspaceInstructionPolicyDraftProvenanceSource = Exclude<
|
|
9
|
+
WorkspaceInstructionPolicyProvenanceSource,
|
|
10
|
+
"legacy_import"
|
|
11
|
+
>;
|
|
12
|
+
export type WorkspaceInstructionPolicyActivationType = "activate" | "rollback";
|
|
13
|
+
|
|
14
|
+
export function normalizeWorkspaceInstructionPolicyRoleKey(value: string): string {
|
|
15
|
+
return value.normalize("NFKC").trim().toLowerCase().replace(/\s+/gu, "-").replace(/-+/g, "-");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type WorkspaceInstructionPolicyTarget = {
|
|
19
|
+
kind: WorkspaceInstructionPolicyKind;
|
|
20
|
+
scope: WorkspaceInstructionPolicyScope;
|
|
21
|
+
roleKey: string | null;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type WorkspaceInstructionPolicyRevisionIdentity = {
|
|
25
|
+
id: string;
|
|
26
|
+
revision: number;
|
|
27
|
+
contentHash: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type WorkspaceInstructionPolicyRevision = WorkspaceInstructionPolicyRevisionIdentity &
|
|
31
|
+
WorkspaceInstructionPolicyTarget & {
|
|
32
|
+
accountId: string;
|
|
33
|
+
workspaceId: string;
|
|
34
|
+
content: string;
|
|
35
|
+
provenance: {
|
|
36
|
+
source: WorkspaceInstructionPolicyProvenanceSource;
|
|
37
|
+
sourceId: string | null;
|
|
38
|
+
};
|
|
39
|
+
supersedesRevisionId: string | null;
|
|
40
|
+
createdBySubjectId: string;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type WorkspaceInstructionPolicyHead = WorkspaceInstructionPolicyTarget & {
|
|
45
|
+
workspaceId: string;
|
|
46
|
+
revisionId: string;
|
|
47
|
+
revision: number;
|
|
48
|
+
contentHash: string;
|
|
49
|
+
activationVersion: number;
|
|
50
|
+
activatedAt: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type WorkspaceInstructionPolicyActivationEvent = WorkspaceInstructionPolicyTarget & {
|
|
54
|
+
id: string;
|
|
55
|
+
accountId: string;
|
|
56
|
+
workspaceId: string;
|
|
57
|
+
type: WorkspaceInstructionPolicyActivationType;
|
|
58
|
+
activationVersion: number;
|
|
59
|
+
oldRevision: WorkspaceInstructionPolicyRevisionIdentity | null;
|
|
60
|
+
newRevision: WorkspaceInstructionPolicyRevisionIdentity;
|
|
61
|
+
actorSubjectId: string;
|
|
62
|
+
reason: string;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type CreateWorkspaceInstructionPolicyDraftRequest = WorkspaceInstructionPolicyTarget & {
|
|
67
|
+
content: string;
|
|
68
|
+
provenanceSource?: WorkspaceInstructionPolicyDraftProvenanceSource;
|
|
69
|
+
provenanceSourceId?: string | null;
|
|
70
|
+
supersedesRevisionId?: string | null;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type ImportLegacyWorkspaceInstructionPolicyDraftRequest = {
|
|
74
|
+
supersedesRevisionId?: string | null;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type WorkspaceInstructionPolicyListOptions = {
|
|
78
|
+
kind?: WorkspaceInstructionPolicyKind;
|
|
79
|
+
scope?: WorkspaceInstructionPolicyScope;
|
|
80
|
+
roleKey?: string;
|
|
81
|
+
afterRevision?: number;
|
|
82
|
+
limit?: number;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type WorkspaceInstructionPolicyListResponse = {
|
|
86
|
+
revisions: WorkspaceInstructionPolicyRevision[];
|
|
87
|
+
activeHeads: WorkspaceInstructionPolicyHead[];
|
|
88
|
+
activationEvents: WorkspaceInstructionPolicyActivationEvent[];
|
|
89
|
+
nextAfterRevision: number | null;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type WorkspaceInstructionPolicyDiffRequest = {
|
|
93
|
+
fromRevisionId: string;
|
|
94
|
+
toRevisionId: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type WorkspaceInstructionPolicyDiffResponse = {
|
|
98
|
+
from: WorkspaceInstructionPolicyRevision;
|
|
99
|
+
to: WorkspaceInstructionPolicyRevision;
|
|
100
|
+
format: "unified";
|
|
101
|
+
diff: string;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type ActivateWorkspaceInstructionPolicyRequest = {
|
|
105
|
+
expectedCurrentRevisionId: string | null;
|
|
106
|
+
reason: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type RollbackWorkspaceInstructionPolicyRequest = {
|
|
110
|
+
targetRevisionId: string;
|
|
111
|
+
expectedCurrentRevisionId: string;
|
|
112
|
+
reason: string;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type WorkspaceInstructionPolicyActivationResponse = {
|
|
116
|
+
head: WorkspaceInstructionPolicyHead;
|
|
117
|
+
event: WorkspaceInstructionPolicyActivationEvent;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type WorkspaceInstructionPolicyConflictResponse = {
|
|
121
|
+
code: "WORKSPACE_INSTRUCTION_POLICY_CONFLICT";
|
|
122
|
+
message: string;
|
|
123
|
+
currentHead: WorkspaceInstructionPolicyHead | null;
|
|
124
|
+
};
|