@automagik/omni 2.260714.1 → 2.260714.3
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.js +105 -3
- package/dist/sdk/types.generated.d.ts +1 -1
- package/dist/sdk/types.generated.d.ts.map +1 -1
- package/dist/server/index.js +181 -9
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -225883,7 +225883,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
225883
225883
|
var require_package7 = __commonJS((exports, module) => {
|
|
225884
225884
|
module.exports = {
|
|
225885
225885
|
name: "@omni/api",
|
|
225886
|
-
version: "2.260714.
|
|
225886
|
+
version: "2.260714.3",
|
|
225887
225887
|
type: "module",
|
|
225888
225888
|
exports: {
|
|
225889
225889
|
".": {
|
|
@@ -278135,7 +278135,16 @@ var init_schema2 = __esm(() => {
|
|
|
278135
278135
|
accessModes = ["disabled", "blocklist", "allowlist"];
|
|
278136
278136
|
settingValueTypes = ["string", "integer", "boolean", "json", "secret"];
|
|
278137
278137
|
apiKeyStatuses = ["active", "revoked", "expired"];
|
|
278138
|
-
apiKeyProfiles = [
|
|
278138
|
+
apiKeyProfiles = [
|
|
278139
|
+
"cs",
|
|
278140
|
+
"personal",
|
|
278141
|
+
"scout",
|
|
278142
|
+
"coworker",
|
|
278143
|
+
"admin",
|
|
278144
|
+
"console-viewer",
|
|
278145
|
+
"console-operator",
|
|
278146
|
+
"console-admin"
|
|
278147
|
+
];
|
|
278139
278148
|
eventTypes = CORE_EVENT_TYPES;
|
|
278140
278149
|
contentTypes = [
|
|
278141
278150
|
"text",
|
|
@@ -285031,8 +285040,80 @@ var init_genie_signature = __esm(() => {
|
|
|
285031
285040
|
});
|
|
285032
285041
|
|
|
285033
285042
|
// ../api/src/constants/profiles.ts
|
|
285034
|
-
var COWORKER_DEFAULT_DENYLIST_PRESET_KEY = "khal-os-core", PROFILES;
|
|
285043
|
+
var COWORKER_DEFAULT_DENYLIST_PRESET_KEY = "khal-os-core", CONSOLE_READ_SCOPES, CONSOLE_OPERATE_SCOPES, CONSOLE_ADMINISTRATION_SCOPES, CONSOLE_VIEWER_SCOPES, CONSOLE_OPERATOR_SCOPES, CONSOLE_ADMIN_SCOPES, PROFILES;
|
|
285035
285044
|
var init_profiles = __esm(() => {
|
|
285045
|
+
CONSOLE_READ_SCOPES = [
|
|
285046
|
+
"access:read",
|
|
285047
|
+
"agent-state:read",
|
|
285048
|
+
"agent-tasks:read",
|
|
285049
|
+
"agents:read",
|
|
285050
|
+
"auth:validate",
|
|
285051
|
+
"automations:read",
|
|
285052
|
+
"batch-jobs:read",
|
|
285053
|
+
"chats:read",
|
|
285054
|
+
"context:read",
|
|
285055
|
+
"conversations:read",
|
|
285056
|
+
"dead-letters:read",
|
|
285057
|
+
"event-ops:read",
|
|
285058
|
+
"events:read",
|
|
285059
|
+
"follow-up:read",
|
|
285060
|
+
"handoffs:read",
|
|
285061
|
+
"instances:read",
|
|
285062
|
+
"journeys:read",
|
|
285063
|
+
"logs:read",
|
|
285064
|
+
"media:read",
|
|
285065
|
+
"messages:read",
|
|
285066
|
+
"metrics:read",
|
|
285067
|
+
"payloads:read",
|
|
285068
|
+
"persons:read",
|
|
285069
|
+
"providers:read",
|
|
285070
|
+
"routes:read",
|
|
285071
|
+
"settings:read",
|
|
285072
|
+
"trust:read",
|
|
285073
|
+
"voice:read",
|
|
285074
|
+
"webhooks:read"
|
|
285075
|
+
];
|
|
285076
|
+
CONSOLE_OPERATE_SCOPES = [
|
|
285077
|
+
"agent-state:write",
|
|
285078
|
+
"agent-tasks:write",
|
|
285079
|
+
"automations:write",
|
|
285080
|
+
"batch-jobs:write",
|
|
285081
|
+
"chats:write",
|
|
285082
|
+
"context:write",
|
|
285083
|
+
"conversations:write",
|
|
285084
|
+
"dead-letters:write",
|
|
285085
|
+
"event-ops:write",
|
|
285086
|
+
"events:write",
|
|
285087
|
+
"follow-up:write",
|
|
285088
|
+
"instances:write",
|
|
285089
|
+
"media:write",
|
|
285090
|
+
"messages:send",
|
|
285091
|
+
"messages:write",
|
|
285092
|
+
"persons:write",
|
|
285093
|
+
"routes:write",
|
|
285094
|
+
"tts:synthesize",
|
|
285095
|
+
"turns:admin",
|
|
285096
|
+
"turns:close",
|
|
285097
|
+
"voice:write"
|
|
285098
|
+
];
|
|
285099
|
+
CONSOLE_ADMINISTRATION_SCOPES = [
|
|
285100
|
+
"access:write",
|
|
285101
|
+
"agents:write",
|
|
285102
|
+
"keys:read",
|
|
285103
|
+
"keys:write",
|
|
285104
|
+
"payloads:write",
|
|
285105
|
+
"providers:write",
|
|
285106
|
+
"settings:write",
|
|
285107
|
+
"trust:write",
|
|
285108
|
+
"webhooks:write"
|
|
285109
|
+
];
|
|
285110
|
+
CONSOLE_VIEWER_SCOPES = [...CONSOLE_READ_SCOPES];
|
|
285111
|
+
CONSOLE_OPERATOR_SCOPES = [...CONSOLE_READ_SCOPES, ...CONSOLE_OPERATE_SCOPES];
|
|
285112
|
+
CONSOLE_ADMIN_SCOPES = [
|
|
285113
|
+
...CONSOLE_READ_SCOPES,
|
|
285114
|
+
...CONSOLE_OPERATE_SCOPES,
|
|
285115
|
+
...CONSOLE_ADMINISTRATION_SCOPES
|
|
285116
|
+
];
|
|
285036
285117
|
PROFILES = {
|
|
285037
285118
|
cs: {
|
|
285038
285119
|
buckets: ["outgoing", "read", "context", "turn"],
|
|
@@ -285063,6 +285144,27 @@ var init_profiles = __esm(() => {
|
|
|
285063
285144
|
buckets: ["outgoing", "read", "context", "turn", "multimodal_in", "multimodal_out"],
|
|
285064
285145
|
requiresLocks: [],
|
|
285065
285146
|
adminOnlyFlag: true
|
|
285147
|
+
},
|
|
285148
|
+
"console-viewer": {
|
|
285149
|
+
buckets: [],
|
|
285150
|
+
requiresLocks: [],
|
|
285151
|
+
defaultOverrides: {
|
|
285152
|
+
extraScopes: CONSOLE_VIEWER_SCOPES
|
|
285153
|
+
}
|
|
285154
|
+
},
|
|
285155
|
+
"console-operator": {
|
|
285156
|
+
buckets: [],
|
|
285157
|
+
requiresLocks: [],
|
|
285158
|
+
defaultOverrides: {
|
|
285159
|
+
extraScopes: CONSOLE_OPERATOR_SCOPES
|
|
285160
|
+
}
|
|
285161
|
+
},
|
|
285162
|
+
"console-admin": {
|
|
285163
|
+
buckets: [],
|
|
285164
|
+
requiresLocks: [],
|
|
285165
|
+
defaultOverrides: {
|
|
285166
|
+
extraScopes: CONSOLE_ADMIN_SCOPES
|
|
285167
|
+
}
|
|
285066
285168
|
}
|
|
285067
285169
|
};
|
|
285068
285170
|
});
|
|
@@ -285420,6 +285522,17 @@ var init_scopes = __esm(() => {
|
|
|
285420
285522
|
"POST /events/search": "events:read",
|
|
285421
285523
|
"GET /events/:id": "events:read",
|
|
285422
285524
|
"GET /events/by-sender/:senderId": "events:read",
|
|
285525
|
+
"GET /follow-up/agents/:id": "follow-up:read",
|
|
285526
|
+
"PUT /follow-up/agents/:id": "follow-up:write",
|
|
285527
|
+
"DELETE /follow-up/agents/:id": "follow-up:write",
|
|
285528
|
+
"GET /follow-up/instances/:id": "follow-up:read",
|
|
285529
|
+
"PUT /follow-up/instances/:id": "follow-up:write",
|
|
285530
|
+
"DELETE /follow-up/instances/:id": "follow-up:write",
|
|
285531
|
+
"GET /follow-up/chats/:id": "follow-up:read",
|
|
285532
|
+
"PUT /follow-up/chats/:id": "follow-up:write",
|
|
285533
|
+
"DELETE /follow-up/chats/:id": "follow-up:write",
|
|
285534
|
+
"GET /handoffs": "handoffs:read",
|
|
285535
|
+
"GET /handoffs/:id": "handoffs:read",
|
|
285423
285536
|
"GET /instances": "instances:read",
|
|
285424
285537
|
"GET /instances/supported-channels": "instances:read",
|
|
285425
285538
|
"GET /instances/:id": "instances:read",
|
|
@@ -285553,6 +285666,15 @@ var init_scopes = __esm(() => {
|
|
|
285553
285666
|
"POST /turns/:id/close": "turns:admin",
|
|
285554
285667
|
"POST /turns/close-all": "turns:admin",
|
|
285555
285668
|
"POST /turns/close": "turns:close",
|
|
285669
|
+
"POST /trust/handshake": "trust:write",
|
|
285670
|
+
"GET /trust/hosts": "trust:read",
|
|
285671
|
+
"GET /trust/hosts/:id": "trust:read",
|
|
285672
|
+
"PATCH /trust/hosts/:id": "trust:write",
|
|
285673
|
+
"DELETE /trust/hosts/:id": "trust:write",
|
|
285674
|
+
"POST /voice/join": "voice:write",
|
|
285675
|
+
"POST /voice/leave": "voice:write",
|
|
285676
|
+
"GET /voice/sessions": "voice:read",
|
|
285677
|
+
"GET /voice/sessions/:id": "voice:read",
|
|
285556
285678
|
"GET /webhook-sources": "webhooks:read",
|
|
285557
285679
|
"GET /webhook-sources/:id": "webhooks:read",
|
|
285558
285680
|
"POST /webhook-sources": "webhooks:write",
|
|
@@ -346319,7 +346441,7 @@ function registerAuthSchemas(registry4) {
|
|
|
346319
346441
|
registry4.register("AuthValidateResponse", AuthValidateResponseSchema);
|
|
346320
346442
|
registry4.registerPath({
|
|
346321
346443
|
method: "post",
|
|
346322
|
-
path: "/
|
|
346444
|
+
path: "/auth/validate",
|
|
346323
346445
|
operationId: "validateApiKey",
|
|
346324
346446
|
tags: ["Auth"],
|
|
346325
346447
|
summary: "Validate API key",
|
|
@@ -349766,9 +349888,28 @@ var init_webhooks2 = __esm(() => {
|
|
|
349766
349888
|
});
|
|
349767
349889
|
|
|
349768
349890
|
// ../api/src/routes/openapi.ts
|
|
349891
|
+
function annotateScopes(document2) {
|
|
349892
|
+
const paths = document2.paths;
|
|
349893
|
+
if (!paths)
|
|
349894
|
+
return;
|
|
349895
|
+
for (const [pathKey, pathItem] of Object.entries(paths)) {
|
|
349896
|
+
if (!pathItem)
|
|
349897
|
+
continue;
|
|
349898
|
+
const honoPath = pathKey.replace(/\{([^}]+)\}/g, ":$1");
|
|
349899
|
+
for (const method of HTTP_METHODS) {
|
|
349900
|
+
const operation = pathItem[method];
|
|
349901
|
+
if (!operation || typeof operation !== "object")
|
|
349902
|
+
continue;
|
|
349903
|
+
const scope = SCOPE_MAP[`${method.toUpperCase()} ${honoPath}`];
|
|
349904
|
+
if (scope) {
|
|
349905
|
+
operation["x-omni-scope"] = scope;
|
|
349906
|
+
}
|
|
349907
|
+
}
|
|
349908
|
+
}
|
|
349909
|
+
}
|
|
349769
349910
|
function generateOpenApiSpec() {
|
|
349770
349911
|
const generator = new OpenApiGeneratorV3(registry4.definitions);
|
|
349771
|
-
|
|
349912
|
+
const document2 = generator.generateDocument({
|
|
349772
349913
|
openapi: "3.0.3",
|
|
349773
349914
|
info: openApiInfo,
|
|
349774
349915
|
servers: [
|
|
@@ -349784,12 +349925,15 @@ function generateOpenApiSpec() {
|
|
|
349784
349925
|
],
|
|
349785
349926
|
tags: apiTags
|
|
349786
349927
|
});
|
|
349928
|
+
annotateScopes(document2);
|
|
349929
|
+
return document2;
|
|
349787
349930
|
}
|
|
349788
|
-
var registry4, openapiRoutes, openApiSpec;
|
|
349931
|
+
var registry4, openapiRoutes, HTTP_METHODS, openApiSpec;
|
|
349789
349932
|
var init_openapi2 = __esm(() => {
|
|
349790
349933
|
init_dist4();
|
|
349791
349934
|
init_dist5();
|
|
349792
349935
|
init_dist2();
|
|
349936
|
+
init_scopes();
|
|
349793
349937
|
init_openapi();
|
|
349794
349938
|
init_zod_openapi();
|
|
349795
349939
|
init_access2();
|
|
@@ -349841,6 +349985,7 @@ var init_openapi2 = __esm(() => {
|
|
|
349841
349985
|
registerFollowUpSchemas(registry4);
|
|
349842
349986
|
registerVoiceSchemas(registry4);
|
|
349843
349987
|
openapiRoutes = new Hono2;
|
|
349988
|
+
HTTP_METHODS = ["get", "put", "post", "delete", "patch", "options", "head", "trace"];
|
|
349844
349989
|
openApiSpec = generateOpenApiSpec();
|
|
349845
349990
|
openapiRoutes.get("/openapi.json", (c) => {
|
|
349846
349991
|
return c.json(openApiSpec);
|
|
@@ -356630,6 +356775,18 @@ function normalizeOverrides(overrides) {
|
|
|
356630
356775
|
denylistPresetKey: overrides.denylistPresetKey === null ? undefined : overrides.denylistPresetKey
|
|
356631
356776
|
};
|
|
356632
356777
|
}
|
|
356778
|
+
function enforceMintCeiling(c, requestedScopes) {
|
|
356779
|
+
const callerScopes = c.get("apiKey")?.scopes ?? [];
|
|
356780
|
+
const exceeding = requestedScopes.filter((scope) => !ApiKeyService.scopeAllows(callerScopes, scope));
|
|
356781
|
+
if (exceeding.length === 0)
|
|
356782
|
+
return null;
|
|
356783
|
+
return c.json({
|
|
356784
|
+
error: {
|
|
356785
|
+
code: "FORBIDDEN",
|
|
356786
|
+
message: `Cannot mint a key whose scopes exceed the caller's own. Disallowed: ${exceeding.join(", ")}`
|
|
356787
|
+
}
|
|
356788
|
+
}, 403);
|
|
356789
|
+
}
|
|
356633
356790
|
async function handleProfileCreate(c, data, services) {
|
|
356634
356791
|
try {
|
|
356635
356792
|
const resolved = resolveProfile({
|
|
@@ -356641,6 +356798,9 @@ async function handleProfileCreate(c, data, services) {
|
|
|
356641
356798
|
overrides: normalizeOverrides(data.overrides),
|
|
356642
356799
|
denylistPresetKey: data.denylistPresetKey
|
|
356643
356800
|
});
|
|
356801
|
+
const ceilingDenied = enforceMintCeiling(c, resolved.scopes);
|
|
356802
|
+
if (ceilingDenied)
|
|
356803
|
+
return ceilingDenied;
|
|
356644
356804
|
const result = await services.apiKeys.create({
|
|
356645
356805
|
name: data.name,
|
|
356646
356806
|
description: data.description,
|
|
@@ -356673,6 +356833,9 @@ async function handleLegacyCreate(c, data, services) {
|
|
|
356673
356833
|
if (!data.scopes || data.scopes.length === 0) {
|
|
356674
356834
|
return c.json({ error: { code: "VALIDATION_ERROR", message: "scopes is required when no profile is supplied" } }, 400);
|
|
356675
356835
|
}
|
|
356836
|
+
const ceilingDenied = enforceMintCeiling(c, data.scopes);
|
|
356837
|
+
if (ceilingDenied)
|
|
356838
|
+
return ceilingDenied;
|
|
356676
356839
|
const result = await services.apiKeys.create({
|
|
356677
356840
|
name: data.name,
|
|
356678
356841
|
description: data.description,
|
|
@@ -356691,8 +356854,17 @@ var init_keys = __esm(() => {
|
|
|
356691
356854
|
init_zod();
|
|
356692
356855
|
init_resolve_profile();
|
|
356693
356856
|
init_date_query();
|
|
356857
|
+
init_api_keys();
|
|
356694
356858
|
keysRoutes = new Hono2;
|
|
356695
|
-
NON_ADMIN_PROFILES = [
|
|
356859
|
+
NON_ADMIN_PROFILES = [
|
|
356860
|
+
"cs",
|
|
356861
|
+
"personal",
|
|
356862
|
+
"scout",
|
|
356863
|
+
"coworker",
|
|
356864
|
+
"console-viewer",
|
|
356865
|
+
"console-operator",
|
|
356866
|
+
"console-admin"
|
|
356867
|
+
];
|
|
356696
356868
|
profileOverridesSchema = exports_external.object({
|
|
356697
356869
|
add: exports_external.array(exports_external.string()).optional(),
|
|
356698
356870
|
remove: exports_external.array(exports_external.string()).optional(),
|
|
@@ -356706,7 +356878,7 @@ var init_keys = __esm(() => {
|
|
|
356706
356878
|
instanceIds: exports_external.array(exports_external.string().uuid()).optional().describe("Restrict key to specific instance IDs"),
|
|
356707
356879
|
rateLimit: exports_external.number().int().positive().optional().describe("Rate limit in requests per minute"),
|
|
356708
356880
|
expiresAt: exports_external.string().datetime().optional().describe("Expiration timestamp (ISO 8601)"),
|
|
356709
|
-
profile: exports_external.enum(NON_ADMIN_PROFILES).optional().describe("Profile template: cs, personal, scout, coworker. admin is CLI-only and rejected here."),
|
|
356881
|
+
profile: exports_external.enum(NON_ADMIN_PROFILES).optional().describe("Profile template: cs, personal, scout, coworker, console-viewer, console-operator, console-admin. " + "admin is CLI-only and rejected here."),
|
|
356710
356882
|
overrides: profileOverridesSchema.optional().describe("Tenant overrides merged on top of the profile template"),
|
|
356711
356883
|
chatAllowlist: exports_external.array(exports_external.string()).optional().describe("Chats this key may target (profile-aware semantics)"),
|
|
356712
356884
|
instanceAllowlist: exports_external.array(exports_external.string().uuid()).optional().describe("Instances this key may target"),
|
|
@@ -356739,7 +356911,7 @@ var init_keys = __esm(() => {
|
|
|
356739
356911
|
cursor: exports_external.string().optional().describe("Pagination cursor")
|
|
356740
356912
|
});
|
|
356741
356913
|
keysRoutes.post("/", async (c, next) => {
|
|
356742
|
-
const raw2 = await c.req.
|
|
356914
|
+
const raw2 = await c.req.json().catch(() => null);
|
|
356743
356915
|
if (raw2 && typeof raw2 === "object" && raw2.profile === "admin") {
|
|
356744
356916
|
return c.json({
|
|
356745
356917
|
error: {
|