@collective-intelligence/external-apps-server-sdk 0.1.7 → 0.1.9

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/README.md CHANGED
@@ -358,6 +358,34 @@ than waiting for a workflow in this bounded tool adapter. The
358
358
  shows distinct receipts and final results, independent resource authorization,
359
359
  and application-owned execution, recovery, failure, and duplicate protection.
360
360
 
361
+ ## Workflow results
362
+
363
+ Workflow invocation returns `runId`. A successful declared-output Workflow run
364
+ read through `runs.get` has `result: { nativeStatus: "completed", output }`;
365
+ the `completed` event from `runs.stream` carries that same object in `data`.
366
+ CI reads the validated, persisted Workflow output snapshot. The Gateway Tool's
367
+ response becomes public only through the Workflow's explicit `outputContract`
368
+ bindings and schema; selecting a Tool alone does not declare a Workflow result.
369
+ See the [binding example and lifecycle](../../../docs/architecture/external-app-gateway.md#workflow-results-and-observation).
370
+
371
+ The native worker finishes and persists output independently of the browser.
372
+ External terminal publication stays lazy on the next authorized run read, with
373
+ status, result and completion event committed together as an immutable receipt.
374
+ Existing terminal results and cancellation decisions survive repeated reads.
375
+ Owner-user/kind, Organization, Application and external audit-subject checks
376
+ still apply to both snapshots and events.
377
+
378
+ If reading fails, observe the original `runId` again; do not resubmit the
379
+ business command to retrieve its result. The browser SDK's `runs.follow`
380
+ returns an event page, propagates read failures, and does not retry them
381
+ automatically. Missing promised output is a technical invariant defect, not a
382
+ normal null-output or partial-success terminal result. There is no historical
383
+ terminal-run backfill or compatibility mode for this contract.
384
+
385
+ Keep analysis history and candidate results in Knowledge reads. Send a matching
386
+ completion notification only after the matching results are actually available
387
+ in Knowledge, even if the command run has already completed.
388
+
361
389
  ## Agent runs and conversations
362
390
 
363
391
  `agents.invoke({ agentId, input })` starts one Agent run and returns
@@ -517,6 +545,40 @@ const created = await ci.members.createOrGet({
517
545
  - Only `temporarily_unavailable` is retryable (the client retries it); a
518
546
  creation CI refuses is a non-retryable `internal_error`.
519
547
 
548
+ ## Durable files
549
+
550
+ A confidential application stores a file that a workflow run reads later, such
551
+ as the PDF of a signed form. The file is a private stored file of the
552
+ Organization the credentials were authorized for, with no expiry.
553
+
554
+ ```ts
555
+ const uploaded = await ci.files.upload({
556
+ contentBase64: pdf.toString("base64"),
557
+ contentType: "application/pdf",
558
+ fileName: "application.pdf",
559
+ organizationId,
560
+ sizeBytes: pdf.byteLength
561
+ })
562
+ // uploaded.value.result: { storageFileId }
563
+
564
+ await ci.workflows.invoke({
565
+ input: { document: { storageFileId: uploaded.value.result.storageFileId } },
566
+ organizationId,
567
+ workflowFqn
568
+ })
569
+ ```
570
+
571
+ - `contentType` is `application/pdf`, `image/jpeg` or `image/png`, and the file
572
+ holds 1 byte to 10 MiB. `sizeBytes` must match the decoded content. Other
573
+ files are refused with `invalid_request`.
574
+ - A workflow input can name the `storageFileId`; the nodes of a run of the same
575
+ Organization read the file through their stored file access. The file has no
576
+ public URL, and another Organization cannot read it.
577
+ - `attachments.upload` is different: its file belongs to one run and expires
578
+ after 24 hours.
579
+ - It needs the `ai:attachments` scope. Only service credentials may call it: a
580
+ delegated user token or an anonymous visitor gets `operation_not_allowed`.
581
+
520
582
  ## Member company links
521
583
 
522
584
  An application links a member of its Organization to the Knowledge company
@@ -1407,6 +1469,21 @@ The adapter never retries or follows redirects. Cancellation or a lost response
1407
1469
  after dispatch remains an uncertain outcome; retain the original action for
1408
1470
  explicit resubmission.
1409
1471
 
1472
+ #### File uploads through the BFF
1473
+
1474
+ When the definition declares `capabilities.upload: true`, the handler also
1475
+ accepts `POST {basePath}/uploads` with `{ field, filename, mimeType }`. It calls
1476
+ `authorize` with the operation `upload`, then forwards the request with the
1477
+ verified grant to `/application/v1/resources/{schemaFqn}/uploads`. CI answers
1478
+ the File upload `{ uploadId, url, method: "PUT", headers }`; the browser PUTs
1479
+ the bytes straight to that storage URL, so no file bytes pass through the BFF.
1480
+ The entity write that names `{ upload: uploadId }` follows the normal update
1481
+ path. `upload_not_supported` (the Organization storage can not presign) maps to
1482
+ HTTP 400. Without the capability the request answers `capability_not_supported`
1483
+ and is not forwarded. A local `defineEntityResource` binding answers
1484
+ `capability_not_supported`, and a `defineCrudResource` handler answers 404 for
1485
+ this path. The client SDK README documents the write form.
1486
+
1410
1487
  ## Optional local user authentication
1411
1488
 
1412
1489
  Import `createBetterAuth` only from
package/dist/admin.d.ts CHANGED
@@ -334,6 +334,19 @@ export type EntityRelationField = {
334
334
  targetEntityId: string;
335
335
  targetSchemaFqn: string;
336
336
  };
337
+ declare const KnowledgeFileVisibility: {
338
+ readonly PUBLIC: "public";
339
+ readonly PROTECTED: "protected";
340
+ readonly PRIVATE: "private";
341
+ };
342
+ export type KnowledgeFileVisibility = typeof KnowledgeFileVisibility[keyof typeof KnowledgeFileVisibility];
343
+ export type KnowledgeFileFieldEntry = {
344
+ accepts: Array<string>;
345
+ multiple: boolean;
346
+ };
347
+ export type PackageOperationAccepted7 = {
348
+ operationId: string;
349
+ };
337
350
  export type PackageOperationAccepted5 = {
338
351
  operationId: string;
339
352
  };
@@ -1505,6 +1518,7 @@ export type ExtensionPackagesUninstallData = {
1505
1518
  headers: {
1506
1519
  authorization?: string;
1507
1520
  "x-organization-id": string;
1521
+ "idempotency-key": string;
1508
1522
  };
1509
1523
  path: {
1510
1524
  fqn: string;
@@ -1892,12 +1906,17 @@ export type RelationSchemasUpdateData = {
1892
1906
  defaultSearch?: boolean;
1893
1907
  embedded?: boolean;
1894
1908
  faceted?: boolean;
1909
+ includeInItemEmbedding?: boolean;
1895
1910
  indexContent?: boolean;
1896
1911
  indexOverview?: boolean;
1897
1912
  indexed?: boolean;
1898
1913
  managedProjectionSource?: "organization_group" | "organization_user";
1914
+ overviewInputMaxChars?: number | null;
1899
1915
  queryGuidance?: string;
1916
+ richEnrichment?: boolean | null;
1900
1917
  unique?: boolean;
1918
+ file?: unknown;
1919
+ mediaVisibility?: unknown;
1901
1920
  };
1902
1921
  };
1903
1922
  fqn?: string;
@@ -2000,12 +2019,17 @@ export type RelationSchemasCreateData = {
2000
2019
  defaultSearch?: boolean;
2001
2020
  embedded?: boolean;
2002
2021
  faceted?: boolean;
2022
+ includeInItemEmbedding?: boolean;
2003
2023
  indexContent?: boolean;
2004
2024
  indexOverview?: boolean;
2005
2025
  indexed?: boolean;
2006
2026
  managedProjectionSource?: "organization_group" | "organization_user";
2027
+ overviewInputMaxChars?: number | null;
2007
2028
  queryGuidance?: string;
2029
+ richEnrichment?: boolean | null;
2008
2030
  unique?: boolean;
2031
+ file?: unknown;
2032
+ mediaVisibility?: unknown;
2009
2033
  };
2010
2034
  };
2011
2035
  fqn: string;
@@ -2245,12 +2269,17 @@ export type EntitySchemasUpdateData = {
2245
2269
  defaultSearch?: boolean;
2246
2270
  embedded?: boolean;
2247
2271
  faceted?: boolean;
2272
+ includeInItemEmbedding?: boolean;
2248
2273
  indexContent?: boolean;
2249
2274
  indexOverview?: boolean;
2250
2275
  indexed?: boolean;
2251
2276
  managedProjectionSource?: "organization_group" | "organization_user";
2277
+ overviewInputMaxChars?: number | null;
2252
2278
  queryGuidance?: string;
2279
+ richEnrichment?: boolean | null;
2253
2280
  unique?: boolean;
2281
+ file?: KnowledgeFileFieldEntry;
2282
+ mediaVisibility?: KnowledgeFileVisibility;
2254
2283
  };
2255
2284
  };
2256
2285
  fqn?: string;
@@ -2271,8 +2300,10 @@ export type EntitySchemasUpdateData = {
2271
2300
  source: "organization_group" | "organization_group_hierarchy" | "organization_group_membership" | "organization_user";
2272
2301
  } | null;
2273
2302
  name?: string;
2303
+ overviewInputMaxChars?: number | null;
2274
2304
  persistFullFieldContributions?: boolean;
2275
2305
  relationFields?: Array<EntityRelationField>;
2306
+ richEnrichment?: boolean | null;
2276
2307
  usableAsDocumentScope?: boolean;
2277
2308
  };
2278
2309
  headers: {
@@ -2379,12 +2410,17 @@ export type EntitySchemasCreateData = {
2379
2410
  defaultSearch?: boolean;
2380
2411
  embedded?: boolean;
2381
2412
  faceted?: boolean;
2413
+ includeInItemEmbedding?: boolean;
2382
2414
  indexContent?: boolean;
2383
2415
  indexOverview?: boolean;
2384
2416
  indexed?: boolean;
2385
2417
  managedProjectionSource?: "organization_group" | "organization_user";
2418
+ overviewInputMaxChars?: number | null;
2386
2419
  queryGuidance?: string;
2420
+ richEnrichment?: boolean | null;
2387
2421
  unique?: boolean;
2422
+ file?: KnowledgeFileFieldEntry;
2423
+ mediaVisibility?: KnowledgeFileVisibility;
2388
2424
  };
2389
2425
  };
2390
2426
  fqn: string;
@@ -2399,8 +2435,10 @@ export type EntitySchemasCreateData = {
2399
2435
  source: "organization_group" | "organization_group_hierarchy" | "organization_group_membership" | "organization_user";
2400
2436
  } | null;
2401
2437
  name: string;
2438
+ overviewInputMaxChars?: number | null;
2402
2439
  persistFullFieldContributions?: boolean;
2403
2440
  relationFields?: Array<EntityRelationField>;
2441
+ richEnrichment?: boolean | null;
2404
2442
  usableAsDocumentScope?: boolean;
2405
2443
  };
2406
2444
  headers: {
@@ -6364,12 +6402,17 @@ declare const createAdministrationApi: (client: Client$1) => {
6364
6402
  defaultSearch?: boolean;
6365
6403
  embedded?: boolean;
6366
6404
  faceted?: boolean;
6405
+ includeInItemEmbedding?: boolean;
6367
6406
  indexContent?: boolean;
6368
6407
  indexOverview?: boolean;
6369
6408
  indexed?: boolean;
6370
6409
  managedProjectionSource?: "organization_group" | "organization_user";
6410
+ overviewInputMaxChars?: number | null;
6371
6411
  queryGuidance?: string;
6412
+ richEnrichment?: boolean | null;
6372
6413
  unique?: boolean;
6414
+ file?: KnowledgeFileFieldEntry;
6415
+ mediaVisibility?: KnowledgeFileVisibility;
6373
6416
  };
6374
6417
  };
6375
6418
  fqn: string;
@@ -6386,9 +6429,11 @@ declare const createAdministrationApi: (client: Client$1) => {
6386
6429
  source: "organization_group" | "organization_group_hierarchy" | "organization_group_membership" | "organization_user";
6387
6430
  } | null;
6388
6431
  name: string;
6432
+ overviewInputMaxChars: number | null;
6389
6433
  persistFullFieldContributions: boolean;
6390
6434
  relationFields: Array<EntityRelationField>;
6391
6435
  removedFields: Array<unknown>;
6436
+ richEnrichment: boolean | null;
6392
6437
  updatedAt: string | null;
6393
6438
  usableAsDocumentScope: boolean;
6394
6439
  }>;
@@ -6469,11 +6514,14 @@ declare const createAdministrationApi: (client: Client$1) => {
6469
6514
  defaultSearch?: boolean;
6470
6515
  embedded?: boolean;
6471
6516
  faceted?: boolean;
6517
+ includeInItemEmbedding?: boolean;
6472
6518
  indexContent?: boolean;
6473
6519
  indexOverview?: boolean;
6474
6520
  indexed?: boolean;
6475
6521
  managedProjectionSource?: "organization_group" | "organization_user";
6522
+ overviewInputMaxChars?: number | null;
6476
6523
  queryGuidance?: string;
6524
+ richEnrichment?: boolean | null;
6477
6525
  unique?: boolean;
6478
6526
  };
6479
6527
  };
@@ -6595,12 +6643,17 @@ declare const createAdministrationApi: (client: Client$1) => {
6595
6643
  defaultSearch?: boolean;
6596
6644
  embedded?: boolean;
6597
6645
  faceted?: boolean;
6646
+ includeInItemEmbedding?: boolean;
6598
6647
  indexContent?: boolean;
6599
6648
  indexOverview?: boolean;
6600
6649
  indexed?: boolean;
6601
6650
  managedProjectionSource?: "organization_group" | "organization_user";
6651
+ overviewInputMaxChars?: number | null;
6602
6652
  queryGuidance?: string;
6653
+ richEnrichment?: boolean | null;
6603
6654
  unique?: boolean;
6655
+ file?: KnowledgeFileFieldEntry;
6656
+ mediaVisibility?: KnowledgeFileVisibility;
6604
6657
  };
6605
6658
  };
6606
6659
  fqn: string;
@@ -6617,9 +6670,11 @@ declare const createAdministrationApi: (client: Client$1) => {
6617
6670
  source: "organization_group" | "organization_group_hierarchy" | "organization_group_membership" | "organization_user";
6618
6671
  } | null;
6619
6672
  name: string;
6673
+ overviewInputMaxChars: number | null;
6620
6674
  persistFullFieldContributions: boolean;
6621
6675
  relationFields: Array<EntityRelationField>;
6622
6676
  removedFields: Array<unknown>;
6677
+ richEnrichment: boolean | null;
6623
6678
  updatedAt: string | null;
6624
6679
  usableAsDocumentScope: boolean;
6625
6680
  }>;
@@ -6700,11 +6755,14 @@ declare const createAdministrationApi: (client: Client$1) => {
6700
6755
  defaultSearch?: boolean;
6701
6756
  embedded?: boolean;
6702
6757
  faceted?: boolean;
6758
+ includeInItemEmbedding?: boolean;
6703
6759
  indexContent?: boolean;
6704
6760
  indexOverview?: boolean;
6705
6761
  indexed?: boolean;
6706
6762
  managedProjectionSource?: "organization_group" | "organization_user";
6763
+ overviewInputMaxChars?: number | null;
6707
6764
  queryGuidance?: string;
6765
+ richEnrichment?: boolean | null;
6708
6766
  unique?: boolean;
6709
6767
  };
6710
6768
  };
@@ -6821,12 +6879,17 @@ declare const createAdministrationApi: (client: Client$1) => {
6821
6879
  defaultSearch?: boolean;
6822
6880
  embedded?: boolean;
6823
6881
  faceted?: boolean;
6882
+ includeInItemEmbedding?: boolean;
6824
6883
  indexContent?: boolean;
6825
6884
  indexOverview?: boolean;
6826
6885
  indexed?: boolean;
6827
6886
  managedProjectionSource?: "organization_group" | "organization_user";
6887
+ overviewInputMaxChars?: number | null;
6828
6888
  queryGuidance?: string;
6889
+ richEnrichment?: boolean | null;
6829
6890
  unique?: boolean;
6891
+ file?: KnowledgeFileFieldEntry;
6892
+ mediaVisibility?: KnowledgeFileVisibility;
6830
6893
  };
6831
6894
  };
6832
6895
  fqn: string;
@@ -6843,9 +6906,11 @@ declare const createAdministrationApi: (client: Client$1) => {
6843
6906
  source: "organization_group" | "organization_group_hierarchy" | "organization_group_membership" | "organization_user";
6844
6907
  } | null;
6845
6908
  name: string;
6909
+ overviewInputMaxChars: number | null;
6846
6910
  persistFullFieldContributions: boolean;
6847
6911
  relationFields: Array<EntityRelationField>;
6848
6912
  removedFields: Array<unknown>;
6913
+ richEnrichment: boolean | null;
6849
6914
  updatedAt: string | null;
6850
6915
  usableAsDocumentScope: boolean;
6851
6916
  }>;
@@ -6934,11 +6999,14 @@ declare const createAdministrationApi: (client: Client$1) => {
6934
6999
  defaultSearch?: boolean;
6935
7000
  embedded?: boolean;
6936
7001
  faceted?: boolean;
7002
+ includeInItemEmbedding?: boolean;
6937
7003
  indexContent?: boolean;
6938
7004
  indexOverview?: boolean;
6939
7005
  indexed?: boolean;
6940
7006
  managedProjectionSource?: "organization_group" | "organization_user";
7007
+ overviewInputMaxChars?: number | null;
6941
7008
  queryGuidance?: string;
7009
+ richEnrichment?: boolean | null;
6942
7010
  unique?: boolean;
6943
7011
  };
6944
7012
  };
@@ -7113,9 +7181,7 @@ declare const createAdministrationApi: (client: Client$1) => {
7113
7181
  }[]>;
7114
7182
  promoteRelease: (options: Pick<Options$1<PackageReleasesPromoteData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<PackageOperationAccepted2>;
7115
7183
  publishRelease: (options: Pick<Options$1<PackageReleasesPublishData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<PackageOperationAccepted1>;
7116
- uninstall: (options: Pick<Options$1<ExtensionPackagesUninstallData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<{
7117
- message: string;
7118
- }>;
7184
+ uninstall: (options: Pick<Options$1<ExtensionPackagesUninstallData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<PackageOperationAccepted7>;
7119
7185
  updateInstallation: (options: Pick<Options$1<PackageReleasesUpdateInstallationData, true, unknown>, "query" | "body" | "headers" | "path">) => Promise<PackageOperationAccepted3>;
7120
7186
  };
7121
7187
  reports: {
@@ -7276,8 +7342,10 @@ declare const createAdministrationApi: (client: Client$1) => {
7276
7342
  layoutProps: unknown | null;
7277
7343
  name: string;
7278
7344
  organizationId: string;
7345
+ packageOwned: boolean;
7279
7346
  publishedDefinitionHash: string | null;
7280
7347
  publishedVersionId: string | null;
7348
+ readonly: boolean;
7281
7349
  slug: string;
7282
7350
  updatedAt: string | null;
7283
7351
  }>;
@@ -7296,8 +7364,10 @@ declare const createAdministrationApi: (client: Client$1) => {
7296
7364
  layoutProps: unknown | null;
7297
7365
  name: string;
7298
7366
  organizationId: string;
7367
+ packageOwned: boolean;
7299
7368
  publishedDefinitionHash: string | null;
7300
7369
  publishedVersionId: string | null;
7370
+ readonly: boolean;
7301
7371
  slug: string;
7302
7372
  updatedAt: string | null;
7303
7373
  }>;
@@ -7314,8 +7384,10 @@ declare const createAdministrationApi: (client: Client$1) => {
7314
7384
  layoutProps: unknown | null;
7315
7385
  name: string;
7316
7386
  organizationId: string;
7387
+ packageOwned: boolean;
7317
7388
  publishedDefinitionHash: string | null;
7318
7389
  publishedVersionId: string | null;
7390
+ readonly: boolean;
7319
7391
  slug: string;
7320
7392
  updatedAt: string | null;
7321
7393
  }>;
package/dist/express.d.ts CHANGED
@@ -387,6 +387,8 @@ export type ResourceCapabilities = Readonly<{
387
387
  search: true;
388
388
  softDelete?: boolean;
389
389
  update?: boolean;
390
+ /** File uploads for the File fields of a common entity resource. */
391
+ upload?: boolean;
390
392
  }>;
391
393
  export type ResourcePaginationMode = "cursor" | "page";
392
394
  export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
@@ -458,7 +460,9 @@ export type ResourceListQuery = Readonly<{
458
460
  sort?: readonly ResourceSort[];
459
461
  textSearch?: string;
460
462
  }>;
461
- export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
463
+ export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
464
+ /** The CI Organization storage can not take a presigned File upload. */
465
+ "upload_not_supported";
462
466
  export type ResourceError = Readonly<{
463
467
  code: ResourceErrorCode;
464
468
  /** Client-observed dispatch outcome; uncertainty never proves rollback. */
@@ -354,6 +354,8 @@ export type ResourceCapabilities = Readonly<{
354
354
  search: true;
355
355
  softDelete?: boolean;
356
356
  update?: boolean;
357
+ /** File uploads for the File fields of a common entity resource. */
358
+ upload?: boolean;
357
359
  }>;
358
360
  export type ResourcePaginationMode = "cursor" | "page";
359
361
  export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
@@ -425,7 +427,9 @@ export type ResourceListQuery = Readonly<{
425
427
  sort?: readonly ResourceSort[];
426
428
  textSearch?: string;
427
429
  }>;
428
- export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
430
+ export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
431
+ /** The CI Organization storage can not take a presigned File upload. */
432
+ "upload_not_supported";
429
433
  export type ResourceError = Readonly<{
430
434
  code: ResourceErrorCode;
431
435
  /** Client-observed dispatch outcome; uncertainty never proves rollback. */
package/dist/gateway.d.ts CHANGED
@@ -395,6 +395,8 @@ export type ResourceCapabilities = Readonly<{
395
395
  search: true;
396
396
  softDelete?: boolean;
397
397
  update?: boolean;
398
+ /** File uploads for the File fields of a common entity resource. */
399
+ upload?: boolean;
398
400
  }>;
399
401
  export type ResourcePaginationMode = "cursor" | "page";
400
402
  export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
@@ -466,7 +468,9 @@ export type ResourceListQuery = Readonly<{
466
468
  sort?: readonly ResourceSort[];
467
469
  textSearch?: string;
468
470
  }>;
469
- export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
471
+ export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
472
+ /** The CI Organization storage can not take a presigned File upload. */
473
+ "upload_not_supported";
470
474
  export type ResourceError = Readonly<{
471
475
  code: ResourceErrorCode;
472
476
  /** Client-observed dispatch outcome; uncertainty never proves rollback. */