@opengeni/contracts 0.31.1 → 0.32.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/chunk-7JZMI22I.js +126 -0
- package/dist/chunk-7JZMI22I.js.map +1 -0
- package/dist/{chunk-TQC34EGL.js → chunk-GMOYIHF3.js} +646 -280
- package/dist/chunk-GMOYIHF3.js.map +1 -0
- package/dist/google-drive.d.ts +21 -0
- package/dist/google-drive.js +36 -3
- package/dist/google-drive.js.map +1 -1
- package/dist/index.d.ts +562 -2
- package/dist/index.js +97 -5
- package/dist/slack-bot-scopes.d.ts +58 -1
- package/dist/slack-bot-scopes.js +15 -3
- package/dist/workspace-instruction-policies.d.ts +160 -0
- package/package.json +1 -1
- package/src/google-drive.ts +53 -0
- package/src/index.ts +509 -100
- package/src/slack-bot-scopes.ts +93 -1
- package/src/workspace-instruction-policies.ts +75 -3
- package/dist/chunk-KGL5BVGF.js +0 -45
- package/dist/chunk-KGL5BVGF.js.map +0 -1
- package/dist/chunk-TQC34EGL.js.map +0 -1
package/src/slack-bot-scopes.ts
CHANGED
|
@@ -16,12 +16,100 @@ export const OPENGENI_SLACK_BOT_REQUIRED_SCOPES = [
|
|
|
16
16
|
"users:read",
|
|
17
17
|
] as const;
|
|
18
18
|
|
|
19
|
+
/** Read-only scope needed only for the optional emoji-reaction summon surface. */
|
|
20
|
+
export const OPENGENI_SLACK_REACTION_REQUIRED_SCOPE = "reactions:read" as const;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Scopes requested by the managed and generated self-hosted manifests.
|
|
24
|
+
*
|
|
25
|
+
* `reactions:read` is deliberately not part of the base eligibility contract:
|
|
26
|
+
* legacy installations may continue using existing Slack interactions and
|
|
27
|
+
* tools while the reaction setting stays disabled and the UI asks an admin to
|
|
28
|
+
* reinstall.
|
|
29
|
+
*/
|
|
30
|
+
export const OPENGENI_SLACK_BOT_REQUESTED_SCOPES = [
|
|
31
|
+
...OPENGENI_SLACK_BOT_REQUIRED_SCOPES,
|
|
32
|
+
OPENGENI_SLACK_REACTION_REQUIRED_SCOPE,
|
|
33
|
+
] as const;
|
|
34
|
+
|
|
35
|
+
export const OPENGENI_SLACK_BOT_EVENTS = [
|
|
36
|
+
"app_mention",
|
|
37
|
+
"message.channels",
|
|
38
|
+
"message.groups",
|
|
39
|
+
"message.im",
|
|
40
|
+
"message.mpim",
|
|
41
|
+
"reaction_added",
|
|
42
|
+
] as const;
|
|
43
|
+
|
|
44
|
+
export const OPENGENI_MANAGED_PUBLIC_BASE_URL = "https://app.opengeni.ai" as const;
|
|
45
|
+
|
|
46
|
+
function normalizedSlackManifestBaseUrl(publicBaseUrl: string): string {
|
|
47
|
+
const parsed = new URL(publicBaseUrl);
|
|
48
|
+
if (parsed.protocol !== "https:" || parsed.username || parsed.password) {
|
|
49
|
+
throw new Error("Slack bot manifest public base URL must be credential-free HTTPS");
|
|
50
|
+
}
|
|
51
|
+
parsed.hash = "";
|
|
52
|
+
parsed.search = "";
|
|
53
|
+
parsed.pathname = parsed.pathname.replace(/\/+$/, "");
|
|
54
|
+
return parsed.toString().replace(/\/$/, "");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Canonical managed/self-hosted Slack app manifest. Slack accepts JSON manifests. */
|
|
58
|
+
export function buildOpenGeniSlackBotManifest(publicBaseUrl: string) {
|
|
59
|
+
const baseUrl = normalizedSlackManifestBaseUrl(publicBaseUrl);
|
|
60
|
+
return {
|
|
61
|
+
display_information: { name: "OpenGeni" },
|
|
62
|
+
features: {
|
|
63
|
+
bot_user: { display_name: "OpenGeni", always_online: false },
|
|
64
|
+
slash_commands: [
|
|
65
|
+
{
|
|
66
|
+
command: "/opengeni",
|
|
67
|
+
description: "Start an OpenGeni task in this channel",
|
|
68
|
+
should_escape: false,
|
|
69
|
+
url: `${baseUrl}/v1/integrations/slack/commands`,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
shortcuts: [
|
|
73
|
+
{
|
|
74
|
+
callback_id: "opengeni_message",
|
|
75
|
+
description: "Start an OpenGeni task from this Slack message",
|
|
76
|
+
name: "Open in OpenGeni",
|
|
77
|
+
type: "message",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
oauth_config: {
|
|
82
|
+
redirect_urls: [
|
|
83
|
+
`${baseUrl}/v1/integrations/oauth/callback`,
|
|
84
|
+
`${baseUrl}/v1/integrations/slack/callback`,
|
|
85
|
+
],
|
|
86
|
+
scopes: { bot: [...OPENGENI_SLACK_BOT_REQUESTED_SCOPES] },
|
|
87
|
+
},
|
|
88
|
+
settings: {
|
|
89
|
+
event_subscriptions: {
|
|
90
|
+
bot_events: [...OPENGENI_SLACK_BOT_EVENTS],
|
|
91
|
+
request_url: `${baseUrl}/v1/integrations/slack/events`,
|
|
92
|
+
},
|
|
93
|
+
interactivity: {
|
|
94
|
+
is_enabled: true,
|
|
95
|
+
request_url: `${baseUrl}/v1/integrations/slack/interactions`,
|
|
96
|
+
},
|
|
97
|
+
org_deploy_enabled: false,
|
|
98
|
+
socket_mode_enabled: false,
|
|
99
|
+
token_rotation_enabled: false,
|
|
100
|
+
},
|
|
101
|
+
} as const;
|
|
102
|
+
}
|
|
103
|
+
|
|
19
104
|
/**
|
|
20
105
|
* Optional bot grants that remain inside the shipped bot's read/identity
|
|
21
106
|
* boundary. Every other unrequired scope fails closed, including unknown future
|
|
22
107
|
* Slack scopes, so verification, core routing, and UI eligibility cannot drift.
|
|
23
108
|
*/
|
|
24
|
-
export const OPENGENI_SLACK_BOT_SAFE_OPTIONAL_SCOPES = [
|
|
109
|
+
export const OPENGENI_SLACK_BOT_SAFE_OPTIONAL_SCOPES = [
|
|
110
|
+
"team:read",
|
|
111
|
+
OPENGENI_SLACK_REACTION_REQUIRED_SCOPE,
|
|
112
|
+
] as const;
|
|
25
113
|
|
|
26
114
|
/** @deprecated Use evaluateOpenGeniSlackBotScopes; an allowlist is the policy. */
|
|
27
115
|
export const OPENGENI_SLACK_BOT_FORBIDDEN_SCOPES = ["channels:join", "chat:write.public"] as const;
|
|
@@ -46,6 +134,10 @@ export function areOpenGeniSlackBotScopesAccepted(grantedScopes: readonly string
|
|
|
46
134
|
);
|
|
47
135
|
}
|
|
48
136
|
|
|
137
|
+
export function hasOpenGeniSlackReactionScope(grantedScopes: readonly string[]): boolean {
|
|
138
|
+
return grantedScopes.includes(OPENGENI_SLACK_REACTION_REQUIRED_SCOPE);
|
|
139
|
+
}
|
|
140
|
+
|
|
49
141
|
export function evaluateOpenGeniSlackBotScopes(
|
|
50
142
|
grantedScopes: readonly string[],
|
|
51
143
|
): OpenGeniSlackBotScopePolicy {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
export const WORKSPACE_INSTRUCTION_POLICY_CONTENT_MAX_CHARS = 262_144;
|
|
4
|
+
export const WORKSPACE_INSTRUCTION_POLICY_PROMPT_MAX_UTF8_BYTES = 131_072;
|
|
4
5
|
export const WORKSPACE_INSTRUCTION_POLICY_REASON_MAX_CHARS = 4_096;
|
|
5
6
|
export const WORKSPACE_INSTRUCTION_POLICY_ROLE_KEY_MAX_CHARS = 64;
|
|
6
7
|
export const WORKSPACE_INSTRUCTION_POLICY_SOURCE_ID_MAX_CHARS = 512;
|
|
@@ -50,10 +51,23 @@ export function normalizeWorkspaceInstructionPolicyRoleKey(value: string): strin
|
|
|
50
51
|
return value.normalize("NFKC").trim().toLowerCase().replace(/\s+/gu, "-").replace(/-+/g, "-");
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
const
|
|
54
|
+
export const WorkspaceInstructionPolicyRoleKeyInput = z
|
|
54
55
|
.string()
|
|
55
56
|
.transform(normalizeWorkspaceInstructionPolicyRoleKey)
|
|
56
57
|
.pipe(WorkspaceInstructionPolicyRoleKey);
|
|
58
|
+
export type WorkspaceInstructionPolicyRoleKeyInput = z.infer<
|
|
59
|
+
typeof WorkspaceInstructionPolicyRoleKeyInput
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
export const WorkspaceInstructionPolicyRoleSource = z.enum([
|
|
63
|
+
"session_binding",
|
|
64
|
+
"metadata_fallback",
|
|
65
|
+
"none",
|
|
66
|
+
"invalid_metadata_fallback",
|
|
67
|
+
]);
|
|
68
|
+
export type WorkspaceInstructionPolicyRoleSource = z.infer<
|
|
69
|
+
typeof WorkspaceInstructionPolicyRoleSource
|
|
70
|
+
>;
|
|
57
71
|
|
|
58
72
|
const targetShape = {
|
|
59
73
|
kind: WorkspaceInstructionPolicyKind,
|
|
@@ -138,6 +152,64 @@ export const WorkspaceInstructionPolicyHead = z.object({
|
|
|
138
152
|
});
|
|
139
153
|
export type WorkspaceInstructionPolicyHead = z.infer<typeof WorkspaceInstructionPolicyHead>;
|
|
140
154
|
|
|
155
|
+
export const WorkspaceInstructionPolicySnapshotProvenance = z.object({
|
|
156
|
+
source: WorkspaceInstructionPolicyProvenanceSource,
|
|
157
|
+
sourceIdHash: z
|
|
158
|
+
.string()
|
|
159
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
160
|
+
.nullable(),
|
|
161
|
+
});
|
|
162
|
+
export type WorkspaceInstructionPolicySnapshotProvenance = z.infer<
|
|
163
|
+
typeof WorkspaceInstructionPolicySnapshotProvenance
|
|
164
|
+
>;
|
|
165
|
+
|
|
166
|
+
export const WorkspaceInstructionPolicySnapshotEntry = z.object({
|
|
167
|
+
kind: WorkspaceInstructionPolicyKind,
|
|
168
|
+
scope: WorkspaceInstructionPolicyScope,
|
|
169
|
+
roleKey: WorkspaceInstructionPolicyRoleKey.nullable(),
|
|
170
|
+
revisionId: z.string().uuid(),
|
|
171
|
+
revision: z.number().int().positive(),
|
|
172
|
+
contentHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
173
|
+
activationVersion: z.number().int().positive(),
|
|
174
|
+
activatedAt: z.string().datetime(),
|
|
175
|
+
provenance: WorkspaceInstructionPolicySnapshotProvenance,
|
|
176
|
+
});
|
|
177
|
+
export type WorkspaceInstructionPolicySnapshotEntry = z.infer<
|
|
178
|
+
typeof WorkspaceInstructionPolicySnapshotEntry
|
|
179
|
+
>;
|
|
180
|
+
|
|
181
|
+
export const WorkspaceInstructionPolicySnapshot = z.object({
|
|
182
|
+
id: z.string().uuid(),
|
|
183
|
+
workspaceId: z.string().uuid(),
|
|
184
|
+
sessionId: z.string().uuid(),
|
|
185
|
+
turnId: z.string().uuid(),
|
|
186
|
+
attemptId: z.string().uuid(),
|
|
187
|
+
executionGeneration: z.number().int().positive(),
|
|
188
|
+
policyRole: WorkspaceInstructionPolicyRoleKey.nullable(),
|
|
189
|
+
roleSource: WorkspaceInstructionPolicyRoleSource,
|
|
190
|
+
entryHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
191
|
+
entries: z.array(WorkspaceInstructionPolicySnapshotEntry).max(3),
|
|
192
|
+
createdAt: z.string().datetime(),
|
|
193
|
+
});
|
|
194
|
+
export type WorkspaceInstructionPolicySnapshot = z.infer<typeof WorkspaceInstructionPolicySnapshot>;
|
|
195
|
+
|
|
196
|
+
export const ResolvedWorkspaceInstructionPolicySnapshotEntry =
|
|
197
|
+
WorkspaceInstructionPolicySnapshotEntry.extend({
|
|
198
|
+
content: z.string().min(1).max(WORKSPACE_INSTRUCTION_POLICY_CONTENT_MAX_CHARS),
|
|
199
|
+
});
|
|
200
|
+
export type ResolvedWorkspaceInstructionPolicySnapshotEntry = z.infer<
|
|
201
|
+
typeof ResolvedWorkspaceInstructionPolicySnapshotEntry
|
|
202
|
+
>;
|
|
203
|
+
|
|
204
|
+
export const ResolvedWorkspaceInstructionPolicySnapshot = WorkspaceInstructionPolicySnapshot.extend(
|
|
205
|
+
{
|
|
206
|
+
entries: z.array(ResolvedWorkspaceInstructionPolicySnapshotEntry).max(3),
|
|
207
|
+
},
|
|
208
|
+
);
|
|
209
|
+
export type ResolvedWorkspaceInstructionPolicySnapshot = z.infer<
|
|
210
|
+
typeof ResolvedWorkspaceInstructionPolicySnapshot
|
|
211
|
+
>;
|
|
212
|
+
|
|
141
213
|
export const WorkspaceInstructionPolicyActivationEvent = z.object({
|
|
142
214
|
id: z.string().uuid(),
|
|
143
215
|
accountId: z.string().uuid(),
|
|
@@ -159,7 +231,7 @@ export const CreateWorkspaceInstructionPolicyDraftRequest = z
|
|
|
159
231
|
.object({
|
|
160
232
|
kind: WorkspaceInstructionPolicyKind,
|
|
161
233
|
scope: WorkspaceInstructionPolicyScope,
|
|
162
|
-
roleKey:
|
|
234
|
+
roleKey: WorkspaceInstructionPolicyRoleKeyInput.nullable().default(null),
|
|
163
235
|
content: z
|
|
164
236
|
.string()
|
|
165
237
|
.min(1)
|
|
@@ -191,7 +263,7 @@ export type ImportLegacyWorkspaceInstructionPolicyDraftRequest = z.infer<
|
|
|
191
263
|
export const WorkspaceInstructionPolicyListQuery = z.object({
|
|
192
264
|
kind: WorkspaceInstructionPolicyKind.optional(),
|
|
193
265
|
scope: WorkspaceInstructionPolicyScope.optional(),
|
|
194
|
-
roleKey:
|
|
266
|
+
roleKey: WorkspaceInstructionPolicyRoleKeyInput.nullable().optional(),
|
|
195
267
|
afterRevision: z.coerce.number().int().positive().optional(),
|
|
196
268
|
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
197
269
|
});
|
package/dist/chunk-KGL5BVGF.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// src/slack-bot-scopes.ts
|
|
2
|
-
var OPENGENI_SLACK_BOT_REQUIRED_SCOPES = [
|
|
3
|
-
"app_mentions:read",
|
|
4
|
-
"canvases:read",
|
|
5
|
-
"channels:history",
|
|
6
|
-
"channels:read",
|
|
7
|
-
"chat:write",
|
|
8
|
-
"commands",
|
|
9
|
-
"files:read",
|
|
10
|
-
"groups:history",
|
|
11
|
-
"groups:read",
|
|
12
|
-
"im:history",
|
|
13
|
-
"im:read",
|
|
14
|
-
"im:write",
|
|
15
|
-
"mpim:history",
|
|
16
|
-
"mpim:read",
|
|
17
|
-
"users:read"
|
|
18
|
-
];
|
|
19
|
-
var OPENGENI_SLACK_BOT_SAFE_OPTIONAL_SCOPES = ["team:read"];
|
|
20
|
-
var OPENGENI_SLACK_BOT_FORBIDDEN_SCOPES = ["channels:join", "chat:write.public"];
|
|
21
|
-
function isOpenGeniSlackBotScopeAllowed(scope) {
|
|
22
|
-
return OPENGENI_SLACK_BOT_REQUIRED_SCOPES.includes(scope) || OPENGENI_SLACK_BOT_SAFE_OPTIONAL_SCOPES.includes(scope);
|
|
23
|
-
}
|
|
24
|
-
function areOpenGeniSlackBotScopesAccepted(grantedScopes) {
|
|
25
|
-
return OPENGENI_SLACK_BOT_REQUIRED_SCOPES.every((scope) => grantedScopes.includes(scope)) && grantedScopes.every(isOpenGeniSlackBotScopeAllowed);
|
|
26
|
-
}
|
|
27
|
-
function evaluateOpenGeniSlackBotScopes(grantedScopes) {
|
|
28
|
-
const granted = new Set(grantedScopes);
|
|
29
|
-
const missingRequired = OPENGENI_SLACK_BOT_REQUIRED_SCOPES.filter((scope) => !granted.has(scope));
|
|
30
|
-
const unsupported = [...granted].filter((scope) => !isOpenGeniSlackBotScopeAllowed(scope)).sort();
|
|
31
|
-
return {
|
|
32
|
-
accepted: areOpenGeniSlackBotScopesAccepted(grantedScopes),
|
|
33
|
-
missingRequired,
|
|
34
|
-
unsupported
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
OPENGENI_SLACK_BOT_REQUIRED_SCOPES,
|
|
40
|
-
OPENGENI_SLACK_BOT_SAFE_OPTIONAL_SCOPES,
|
|
41
|
-
OPENGENI_SLACK_BOT_FORBIDDEN_SCOPES,
|
|
42
|
-
areOpenGeniSlackBotScopesAccepted,
|
|
43
|
-
evaluateOpenGeniSlackBotScopes
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=chunk-KGL5BVGF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/slack-bot-scopes.ts"],"sourcesContent":["export const OPENGENI_SLACK_BOT_REQUIRED_SCOPES = [\n \"app_mentions:read\",\n \"canvases:read\",\n \"channels:history\",\n \"channels:read\",\n \"chat:write\",\n \"commands\",\n \"files:read\",\n \"groups:history\",\n \"groups:read\",\n \"im:history\",\n \"im:read\",\n \"im:write\",\n \"mpim:history\",\n \"mpim:read\",\n \"users:read\",\n] as const;\n\n/**\n * Optional bot grants that remain inside the shipped bot's read/identity\n * boundary. Every other unrequired scope fails closed, including unknown future\n * Slack scopes, so verification, core routing, and UI eligibility cannot drift.\n */\nexport const OPENGENI_SLACK_BOT_SAFE_OPTIONAL_SCOPES = [\"team:read\"] as const;\n\n/** @deprecated Use evaluateOpenGeniSlackBotScopes; an allowlist is the policy. */\nexport const OPENGENI_SLACK_BOT_FORBIDDEN_SCOPES = [\"channels:join\", \"chat:write.public\"] as const;\n\nexport type OpenGeniSlackBotScopePolicy = {\n accepted: boolean;\n missingRequired: string[];\n unsupported: string[];\n};\n\nfunction isOpenGeniSlackBotScopeAllowed(scope: string): boolean {\n return (\n (OPENGENI_SLACK_BOT_REQUIRED_SCOPES as readonly string[]).includes(scope) ||\n (OPENGENI_SLACK_BOT_SAFE_OPTIONAL_SCOPES as readonly string[]).includes(scope)\n );\n}\n\nexport function areOpenGeniSlackBotScopesAccepted(grantedScopes: readonly string[]): boolean {\n return (\n OPENGENI_SLACK_BOT_REQUIRED_SCOPES.every((scope) => grantedScopes.includes(scope)) &&\n grantedScopes.every(isOpenGeniSlackBotScopeAllowed)\n );\n}\n\nexport function evaluateOpenGeniSlackBotScopes(\n grantedScopes: readonly string[],\n): OpenGeniSlackBotScopePolicy {\n const granted = new Set(grantedScopes);\n const missingRequired = OPENGENI_SLACK_BOT_REQUIRED_SCOPES.filter((scope) => !granted.has(scope));\n const unsupported = [...granted].filter((scope) => !isOpenGeniSlackBotScopeAllowed(scope)).sort();\n return {\n accepted: areOpenGeniSlackBotScopesAccepted(grantedScopes),\n missingRequired,\n unsupported,\n };\n}\n"],"mappings":";AAAO,IAAM,qCAAqC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,IAAM,0CAA0C,CAAC,WAAW;AAG5D,IAAM,sCAAsC,CAAC,iBAAiB,mBAAmB;AAQxF,SAAS,+BAA+B,OAAwB;AAC9D,SACG,mCAAyD,SAAS,KAAK,KACvE,wCAA8D,SAAS,KAAK;AAEjF;AAEO,SAAS,kCAAkC,eAA2C;AAC3F,SACE,mCAAmC,MAAM,CAAC,UAAU,cAAc,SAAS,KAAK,CAAC,KACjF,cAAc,MAAM,8BAA8B;AAEtD;AAEO,SAAS,+BACd,eAC6B;AAC7B,QAAM,UAAU,IAAI,IAAI,aAAa;AACrC,QAAM,kBAAkB,mCAAmC,OAAO,CAAC,UAAU,CAAC,QAAQ,IAAI,KAAK,CAAC;AAChG,QAAM,cAAc,CAAC,GAAG,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,+BAA+B,KAAK,CAAC,EAAE,KAAK;AAChG,SAAO;AAAA,IACL,UAAU,kCAAkC,aAAa;AAAA,IACzD;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|