@every-app/sdk 0.3.0-rc.2 → 0.3.0-rc.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.
Files changed (73) hide show
  1. package/dist/cloudflare/index.d.ts +2 -2
  2. package/dist/cloudflare/index.d.ts.map +1 -1
  3. package/dist/cloudflare/index.js +1 -1
  4. package/dist/cloudflare/sentinel.d.ts +39 -1
  5. package/dist/cloudflare/sentinel.d.ts.map +1 -1
  6. package/dist/cloudflare/sentinel.js +22 -1
  7. package/dist/cloudflare/worker.d.ts +119 -2
  8. package/dist/cloudflare/worker.d.ts.map +1 -1
  9. package/dist/cloudflare/worker.js +90 -6
  10. package/dist/internal/aiDefault.d.ts +141 -0
  11. package/dist/internal/aiDefault.d.ts.map +1 -0
  12. package/dist/internal/aiDefault.js +204 -0
  13. package/dist/internal/aiProviders.d.ts +4 -1
  14. package/dist/internal/aiProviders.d.ts.map +1 -1
  15. package/dist/internal/aiProviders.js +5 -1
  16. package/dist/internal/appSettings.d.ts +20 -2
  17. package/dist/internal/appSettings.d.ts.map +1 -1
  18. package/dist/internal/appSettings.js +53 -7
  19. package/dist/internal/audit.d.ts +108 -0
  20. package/dist/internal/audit.d.ts.map +1 -0
  21. package/dist/internal/audit.js +235 -0
  22. package/dist/internal/capabilities.d.ts +275 -6
  23. package/dist/internal/capabilities.d.ts.map +1 -1
  24. package/dist/internal/capabilities.js +111 -0
  25. package/dist/internal/catalog/index.d.ts +38 -1
  26. package/dist/internal/catalog/index.d.ts.map +1 -1
  27. package/dist/internal/catalog/inference.d.ts +38 -1
  28. package/dist/internal/catalog/inference.d.ts.map +1 -1
  29. package/dist/internal/catalog/inference.js +33 -1
  30. package/dist/internal/devProviders.d.ts +2 -2
  31. package/dist/internal/devProviders.d.ts.map +1 -1
  32. package/dist/internal/devProviders.js +19 -1
  33. package/dist/internal/events.d.ts +13 -2
  34. package/dist/internal/events.d.ts.map +1 -1
  35. package/dist/internal/events.js +19 -3
  36. package/dist/internal/index.d.ts +4 -0
  37. package/dist/internal/index.d.ts.map +1 -1
  38. package/dist/internal/index.js +4 -0
  39. package/dist/internal/oauthPresets.d.ts +29 -0
  40. package/dist/internal/oauthPresets.d.ts.map +1 -0
  41. package/dist/internal/oauthPresets.js +534 -0
  42. package/dist/internal/oauthScopes.d.ts +56 -1
  43. package/dist/internal/oauthScopes.d.ts.map +1 -1
  44. package/dist/internal/oauthScopes.js +98 -4
  45. package/dist/internal/oauthSpec.d.ts +59 -0
  46. package/dist/internal/oauthSpec.d.ts.map +1 -0
  47. package/dist/internal/oauthSpec.js +676 -0
  48. package/dist/internal/protocol.d.ts +11 -0
  49. package/dist/internal/protocol.d.ts.map +1 -1
  50. package/dist/internal/protocol.js +9 -0
  51. package/dist/internal/providerRegistry.d.ts +17 -6
  52. package/dist/internal/providerRegistry.d.ts.map +1 -1
  53. package/dist/internal/providerRegistry.js +47 -2
  54. package/dist/internal/providerSpec.d.ts +11 -7
  55. package/dist/internal/providerSpec.d.ts.map +1 -1
  56. package/dist/internal/providerSpec.js +134 -37
  57. package/dist/internal/signInProviders.d.ts.map +1 -1
  58. package/dist/internal/signInProviders.js +11 -4
  59. package/dist/server/ai.d.ts +45 -0
  60. package/dist/server/ai.d.ts.map +1 -0
  61. package/dist/server/ai.js +40 -0
  62. package/dist/server/connectUrl.d.ts +21 -0
  63. package/dist/server/connectUrl.d.ts.map +1 -0
  64. package/dist/server/connectUrl.js +37 -0
  65. package/dist/server/gatewayFetch.d.ts.map +1 -1
  66. package/dist/server/gatewayFetch.js +72 -8
  67. package/dist/server/index.d.ts +4 -2
  68. package/dist/server/index.d.ts.map +1 -1
  69. package/dist/server/index.js +3 -1
  70. package/dist/server/integrationFetch.d.ts +39 -2
  71. package/dist/server/integrationFetch.d.ts.map +1 -1
  72. package/dist/server/integrationFetch.js +177 -13
  73. package/package.json +1 -1
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The audit log's shared reading of an event row: who did it, what it was
3
+ * about, and what the type means in plain words. Admin → Activity → Audit,
4
+ * `everyapp workspace audit` and `everyapp_workspace_audit` all show the
5
+ * same columns, so the three derive them here, from the stored `actor`
6
+ * and `data` (the catalogue's builders decide what those hold; the
7
+ * gateway's `summarize` writes the one-line summary from the same data).
8
+ * Nothing here reads a secret, a tool's arguments or result, or a mail
9
+ * body: the rows never hold one.
10
+ */
11
+ import { type EventGroup, type EventTypeInfo } from "./events.js";
12
+ /** Who caused an audit event, as every surface shows it. */
13
+ export interface AuditActor {
14
+ /** `user`, `agent`, `app`, `operator`, `gateway`, or what the row says. */
15
+ kind: string;
16
+ /** The user id, the credential id (an agent), the app id, the operator's id; null for the gateway. */
17
+ id: string | null;
18
+ email: string | null;
19
+ /** A member's name, or the AI app's name for an agent. */
20
+ name: string | null;
21
+ }
22
+ /** What an audit event is about, picked from its `data` by the keys the catalogue uses. */
23
+ export interface AuditSubject {
24
+ app?: {
25
+ id: string;
26
+ name: string | null;
27
+ };
28
+ user?: {
29
+ id: string;
30
+ email: string | null;
31
+ name: string | null;
32
+ };
33
+ group?: {
34
+ id: string;
35
+ name: string | null;
36
+ };
37
+ provider?: {
38
+ id: string;
39
+ name: string | null;
40
+ };
41
+ mcpApp?: {
42
+ id: string;
43
+ name: string | null;
44
+ };
45
+ subscription?: {
46
+ id: string;
47
+ name: string | null;
48
+ };
49
+ /** `member.invited`: whom. */
50
+ invitation?: {
51
+ email: string;
52
+ role: string | null;
53
+ };
54
+ /** Setting names an event lists (never a value): unmet, changed, added, removed. */
55
+ settings?: string[];
56
+ tool?: string;
57
+ /** The AI app of a connection or a blocked call. */
58
+ client?: string;
59
+ /** A personal access token's name. */
60
+ token?: string;
61
+ }
62
+ /** The stored `actor` (a JSON string or the parsed object) as the surfaces show it. */
63
+ export declare function auditActorOf(actor: unknown): AuditActor;
64
+ /**
65
+ * The Who cell: a person by name or email, "agent · Claude" for an AI
66
+ * client, "CLI · <operator>" for the operator's command line, "app · crm"
67
+ * for an app's own event, "Gateway" for what the gateway did by itself.
68
+ */
69
+ export declare function auditActorLabel(actor: AuditActor): string;
70
+ /** The plain-words label for a type: the catalogue's description, or "App event" for an app's own. */
71
+ export declare function auditTypeLabel(type: string): string;
72
+ /** What the event is about, from its stored `data`. */
73
+ export declare function auditSubjectOf(type: string, data: unknown): AuditSubject;
74
+ /** The Subject cell: the first thing the event is about, by name, then what else it names. */
75
+ export declare function auditSubjectLabel(subject: AuditSubject): string;
76
+ /**
77
+ * What the audit log leaves out unless asked for by type: `ping` (a test)
78
+ * and `tool.*` (the tool-calls view lists every call, blocked or not).
79
+ */
80
+ export declare const AUDIT_DEFAULT_EXCLUDED: readonly string[];
81
+ /**
82
+ * Whether an event of `type` is in the audit log's default view, or
83
+ * matches the type filter given (an exact type, or a prefix like
84
+ * `member.*`; `*` is everything, the excluded included).
85
+ */
86
+ export declare function auditTypeMatches(type: string, filter: string | undefined): boolean;
87
+ /** The SQL the filter translates to: `type = ?` or `type LIKE 'prefix.%'`; null for `*`. */
88
+ export declare function auditTypeCondition(filter: string): {
89
+ op: "eq";
90
+ value: string;
91
+ } | {
92
+ op: "prefix";
93
+ value: string;
94
+ } | null;
95
+ /** A type-filter value someone typed, cleaned, or null for none. */
96
+ export declare function auditTypeFilterOf(value: unknown): string | undefined;
97
+ export interface AuditTypeGroup {
98
+ group: EventGroup;
99
+ label: string;
100
+ /** `member.*` */
101
+ pattern: string;
102
+ types: EventTypeInfo[];
103
+ }
104
+ /** The groups' plain-words headings, as the Add-subscription dialog names them. */
105
+ export declare const AUDIT_GROUP_LABELS: Partial<Record<EventGroup, string>>;
106
+ /** The catalogue grouped for a type filter, in catalogue order, `ping` left out. */
107
+ export declare function auditTypeGroups(types?: readonly EventTypeInfo[]): AuditTypeGroup[];
108
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/internal/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAML,K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F;AACnF,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAWlE,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,eAAe,CAC7B,KAAK,GAAE,SAAS,aAAa,EAAgB,GAC5C,cAAc,EAAE,CAgBlB"}
@@ -0,0 +1,235 @@
1
+ /**
2
+ * The audit log's shared reading of an event row: who did it, what it was
3
+ * about, and what the type means in plain words. Admin → Activity → Audit,
4
+ * `everyapp workspace audit` and `everyapp_workspace_audit` all show the
5
+ * same columns, so the three derive them here, from the stored `actor`
6
+ * and `data` (the catalogue's builders decide what those hold; the
7
+ * gateway's `summarize` writes the one-line summary from the same data).
8
+ * Nothing here reads a secret, a tool's arguments or result, or a mail
9
+ * body: the rows never hold one.
10
+ */
11
+ import { APP_EVENT_PREFIX, EVENT_TYPES, eventPatternMatches, eventTypeInfo, isAppOwnEventType, } from "./events.js";
12
+ function obj(value) {
13
+ return value && typeof value === "object" && !Array.isArray(value)
14
+ ? value
15
+ : {};
16
+ }
17
+ function str(value) {
18
+ return typeof value === "string" && value.length > 0 ? value : null;
19
+ }
20
+ function strings(value) {
21
+ return Array.isArray(value)
22
+ ? value.filter((item) => typeof item === "string")
23
+ : [];
24
+ }
25
+ /** The stored `actor` (a JSON string or the parsed object) as the surfaces show it. */
26
+ export function auditActorOf(actor) {
27
+ let parsed = actor;
28
+ if (typeof actor === "string") {
29
+ try {
30
+ parsed = JSON.parse(actor);
31
+ }
32
+ catch {
33
+ parsed = {};
34
+ }
35
+ }
36
+ const who = obj(parsed);
37
+ return {
38
+ kind: str(who.kind) ?? "gateway",
39
+ id: str(who.id),
40
+ email: str(who.email),
41
+ name: str(who.name),
42
+ };
43
+ }
44
+ /**
45
+ * The Who cell: a person by name or email, "agent · Claude" for an AI
46
+ * client, "CLI · <operator>" for the operator's command line, "app · crm"
47
+ * for an app's own event, "Gateway" for what the gateway did by itself.
48
+ */
49
+ export function auditActorLabel(actor) {
50
+ switch (actor.kind) {
51
+ case "user":
52
+ return actor.name ?? actor.email ?? actor.id ?? "a member";
53
+ case "agent":
54
+ return `agent · ${actor.name ?? actor.id ?? "AI app"}`;
55
+ case "operator":
56
+ return `CLI · ${actor.email ?? actor.id ?? "operator"}`;
57
+ case "app":
58
+ return `app · ${actor.id ?? "app"}`;
59
+ case "gateway":
60
+ return "Gateway";
61
+ default:
62
+ return actor.name ?? actor.email ?? actor.id ?? actor.kind;
63
+ }
64
+ }
65
+ /** The plain-words label for a type: the catalogue's description, or "App event" for an app's own. */
66
+ export function auditTypeLabel(type) {
67
+ const info = eventTypeInfo(type);
68
+ if (info)
69
+ return info.description;
70
+ if (isAppOwnEventType(type)) {
71
+ const rest = type.slice(APP_EVENT_PREFIX.length);
72
+ return `App event: ${rest.slice(rest.indexOf(".") + 1)}`;
73
+ }
74
+ return type;
75
+ }
76
+ function named(value) {
77
+ const subject = obj(value);
78
+ const id = str(subject.id) ?? str(subject.rowId);
79
+ return id ? { id, name: str(subject.name) } : undefined;
80
+ }
81
+ /** What the event is about, from its stored `data`. */
82
+ export function auditSubjectOf(type, data) {
83
+ const d = obj(data);
84
+ const subject = {};
85
+ const app = named(d.app);
86
+ if (app) {
87
+ if (type.startsWith("mcp_app."))
88
+ subject.mcpApp = app;
89
+ else
90
+ subject.app = app;
91
+ }
92
+ else if (isAppOwnEventType(type)) {
93
+ const rest = type.slice(APP_EVENT_PREFIX.length);
94
+ subject.app = { id: rest.slice(0, rest.indexOf(".")), name: null };
95
+ }
96
+ const user = obj(d.user);
97
+ if (str(user.id)) {
98
+ subject.user = {
99
+ id: str(user.id),
100
+ email: str(user.email),
101
+ name: str(user.name),
102
+ };
103
+ }
104
+ const group = named(d.group);
105
+ if (group)
106
+ subject.group = group;
107
+ const provider = named(d.provider);
108
+ if (provider)
109
+ subject.provider = provider;
110
+ const subscription = named(d.subscription);
111
+ if (subscription)
112
+ subject.subscription = subscription;
113
+ const invitation = obj(d.invitation);
114
+ if (str(invitation.email)) {
115
+ subject.invitation = {
116
+ email: str(invitation.email),
117
+ role: str(invitation.role),
118
+ };
119
+ }
120
+ const settings = [
121
+ ...strings(d.settings),
122
+ ...strings(d.unmet),
123
+ ...strings(d.changed),
124
+ ...strings(d.names),
125
+ ];
126
+ if (settings.length > 0)
127
+ subject.settings = [...new Set(settings)];
128
+ const tool = str(d.tool);
129
+ if (tool)
130
+ subject.tool = tool;
131
+ const client = str(obj(d.client).name) ?? str(obj(d.connection).clientName);
132
+ if (client)
133
+ subject.client = client;
134
+ if (type.startsWith("token.") && str(d.name))
135
+ subject.token = str(d.name);
136
+ return subject;
137
+ }
138
+ /** The Subject cell: the first thing the event is about, by name, then what else it names. */
139
+ export function auditSubjectLabel(subject) {
140
+ const parts = [];
141
+ const app = subject.app ?? subject.mcpApp;
142
+ if (app)
143
+ parts.push(app.name ?? app.id);
144
+ if (subject.user) {
145
+ parts.push(subject.user.name ?? subject.user.email ?? subject.user.id);
146
+ }
147
+ if (subject.invitation)
148
+ parts.push(subject.invitation.email);
149
+ if (subject.group)
150
+ parts.push(subject.group.name ?? subject.group.id);
151
+ if (subject.provider) {
152
+ parts.push(subject.provider.name ?? subject.provider.id);
153
+ }
154
+ if (subject.subscription) {
155
+ parts.push(subject.subscription.name ?? subject.subscription.id);
156
+ }
157
+ if (subject.token)
158
+ parts.push(subject.token);
159
+ if (subject.tool)
160
+ parts.push(subject.tool);
161
+ if (subject.client)
162
+ parts.push(subject.client);
163
+ if (subject.settings)
164
+ parts.push(subject.settings.join(", "));
165
+ return parts.join(" · ");
166
+ }
167
+ /**
168
+ * What the audit log leaves out unless asked for by type: `ping` (a test)
169
+ * and `tool.*` (the tool-calls view lists every call, blocked or not).
170
+ */
171
+ export const AUDIT_DEFAULT_EXCLUDED = ["ping", "tool.*"];
172
+ /**
173
+ * Whether an event of `type` is in the audit log's default view, or
174
+ * matches the type filter given (an exact type, or a prefix like
175
+ * `member.*`; `*` is everything, the excluded included).
176
+ */
177
+ export function auditTypeMatches(type, filter) {
178
+ if (filter === undefined) {
179
+ return !AUDIT_DEFAULT_EXCLUDED.some((pattern) => eventPatternMatches(pattern, type));
180
+ }
181
+ if (filter === "*")
182
+ return true;
183
+ return eventPatternMatches(filter, type);
184
+ }
185
+ /** The SQL the filter translates to: `type = ?` or `type LIKE 'prefix.%'`; null for `*`. */
186
+ export function auditTypeCondition(filter) {
187
+ if (filter === "*")
188
+ return null;
189
+ if (filter.endsWith(".*"))
190
+ return { op: "prefix", value: filter.slice(0, -1) };
191
+ return { op: "eq", value: filter };
192
+ }
193
+ /** A type-filter value someone typed, cleaned, or null for none. */
194
+ export function auditTypeFilterOf(value) {
195
+ const text = typeof value === "string" ? value.trim() : "";
196
+ return text.length > 0 ? text : undefined;
197
+ }
198
+ /** A group with no heading here reads as its name ("organization" → "Organization"). */
199
+ function groupHeading(group) {
200
+ const words = group.replace(/_/g, " ");
201
+ return words.charAt(0).toUpperCase() + words.slice(1);
202
+ }
203
+ /** The groups' plain-words headings, as the Add-subscription dialog names them. */
204
+ export const AUDIT_GROUP_LABELS = {
205
+ member: "Members",
206
+ app: "Apps",
207
+ cap: "Monthly caps",
208
+ tool: "Agent tool calls",
209
+ connection: "AI connections",
210
+ token: "Tokens",
211
+ access: "Cloudflare Access",
212
+ mcp_app: "MCP apps",
213
+ provider: "API providers",
214
+ ping: "Test",
215
+ };
216
+ /** The catalogue grouped for a type filter, in catalogue order, `ping` left out. */
217
+ export function auditTypeGroups(types = EVENT_TYPES) {
218
+ const groups = new Map();
219
+ for (const info of types) {
220
+ if (info.group === "ping")
221
+ continue;
222
+ const existing = groups.get(info.group);
223
+ if (existing)
224
+ existing.types.push(info);
225
+ else {
226
+ groups.set(info.group, {
227
+ group: info.group,
228
+ label: AUDIT_GROUP_LABELS[info.group] ?? groupHeading(info.group),
229
+ pattern: `${info.group}.*`,
230
+ types: [info],
231
+ });
232
+ }
233
+ }
234
+ return [...groups.values()];
235
+ }