@proveanything/smartlinks 2.0.18 → 2.0.20

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/openapi.yaml CHANGED
@@ -72,6 +72,8 @@ tags:
72
72
  description: Product facet querying and aggregation.
73
73
  - name: form
74
74
  description: Form definitions and submissions.
75
+ - name: functions
76
+ description: functions API
75
77
  - name: integrations
76
78
  description: Third-party integration flows and imports.
77
79
  - name: interactions
@@ -1081,6 +1083,39 @@ paths:
1081
1083
  application/json:
1082
1084
  schema:
1083
1085
  $ref: "#/components/schemas/AISearchPhotosRequest"
1086
+ /admin/collection/{collectionId}/ai/sessions:
1087
+ post:
1088
+ tags:
1089
+ - sessions
1090
+ summary: Persisted AI assistant sessions (admin scope) — durable conversation history for admin/host assistants.
1091
+ operationId: sessions_create
1092
+ security:
1093
+ - bearerAuth: []
1094
+ parameters:
1095
+ - name: collectionId
1096
+ in: path
1097
+ required: true
1098
+ schema:
1099
+ type: string
1100
+ responses:
1101
+ 200:
1102
+ description: Success
1103
+ content:
1104
+ application/json:
1105
+ schema:
1106
+ $ref: "#/components/schemas/AiSession"
1107
+ 400:
1108
+ description: Bad request
1109
+ 401:
1110
+ description: Unauthorized
1111
+ 404:
1112
+ description: Not found
1113
+ requestBody:
1114
+ required: true
1115
+ content:
1116
+ application/json:
1117
+ schema:
1118
+ $ref: "#/components/schemas/AiSessionCreate"
1084
1119
  /admin/collection/{collectionId}/ai/sessions/stats:
1085
1120
  get:
1086
1121
  tags:
@@ -1108,6 +1143,77 @@ paths:
1108
1143
  description: Unauthorized
1109
1144
  404:
1110
1145
  description: Not found
1146
+ /admin/collection/{collectionId}/ai/sessions/{id}:
1147
+ get:
1148
+ tags:
1149
+ - sessions
1150
+ summary: Get one session, including its full transcript.
1151
+ operationId: sessions_get
1152
+ security:
1153
+ - bearerAuth: []
1154
+ parameters:
1155
+ - name: collectionId
1156
+ in: path
1157
+ required: true
1158
+ schema:
1159
+ type: string
1160
+ - name: id
1161
+ in: path
1162
+ required: true
1163
+ schema:
1164
+ type: string
1165
+ responses:
1166
+ 200:
1167
+ description: Success
1168
+ content:
1169
+ application/json:
1170
+ schema:
1171
+ $ref: "#/components/schemas/AiSession"
1172
+ 400:
1173
+ description: Bad request
1174
+ 401:
1175
+ description: Unauthorized
1176
+ 404:
1177
+ description: Not found
1178
+ /admin/collection/{collectionId}/ai/sessions/{id}/append:
1179
+ post:
1180
+ tags:
1181
+ - sessions
1182
+ summary: Append Responses items (input/output/tool) to a session — the manual-persistence path.
1183
+ operationId: sessions_append
1184
+ security:
1185
+ - bearerAuth: []
1186
+ parameters:
1187
+ - name: collectionId
1188
+ in: path
1189
+ required: true
1190
+ schema:
1191
+ type: string
1192
+ - name: id
1193
+ in: path
1194
+ required: true
1195
+ schema:
1196
+ type: string
1197
+ responses:
1198
+ 200:
1199
+ description: Success
1200
+ content:
1201
+ application/json:
1202
+ schema:
1203
+ $ref: "#/components/schemas/AiSession"
1204
+ 400:
1205
+ description: Bad request
1206
+ 401:
1207
+ description: Unauthorized
1208
+ 404:
1209
+ description: Not found
1210
+ requestBody:
1211
+ required: true
1212
+ content:
1213
+ application/json:
1214
+ schema:
1215
+ type: object
1216
+ additionalProperties: true
1111
1217
  /admin/collection/{collectionId}/ai/skills:
1112
1218
  get:
1113
1219
  tags:
@@ -1196,6 +1302,33 @@ paths:
1196
1302
  description: Unauthorized
1197
1303
  404:
1198
1304
  description: Not found
1305
+ /admin/collection/{collectionId}/ai/usage:
1306
+ get:
1307
+ tags:
1308
+ - sessions
1309
+ summary: AI usage / cost report for a collection, grouped by any of model/serviceTier/appId/feature/mode over an optional date window.
1310
+ operationId: sessions_usage
1311
+ security:
1312
+ - bearerAuth: []
1313
+ parameters:
1314
+ - name: collectionId
1315
+ in: path
1316
+ required: true
1317
+ schema:
1318
+ type: string
1319
+ responses:
1320
+ 200:
1321
+ description: Success
1322
+ content:
1323
+ application/json:
1324
+ schema:
1325
+ $ref: "#/components/schemas/AiUsageReport"
1326
+ 400:
1327
+ description: Bad request
1328
+ 401:
1329
+ description: Unauthorized
1330
+ 404:
1331
+ description: Not found
1199
1332
  /admin/collection/{collectionId}/ai/v1/chat/completions:
1200
1333
  post:
1201
1334
  tags:
@@ -10294,9 +10427,9 @@ paths:
10294
10427
  /public/collection/{collectionId}/ai/rate-limit/{userId}:
10295
10428
  get:
10296
10429
  tags:
10297
- - publicClient
10430
+ - sessions
10298
10431
  summary: Check rate limit status
10299
- operationId: publicClient_getRateLimit
10432
+ operationId: sessions_getRateLimit
10300
10433
  security: []
10301
10434
  parameters:
10302
10435
  - name: collectionId
@@ -10353,12 +10486,113 @@ paths:
10353
10486
  description: Unauthorized
10354
10487
  404:
10355
10488
  description: Not found
10489
+ /public/collection/{collectionId}/ai/sessions:
10490
+ post:
10491
+ tags:
10492
+ - sessions
10493
+ summary: sessions.create
10494
+ operationId: sessions_create
10495
+ security: []
10496
+ parameters:
10497
+ - name: collectionId
10498
+ in: path
10499
+ required: true
10500
+ schema:
10501
+ type: string
10502
+ responses:
10503
+ 200:
10504
+ description: Success
10505
+ content:
10506
+ application/json:
10507
+ schema:
10508
+ $ref: "#/components/schemas/AiSession"
10509
+ 400:
10510
+ description: Bad request
10511
+ 401:
10512
+ description: Unauthorized
10513
+ 404:
10514
+ description: Not found
10515
+ requestBody:
10516
+ required: true
10517
+ content:
10518
+ application/json:
10519
+ schema:
10520
+ $ref: "#/components/schemas/AiSessionCreate"
10521
+ /public/collection/{collectionId}/ai/sessions/{id}:
10522
+ get:
10523
+ tags:
10524
+ - sessions
10525
+ summary: sessions.get
10526
+ operationId: sessions_get
10527
+ security: []
10528
+ parameters:
10529
+ - name: collectionId
10530
+ in: path
10531
+ required: true
10532
+ schema:
10533
+ type: string
10534
+ - name: id
10535
+ in: path
10536
+ required: true
10537
+ schema:
10538
+ type: string
10539
+ responses:
10540
+ 200:
10541
+ description: Success
10542
+ content:
10543
+ application/json:
10544
+ schema:
10545
+ $ref: "#/components/schemas/AiSession"
10546
+ 400:
10547
+ description: Bad request
10548
+ 401:
10549
+ description: Unauthorized
10550
+ 404:
10551
+ description: Not found
10552
+ /public/collection/{collectionId}/ai/sessions/{id}/append:
10553
+ post:
10554
+ tags:
10555
+ - sessions
10556
+ summary: sessions.append
10557
+ operationId: sessions_append
10558
+ security: []
10559
+ parameters:
10560
+ - name: collectionId
10561
+ in: path
10562
+ required: true
10563
+ schema:
10564
+ type: string
10565
+ - name: id
10566
+ in: path
10567
+ required: true
10568
+ schema:
10569
+ type: string
10570
+ responses:
10571
+ 200:
10572
+ description: Success
10573
+ content:
10574
+ application/json:
10575
+ schema:
10576
+ $ref: "#/components/schemas/AiSession"
10577
+ 400:
10578
+ description: Bad request
10579
+ 401:
10580
+ description: Unauthorized
10581
+ 404:
10582
+ description: Not found
10583
+ requestBody:
10584
+ required: true
10585
+ content:
10586
+ application/json:
10587
+ schema:
10588
+ type: object
10589
+ additionalProperties: true
10356
10590
  /public/collection/{collectionId}/ai/token:
10357
10591
  post:
10358
10592
  tags:
10359
- - publicClient
10593
+ - sessions
10360
10594
  summary: Generate ephemeral token for Gemini Live
10361
- operationId: publicClient_getToken
10595
+ operationId: sessions_getToken
10362
10596
  security: []
10363
10597
  parameters:
10364
10598
  - name: collectionId
@@ -11918,6 +12152,32 @@ paths:
11918
12152
  description: Unauthorized
11919
12153
  404:
11920
12154
  description: Not found
12155
+ /public/collection/{collectionId}/functions:
12156
+ get:
12157
+ tags:
12158
+ - functions
12159
+ summary: List the public functions available for a collection (discovery).
12160
+ operationId: functions_list
12161
+ security: []
12162
+ parameters:
12163
+ - name: collectionId
12164
+ in: path
12165
+ required: true
12166
+ schema:
12167
+ type: string
12168
+ responses:
12169
+ 200:
12170
+ description: Success
12171
+ content:
12172
+ application/json:
12173
+ schema:
12174
+ $ref: "#/components/schemas/FunctionListResponse"
12175
+ 400:
12176
+ description: Bad request
12177
+ 401:
12178
+ description: Unauthorized
12179
+ 404:
12180
+ description: Not found
11921
12181
  /public/collection/{collectionId}/interactions:
11922
12182
  get:
11923
12183
  tags:
@@ -15244,6 +15504,10 @@ components:
15244
15504
  - standard
15245
15505
  - flex
15246
15506
  - priority
15507
+ feature:
15508
+ type: string
15509
+ session_id:
15510
+ type: string
15247
15511
  server_tools:
15248
15512
  type: array
15249
15513
  items:
@@ -15799,6 +16063,102 @@ components:
15799
16063
  - activeSessions
15800
16064
  - totalMessages
15801
16065
  - rateLimitedUsers
16066
+ AiSession:
16067
+ type: object
16068
+ properties:
16069
+ id:
16070
+ type: string
16071
+ collectionId:
16072
+ type: string
16073
+ appId:
16074
+ type: string
16075
+ scope:
16076
+ $ref: "#/components/schemas/AiSessionScope"
16077
+ title:
16078
+ type: string
16079
+ status:
16080
+ type: string
16081
+ ownerId:
16082
+ type: string
16083
+ authorId:
16084
+ type: string
16085
+ productId:
16086
+ type: string
16087
+ proofId:
16088
+ type: string
16089
+ feature:
16090
+ type: string
16091
+ items:
16092
+ type: array
16093
+ items:
16094
+ $ref: "#/components/schemas/ResponseInputItem"
16095
+ summary:
16096
+ type: object
16097
+ additionalProperties: true
16098
+ usage:
16099
+ type: object
16100
+ additionalProperties: true
16101
+ itemCount:
16102
+ type: number
16103
+ lastTurnAt:
16104
+ type: string
16105
+ createdAt:
16106
+ type: string
16107
+ updatedAt:
16108
+ type: string
16109
+ expiresAt:
16110
+ type: string
16111
+ required:
16112
+ - id
16113
+ - collectionId
16114
+ - scope
16115
+ - status
16116
+ - items
16117
+ - itemCount
16118
+ - createdAt
16119
+ - updatedAt
16120
+ AiSessionCreate:
16121
+ type: object
16122
+ properties:
16123
+ appId:
16124
+ type: string
16125
+ title:
16126
+ type: string
16127
+ productId:
16128
+ type: string
16129
+ proofId:
16130
+ type: string
16131
+ feature:
16132
+ type: string
16133
+ ttlMs:
16134
+ type: number
16135
+ items:
16136
+ type: array
16137
+ items:
16138
+ $ref: "#/components/schemas/ResponseInputItem"
16139
+ AiUsageReport:
16140
+ type: object
16141
+ properties:
16142
+ groupBy:
16143
+ type: array
16144
+ items:
16145
+ type: string
16146
+ from:
16147
+ type: string
16148
+ to:
16149
+ type: string
16150
+ totals:
16151
+ type: object
16152
+ additionalProperties: true
16153
+ groups:
16154
+ type: array
16155
+ items:
16156
+ type: object
16157
+ additionalProperties: true
16158
+ required:
16159
+ - groupBy
16160
+ - totals
16161
+ - groups
15802
16162
  VoiceSessionRequest:
15803
16163
  type: object
15804
16164
  properties:
@@ -16656,6 +17016,12 @@ components:
16656
17016
  additionalProperties: true
16657
17017
  required:
16658
17018
  - type
17019
+ AiSessionScope:
17020
+ type: string
17021
+ enum:
17022
+ - admin
17023
+ - owner
17024
+ - public
16659
17025
  AiToolCapability:
16660
17026
  type: string
16661
17027
  enum:
@@ -28931,6 +29297,23 @@ components:
28931
29297
  additionalProperties: true
28932
29298
  required:
28933
29299
  - valid
29300
+ FunctionListEntry:
29301
+ type: object
29302
+ properties:
29303
+ name:
29304
+ type: object
29305
+ additionalProperties: true
29306
+ required:
29307
+ - name
29308
+ FunctionListResponse:
29309
+ type: object
29310
+ properties:
29311
+ functions:
29312
+ type: array
29313
+ items:
29314
+ $ref: "#/components/schemas/FunctionListEntry"
29315
+ required:
29316
+ - functions
28934
29317
  AllocateSequenceInput:
28935
29318
  type: object
28936
29319
  properties:
@@ -116,6 +116,12 @@ export function createFunctionTestContext(opts) {
116
116
  throw new CapabilityError(`secrets:${ref}`);
117
117
  return Object.prototype.hasOwnProperty.call(secretsMap, ref) ? secretsMap[ref] : null;
118
118
  },
119
+ // App-scoped read — in tests it resolves from the same provided secrets map.
120
+ async app(ref) {
121
+ if (!parsed.secrets.has(ref))
122
+ throw new CapabilityError(`secrets:${ref}`);
123
+ return Object.prototype.hasOwnProperty.call(secretsMap, ref) ? secretsMap[ref] : null;
124
+ },
119
125
  },
120
126
  caller: {
121
127
  userId: (_a = caller.userId) !== null && _a !== void 0 ? _a : null,
@@ -109,6 +109,18 @@ export interface ResponsesRequest {
109
109
  };
110
110
  /** `'flex'` is ~50% cheaper at Batch-API rates but slower; reserve for non-interactive/background work. */
111
111
  service_tier?: 'auto' | 'standard' | 'flex' | 'priority';
112
+ /**
113
+ * Attribution tag for AI usage/cost reporting (see `ai.usage`). Not sent to the model —
114
+ * the server strips it. e.g. `'readiness-check'`, `'design-critique'`.
115
+ */
116
+ feature?: string;
117
+ /**
118
+ * Persist this turn to a server-managed session (create one with `ai.sessions.create`). The
119
+ * server threads the session's prior transcript into the input and appends the new turn — so
120
+ * you get conversation memory without managing history yourself, and it works even with
121
+ * `server_tools` (unlike `previous_response_id`).
122
+ */
123
+ session_id?: string;
112
124
  /**
113
125
  * Run through the server-side agent loop: the platform executes built-in tools
114
126
  * (see BUILTIN_AI_TOOLS / AiToolName) and feeds results back automatically, so the
@@ -350,6 +362,65 @@ export interface SessionStatistics {
350
362
  totalMessages: number;
351
363
  rateLimitedUsers: number;
352
364
  }
365
+ /** Who may read/append a persisted AI session. */
366
+ export type AiSessionScope = 'admin' | 'owner' | 'public';
367
+ /** A persisted AI assistant conversation (durable, scoped). */
368
+ export interface AiSession {
369
+ id: string;
370
+ collectionId: string;
371
+ appId?: string | null;
372
+ scope: AiSessionScope;
373
+ title?: string | null;
374
+ status: string;
375
+ ownerId?: string | null;
376
+ authorId?: string | null;
377
+ productId?: string | null;
378
+ proofId?: string | null;
379
+ feature?: string | null;
380
+ /** Append-only Responses items (input/output + tool calls/results). */
381
+ items: ResponseInputItem[];
382
+ /** Compacted digest of older turns (server-managed). */
383
+ summary?: Record<string, any>;
384
+ /** Running token/turn accounting for this session. */
385
+ usage?: Record<string, any>;
386
+ itemCount: number;
387
+ lastTurnAt?: string | null;
388
+ createdAt: string;
389
+ updatedAt: string;
390
+ expiresAt?: string | null;
391
+ }
392
+ /** Fields for creating a session (all optional). */
393
+ export interface AiSessionCreate {
394
+ appId?: string;
395
+ title?: string;
396
+ productId?: string;
397
+ proofId?: string;
398
+ feature?: string;
399
+ /** Time-to-live in ms; omit to keep until explicitly cleared. */
400
+ ttlMs?: number;
401
+ /** Seed items (e.g. a system/instruction turn). */
402
+ items?: ResponseInputItem[];
403
+ }
404
+ /** Per-collection AI usage/cost report. `costUnits` are OPAQUE internal units, never provider currency. */
405
+ export interface AiUsageReport {
406
+ groupBy: string[];
407
+ from?: string | null;
408
+ to?: string | null;
409
+ totals: {
410
+ promptTokens: number;
411
+ outputTokens: number;
412
+ totalTokens: number;
413
+ requests: number;
414
+ costUnits: number;
415
+ };
416
+ groups: Array<Record<string, any> & {
417
+ promptTokens: number;
418
+ outputTokens: number;
419
+ totalTokens: number;
420
+ requests: number;
421
+ costUnits: number;
422
+ }>;
423
+ }
353
424
  /** Voice session request */
354
425
  export interface VoiceSessionRequest {
355
426
  productId: string;
@@ -298,9 +298,15 @@ export interface ServerFunctionContext {
298
298
  * Declared `capabilities` cap what these calls may do.
299
299
  */
300
300
  sl: any;
301
- /** Capability-gated secret access. `get(ref)` resolves only refs granted via `secrets:<ref>`. */
301
+ /**
302
+ * Capability-gated secret access (both require the `secrets:<ref>` capability).
303
+ * `get(ref)` resolves the collection's OWN secret first (a client's credential), then falls back
304
+ * to the app-level secret (the developer's shared singleton, installed once per instance).
305
+ * `app(ref)` reads the app-level secret only, skipping the collection store.
306
+ */
302
307
  secrets: {
303
308
  get(ref: string): Promise<string | null>;
309
+ app(ref: string): Promise<string | null>;
304
310
  };
305
311
  /** Who invoked this function. */
306
312
  caller: ServerFunctionCaller;