@vertesia/common 1.5.0-dev.20260714.072725Z → 1.5.0-dev.20260722.120446Z

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 (127) hide show
  1. package/lib/apikey.d.ts +1 -0
  2. package/lib/apikey.d.ts.map +1 -1
  3. package/lib/apikey.js.map +1 -1
  4. package/lib/apps.d.ts +500 -34
  5. package/lib/apps.d.ts.map +1 -1
  6. package/lib/apps.js +63 -70
  7. package/lib/apps.js.map +1 -1
  8. package/lib/audit-trail.d.ts +61 -1
  9. package/lib/audit-trail.d.ts.map +1 -1
  10. package/lib/audit-trail.js +15 -0
  11. package/lib/audit-trail.js.map +1 -1
  12. package/lib/data-platform.d.ts +121 -5
  13. package/lib/data-platform.d.ts.map +1 -1
  14. package/lib/index.d.ts +7 -0
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/index.js +7 -0
  17. package/lib/index.js.map +1 -1
  18. package/lib/interaction.d.ts +19 -1
  19. package/lib/interaction.d.ts.map +1 -1
  20. package/lib/interaction.js.map +1 -1
  21. package/lib/json-schema.d.ts +1 -1
  22. package/lib/json-schema.d.ts.map +1 -1
  23. package/lib/platform-event.d.ts +79 -3
  24. package/lib/platform-event.d.ts.map +1 -1
  25. package/lib/platform-event.js.map +1 -1
  26. package/lib/project.d.ts +119 -20
  27. package/lib/project.d.ts.map +1 -1
  28. package/lib/project.js +65 -0
  29. package/lib/project.js.map +1 -1
  30. package/lib/query.d.ts +6 -0
  31. package/lib/query.d.ts.map +1 -1
  32. package/lib/refs.d.ts +1 -0
  33. package/lib/refs.d.ts.map +1 -1
  34. package/lib/schema-for-extraction.d.ts +21 -0
  35. package/lib/schema-for-extraction.d.ts.map +1 -0
  36. package/lib/schema-for-extraction.js +205 -0
  37. package/lib/schema-for-extraction.js.map +1 -0
  38. package/lib/store/agent-run.d.ts +2 -0
  39. package/lib/store/agent-run.d.ts.map +1 -1
  40. package/lib/store/conversation-state.d.ts +39 -0
  41. package/lib/store/conversation-state.d.ts.map +1 -1
  42. package/lib/store/conversation-state.js +3 -0
  43. package/lib/store/conversation-state.js.map +1 -1
  44. package/lib/store/doc-analyzer.d.ts +10 -67
  45. package/lib/store/doc-analyzer.d.ts.map +1 -1
  46. package/lib/store/dsl-workflow.d.ts +1 -0
  47. package/lib/store/dsl-workflow.d.ts.map +1 -1
  48. package/lib/store/dsl-workflow.js.map +1 -1
  49. package/lib/store/grounded-extraction.d.ts +146 -0
  50. package/lib/store/grounded-extraction.d.ts.map +1 -0
  51. package/lib/store/grounded-extraction.js +8 -0
  52. package/lib/store/grounded-extraction.js.map +1 -0
  53. package/lib/store/index.d.ts +1 -0
  54. package/lib/store/index.d.ts.map +1 -1
  55. package/lib/store/index.js +1 -0
  56. package/lib/store/index.js.map +1 -1
  57. package/lib/store/store.d.ts +307 -1
  58. package/lib/store/store.d.ts.map +1 -1
  59. package/lib/store/store.js +438 -0
  60. package/lib/store/store.js.map +1 -1
  61. package/lib/store/workflow.d.ts +3 -0
  62. package/lib/store/workflow.d.ts.map +1 -1
  63. package/lib/store/workflow.js.map +1 -1
  64. package/lib/user.d.ts +14 -0
  65. package/lib/user.d.ts.map +1 -1
  66. package/lib/user.js +31 -0
  67. package/lib/user.js.map +1 -1
  68. package/lib/vertesia-common.js +2 -2
  69. package/lib/vertesia-common.js.map +1 -1
  70. package/lib/view-configuration-validation.d.ts +15 -0
  71. package/lib/view-configuration-validation.d.ts.map +1 -0
  72. package/lib/view-configuration-validation.js +63 -0
  73. package/lib/view-configuration-validation.js.map +1 -0
  74. package/lib/view-query-validation.d.ts +13 -0
  75. package/lib/view-query-validation.d.ts.map +1 -0
  76. package/lib/view-query-validation.js +266 -0
  77. package/lib/view-query-validation.js.map +1 -0
  78. package/lib/view-validation-helpers.d.ts +15 -0
  79. package/lib/view-validation-helpers.d.ts.map +1 -0
  80. package/lib/view-validation-helpers.js +25 -0
  81. package/lib/view-validation-helpers.js.map +1 -0
  82. package/lib/views-schema.d.ts +1992 -0
  83. package/lib/views-schema.d.ts.map +1 -0
  84. package/lib/views-schema.js +674 -0
  85. package/lib/views-schema.js.map +1 -0
  86. package/lib/views-validation.d.ts +21 -0
  87. package/lib/views-validation.d.ts.map +1 -0
  88. package/lib/views-validation.js +164 -0
  89. package/lib/views-validation.js.map +1 -0
  90. package/lib/views.d.ts +381 -0
  91. package/lib/views.d.ts.map +1 -0
  92. package/lib/views.js +41 -0
  93. package/lib/views.js.map +1 -0
  94. package/package.json +5 -4
  95. package/src/apikey.ts +1 -0
  96. package/src/apps.test.ts +9 -1
  97. package/src/apps.ts +583 -90
  98. package/src/audit-trail.ts +83 -0
  99. package/src/data-platform.ts +129 -5
  100. package/src/index.ts +12 -0
  101. package/src/interaction.ts +20 -1
  102. package/src/json-schema.ts +0 -1
  103. package/src/platform-event.ts +92 -2
  104. package/src/project.test.ts +44 -0
  105. package/src/project.ts +205 -22
  106. package/src/query.ts +6 -0
  107. package/src/refs.ts +1 -0
  108. package/src/roles.test.ts +32 -0
  109. package/src/schema-for-extraction.test.ts +191 -0
  110. package/src/schema-for-extraction.ts +231 -0
  111. package/src/store/agent-run.ts +2 -0
  112. package/src/store/conversation-state.ts +47 -0
  113. package/src/store/doc-analyzer.ts +10 -76
  114. package/src/store/dsl-workflow.ts +1 -0
  115. package/src/store/grounded-extraction.ts +154 -0
  116. package/src/store/index.ts +1 -0
  117. package/src/store/store.ts +778 -1
  118. package/src/store/workflow.ts +3 -0
  119. package/src/user.ts +46 -0
  120. package/src/view-configuration-validation.ts +74 -0
  121. package/src/view-query-validation.test.ts +21 -0
  122. package/src/view-query-validation.ts +319 -0
  123. package/src/view-validation-helpers.ts +28 -0
  124. package/src/views-schema.test.ts +364 -0
  125. package/src/views-schema.ts +689 -0
  126. package/src/views-validation.ts +234 -0
  127. package/src/views.ts +484 -0
package/src/apps.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { JSONObject, JSONSchema, ToolDefinition } from '@llumiverse/common';
2
+ import type { AppDashboardDefinition } from './data-platform.js';
2
3
  import type { CatalogInteractionRef } from './interaction.js';
3
4
  import type { DSLActivityOptions, InCodeProcessDefinition, InCodeTypeDefinition } from './store/index.js';
5
+ import type { InCodeViewDefinition } from './views.js';
4
6
 
5
7
  /** Allowed values for AppUINavItem.preferredSection */
6
8
  export const PREFERRED_SECTIONS = ['default', 'footer', 'settings'] as const;
@@ -382,9 +384,371 @@ export interface RemoteActivityDefinition {
382
384
  options?: DSLActivityOptions;
383
385
  }
384
386
 
385
- export type AppCapabilities = 'ui' | 'tools' | 'interactions' | 'types' | 'processes' | 'templates';
387
+ /**
388
+ * Canonical app capabilities Studio renders/supports. The public type is derived from
389
+ * this list so runtime validation and TypeScript cannot drift.
390
+ */
391
+ export const APP_CAPABILITIES = [
392
+ 'ui',
393
+ 'tools',
394
+ 'interactions',
395
+ 'types',
396
+ 'processes',
397
+ 'views',
398
+ 'templates',
399
+ 'dashboards',
400
+ ] as const;
401
+
402
+ export type AppCapabilities = (typeof APP_CAPABILITIES)[number];
403
+
404
+ /**
405
+ * Header carrying the app version a generated-app UI is running, so studio/zeno resolve app-owned
406
+ * capability refs (`app:<app>:...`) against that exact version instead of the promoted version.
407
+ * Resolution-time only; never persisted. Set by the generated app template via client.withAppVersion.
408
+ */
409
+ export const APP_VERSION_HEADER = 'x-vertesia-app-version';
410
+ /**
411
+ * The platform-artifact types an app build can be required to create. A finer-grained
412
+ * counterpart to {@link AppCapabilities}: a single `interactions` capability may comprise
413
+ * several `interaction` artifacts plus `agent`, `activity`, and `tool` artifacts that
414
+ * {@link AppCapabilities} folds together. Used by the App Solution Architect manifest and
415
+ * the publish-time capability gate.
416
+ */
417
+ export const APP_ARTIFACT_TYPES = [
418
+ 'interaction',
419
+ 'agent',
420
+ 'type',
421
+ 'process',
422
+ 'view',
423
+ 'template',
424
+ 'dashboard',
425
+ 'activity',
426
+ 'tool',
427
+ ] as const;
428
+
429
+ export type AppArtifactType = (typeof APP_ARTIFACT_TYPES)[number];
430
+
431
+ /**
432
+ * A single platform artifact the App Solution Architect requires the build to create.
433
+ * `id` is the app-owned in-code id the implementation must register and reference
434
+ * (e.g. `app:<name>:main:extract-item` for interactions/agents, `app:<name>:<type>` for
435
+ * types, `app:<name>:<process>` for processes).
436
+ */
437
+ /**
438
+ * Build progress for one artifact, maintained by the developer agent as a living checklist:
439
+ * - `pending` — defined by the architect, not yet built.
440
+ * - `built` — registered in the package, not yet successfully exercised.
441
+ * - `done` — built AND successfully exercised against real data.
442
+ * This is the agent's self-reported claim for tracking/handoff; the capability gate verifies
443
+ * the truth independently via package registration + run/data telemetry and does not trust it.
444
+ */
445
+ export type AppArtifactStatus = 'pending' | 'built' | 'done';
446
+
447
+ export const APP_ARTIFACT_STATUSES: readonly AppArtifactStatus[] = ['pending', 'built', 'done'];
448
+
449
+ export interface AppPlannedArtifact {
450
+ /** App-owned in-code id the build must register and reference. */
451
+ id: string;
452
+ type: AppArtifactType;
453
+ /** Short human label. */
454
+ name?: string;
455
+ /** Why this artifact exists / what it does — carried into the build checklist. */
456
+ purpose?: string;
457
+ /**
458
+ * When false, the artifact is planned but optional: the capability gate warns rather
459
+ * than blocks if it is missing or never exercised. Defaults to required (true).
460
+ */
461
+ required?: boolean;
462
+ /** Build progress, updated by the developer agent. Defaults to `pending`. */
463
+ status?: AppArtifactStatus;
464
+ }
465
+
466
+ /**
467
+ * Structured result the App Solution Architect emits alongside its prose artifacts — the
468
+ * machine-readable contract for the build. The implementation MUST create and successfully
469
+ * exercise every required artifact before building a deployable version. Persisted into the app repo as
470
+ * {@link APP_CAPABILITY_MANIFEST_PATH} so it survives across runs and the version-build
471
+ * capability gate can verify against it deterministically. If the builder finds the plan
472
+ * wrong or insufficient, the orchestrator relaunches the architect to revise the manifest;
473
+ * the gate always checks against the latest committed copy.
474
+ */
475
+ export interface AppCapabilityManifest {
476
+ /** Artifact-storage ref to the prose architecture spec (e.g. the architecture `.md`). */
477
+ spec_artifact: string;
478
+ /** Platform artifacts the build must create. */
479
+ artifacts: AppPlannedArtifact[];
480
+ /**
481
+ * Monotonic revision, starting at 1, bumped each time the architect evolves the manifest for
482
+ * the SAME app on a later iteration (read the committed manifest, preserve untouched artifacts,
483
+ * add/modify/remove, then bump). Lets downstream agents tell which contract they are building to.
484
+ */
485
+ revision?: number;
486
+ /**
487
+ * Newest-first change notes, one entry per revision (what was added/modified/removed and why).
488
+ * How manifest changes are communicated to downstream agents across iterations.
489
+ */
490
+ changelog?: string[];
491
+ /** Optional free-form notes the architect wants the builder to honor. */
492
+ notes?: string;
493
+ }
494
+
495
+ /** Repo-relative path the capability manifest is committed to, read by version-build gates. */
496
+ export const APP_CAPABILITY_MANIFEST_PATH = 'docs/app-capability-manifest.json';
386
497
  export type AppAvailableIn = 'app_portal' | 'composite_app';
387
498
 
499
+ export type AppVersionKind = 'design' | 'version';
500
+ export type AppVersionState = 'ready' | 'failed' | 'expired';
501
+ export type AppVersionTarget = 'static' | 'service';
502
+ export type AppVersionGitRefType = 'branch' | 'tag' | 'commit' | 'detached';
503
+ export type AppBuildTrigger = 'ui' | 'git_push' | 'agent' | 'api';
504
+
505
+ export interface AppVersionStorage {
506
+ tenant_id?: string;
507
+ app_prefix?: string;
508
+ artifacts_prefix?: string;
509
+ source_archive?: string;
510
+ source_git?: AppVersionGitSource;
511
+ build_prefix?: string;
512
+ manifest_path?: string;
513
+ service_archive?: string;
514
+ live_metadata_path?: string;
515
+ }
516
+
517
+ export interface AppVersionGitSource {
518
+ url?: string;
519
+ remote?: string;
520
+ /**
521
+ * The source ref that should be used to reproduce this version. Immutable
522
+ * app versions use the exact commit SHA rather than a mutable branch or tag.
523
+ */
524
+ ref?: string;
525
+ ref_type?: AppVersionGitRefType;
526
+ branch?: string;
527
+ tag?: string;
528
+ commit?: string;
529
+ dirty?: boolean;
530
+ pushed?: boolean;
531
+ push_warning?: string;
532
+ }
533
+
534
+ export interface AppVersionUrls {
535
+ live_url?: string;
536
+ app_url?: string;
537
+ plugin_url?: string;
538
+ package_url?: string;
539
+ internal_preview_url?: string;
540
+ }
541
+
542
+ export interface AppVersionRecord {
543
+ id: string;
544
+ account: string;
545
+ project: string;
546
+ app?: string;
547
+ app_id: string;
548
+ app_name: string;
549
+ version_id: string;
550
+ kind: AppVersionKind;
551
+ state: AppVersionState;
552
+ promoted?: boolean;
553
+ target?: AppVersionTarget;
554
+ agent_run_id?: string;
555
+ /** Temporal workflow that produced this version. */
556
+ build_workflow_id?: string;
557
+ /** Temporal run that produced this version. */
558
+ build_workflow_run_id?: string;
559
+ sandbox_id?: string;
560
+ title?: string;
561
+ description?: string;
562
+ storage?: AppVersionStorage;
563
+ /** Exact Git commit used to build this immutable version. */
564
+ source_commit?: string;
565
+ urls?: AppVersionUrls;
566
+ manifest?: Record<string, unknown>;
567
+ files?: string[];
568
+ file_count?: number;
569
+ source_file_count?: number;
570
+ screenshot_artifact?: string;
571
+ checks?: string[];
572
+ created_by?: string;
573
+ created_at: string;
574
+ updated_at: string;
575
+ built_at?: string;
576
+ checked_at?: string;
577
+ expires_at?: string;
578
+ }
579
+
580
+ export interface DeleteAppVersionResponse {
581
+ id: string;
582
+ app_id: string;
583
+ version_id: string;
584
+ storage_prefix?: string;
585
+ deleted: boolean;
586
+ warnings: string[];
587
+ }
588
+
589
+ export interface UpsertAppVersionRequest {
590
+ /** Existing version record to update in place, used by reproducible rebuilds. */
591
+ record_id?: string;
592
+ app?: string;
593
+ app_id: string;
594
+ app_name?: string;
595
+ version_id: string;
596
+ kind: AppVersionKind;
597
+ state?: AppVersionState;
598
+ target?: AppVersionTarget;
599
+ agent_run_id?: string;
600
+ build_workflow_id?: string;
601
+ build_workflow_run_id?: string;
602
+ sandbox_id?: string;
603
+ title?: string;
604
+ description?: string;
605
+ storage?: AppVersionStorage;
606
+ /** Exact Git commit used to build this immutable version. */
607
+ source_commit?: string;
608
+ urls?: AppVersionUrls;
609
+ manifest?: Record<string, unknown>;
610
+ files?: string[];
611
+ file_count?: number;
612
+ source_file_count?: number;
613
+ screenshot_artifact?: string;
614
+ checks?: string[];
615
+ built_at?: string;
616
+ checked_at?: string;
617
+ expires_at?: string;
618
+ }
619
+
620
+ export interface AppVersionListQuery {
621
+ app_id?: string;
622
+ kind?: AppVersionKind;
623
+ include_expired?: boolean;
624
+ limit?: number;
625
+ }
626
+
627
+ export interface PromoteAppVersionResponse {
628
+ version: AppVersionRecord;
629
+ app?: AppManifest;
630
+ }
631
+
632
+ export interface StartAppBuildRequest {
633
+ /**
634
+ * Source branch, tag, or commit to build. When omitted, the app source
635
+ * configuration chooses its default branch.
636
+ */
637
+ source_ref?: string;
638
+ source_ref_type?: Extract<AppVersionGitRefType, 'branch' | 'tag' | 'commit'>;
639
+ trigger?: AppBuildTrigger;
640
+ target?: AppVersionTarget;
641
+ title?: string;
642
+ description?: string;
643
+ }
644
+
645
+ export interface StartAppBuildResponse {
646
+ workflow_id: string;
647
+ run_id: string;
648
+ app_id: string;
649
+ version_id?: string;
650
+ rebuild_version_record_id?: string;
651
+ source_ref?: string;
652
+ source_ref_type?: Extract<AppVersionGitRefType, 'branch' | 'tag' | 'commit'>;
653
+ }
654
+
655
+ export interface AppBuildWorkflowInput extends StartAppBuildRequest {
656
+ app_id: string;
657
+ app_record_id?: string;
658
+ /** Rebuild this persisted version record at its original commit and target. */
659
+ rebuild_version_record_id?: string;
660
+ app_title?: string;
661
+ app_description?: string;
662
+ source_git_url?: string;
663
+ }
664
+
665
+ export interface AppBuildWorkflowResult {
666
+ app_id: string;
667
+ version_id: string;
668
+ kind: Extract<AppVersionKind, 'version'>;
669
+ state: AppVersionState;
670
+ source_commit: string;
671
+ source_git?: AppVersionGitSource;
672
+ urls?: AppVersionUrls;
673
+ file_count?: number;
674
+ }
675
+
676
+ export type AppBuildProgressStatus = 'queued' | 'resolving' | 'building' | 'completed' | 'failed';
677
+
678
+ export interface AppBuildProgress {
679
+ status: AppBuildProgressStatus;
680
+ step: string;
681
+ app_id?: string;
682
+ version_id?: string;
683
+ source_ref?: string;
684
+ source_ref_type?: Extract<AppVersionGitRefType, 'branch' | 'tag' | 'commit'>;
685
+ source_commit?: string;
686
+ file_count?: number;
687
+ app_url?: string;
688
+ error?: string;
689
+ updated_at: string;
690
+ }
691
+
692
+ export type AppScaffoldModule = 'service' | 'assistant' | 'content-app' | 'examples';
693
+
694
+ export interface StartAppScaffoldRequest {
695
+ /**
696
+ * App id / package name to create. It is normalized to the same slug rules
697
+ * used by @vertesia/create-plugin.
698
+ */
699
+ app_id: string;
700
+ title?: string;
701
+ description?: string;
702
+ modules?: AppScaffoldModule[];
703
+ /**
704
+ * Start an initial app version build after the source has been pushed.
705
+ * Defaults to true.
706
+ */
707
+ create_version?: boolean;
708
+ }
709
+
710
+ export interface StartAppScaffoldResponse {
711
+ workflow_id: string;
712
+ run_id: string;
713
+ app_id: string;
714
+ app_record_id?: string;
715
+ git_url?: string;
716
+ create_version: boolean;
717
+ }
718
+
719
+ export interface AppScaffoldWorkflowInput extends StartAppScaffoldRequest {}
720
+
721
+ export interface AppScaffoldWorkflowResult {
722
+ app_id: string;
723
+ app_record_id?: string;
724
+ git_url?: string;
725
+ source_git?: AppVersionGitSource;
726
+ files?: number;
727
+ initial_version_build?: StartAppBuildResponse;
728
+ }
729
+
730
+ export type AppScaffoldProgressStatus =
731
+ | 'queued'
732
+ | 'reserving'
733
+ | 'scaffolding'
734
+ | 'pushing'
735
+ | 'building'
736
+ | 'completed'
737
+ | 'failed';
738
+
739
+ export interface AppScaffoldProgress {
740
+ status: AppScaffoldProgressStatus;
741
+ step: string;
742
+ app_id?: string;
743
+ app_record_id?: string;
744
+ git_url?: string;
745
+ files?: number;
746
+ initial_version_build?: StartAppBuildResponse;
747
+ error?: string;
748
+ error_details?: string[];
749
+ updated_at: string;
750
+ }
751
+
388
752
  /**
389
753
  * Access control policy for an app installation.
390
754
  * Declares which access surfaces are gated by per-user ACEs.
@@ -445,6 +809,18 @@ export interface AppManifestData {
445
809
  */
446
810
  color?: string;
447
811
 
812
+ /**
813
+ * Optional preview screenshot for the app-management UI, captured by the builder during a
814
+ * build/QA run. Resolved client-side from the owning agent run's artifact storage, so it
815
+ * carries both the run id and the artifact path.
816
+ */
817
+ preview_screenshot?: {
818
+ /** Agent run id whose artifact storage holds the screenshot. */
819
+ agent_run_id: string;
820
+ /** Artifact path within that storage, e.g. "preview-checks/app-preview-<ts>.png". */
821
+ artifact: string;
822
+ };
823
+
448
824
  status: 'beta' | 'stable' | 'deprecated';
449
825
 
450
826
  /**
@@ -501,6 +877,8 @@ export interface AppManifestData {
501
877
  * - interactions
502
878
  * - types
503
879
  * - processes
880
+ * - templates
881
+ * - dashboards
504
882
  * - settings
505
883
  * - all (the default if no scope is provided)
506
884
  * You can also use comma-separated values to combine scopes (e.g. "ui,tools").
@@ -523,6 +901,14 @@ export interface AppManifestData {
523
901
  */
524
902
  version?: string;
525
903
 
904
+ /**
905
+ * Source repository configuration for apps generated and maintained through
906
+ * AppGen. Branches are mutable development lanes; immutable app versions
907
+ * record their exact source commit in AppVersionRecord.source_commit and
908
+ * AppVersionRecord.storage.source_git.
909
+ */
910
+ source?: AppSourceConfig;
911
+
526
912
  /**
527
913
  * Free-form tags used for classification and filtering. Platform apps
528
914
  * carry `"system"` so UIs can skip install/uninstall/manage-permission
@@ -538,20 +924,16 @@ export interface AppManifestData {
538
924
  access_control?: AppAccessControl;
539
925
  }
540
926
 
541
- /**
542
- * Reserved deployment environment names that may never be used as endpoint
543
- * override keys. Reserving them prevents a manifest from hijacking auto-resolution
544
- * on a shared production studio-server (whose `Env.environment` is one of these).
545
- */
546
- const RESERVED_ENDPOINT_OVERRIDE_ENVS = new Set(['production', 'preview', 'staging']);
927
+ export interface AppGitSourceConfig {
928
+ url?: string;
929
+ default_branch?: string;
930
+ production_branch?: string;
931
+ development_branch?: string;
932
+ }
547
933
 
548
- /**
549
- * Returns true if the given environment name is allowed as an endpoint override key.
550
- * Any non-empty name is accepted except the reserved shared-deployment names.
551
- */
552
- export function isValidEndpointOverrideEnv(envName: string): boolean {
553
- if (!envName) return false;
554
- return !RESERVED_ENDPOINT_OVERRIDE_ENVS.has(envName.toLowerCase());
934
+ export interface AppSourceConfig {
935
+ kind: 'git';
936
+ git?: AppGitSourceConfig;
555
937
  }
556
938
 
557
939
  /**
@@ -569,6 +951,10 @@ export interface Endpoints {
569
951
  token?: string;
570
952
  /** The browser-facing Studio UI (composable-ui) base URL */
571
953
  ui?: string;
954
+ /** The Smart HTTP app source git server base URL */
955
+ git?: string;
956
+ /** The appgen app-gateway base URL (serves promoted app bundles + their `/api` runtime). */
957
+ gateway?: string;
572
958
  }
573
959
 
574
960
  /**
@@ -577,7 +963,7 @@ export interface Endpoints {
577
963
  * with the unresolved placeholder visible, rather than silently pointing nowhere).
578
964
  * Trailing slashes on replacement values are stripped to avoid `//api/...` joins.
579
965
  */
580
- export function substituteEndpoints(url: string, endpoints?: Endpoints): string {
966
+ function substituteEndpoints(url: string, endpoints?: Endpoints): string {
581
967
  if (!url || !endpoints) return url;
582
968
  return url.replace(/\{\{\s*(\w+)\s*\}\}/g, (match, key: string) => {
583
969
  const value = (endpoints as Record<string, string | undefined>)[key];
@@ -594,85 +980,109 @@ function trimTrailingSlashes(value: string): string {
594
980
  return end === value.length ? value : value.slice(0, end);
595
981
  }
596
982
 
597
- /**
598
- * Resolves the effective endpoint for an app.
599
- *
600
- * Order of resolution:
601
- * 1. If `requestedOverride` matches an `endpoint_overrides` key, use that URL
602
- * (caller must verify the user is allowed to use the override).
603
- * 2. Else if `envName` matches an `endpoint_overrides` key, use that URL
604
- * (auto-resolution from the studio-server's deployment env).
605
- * 3. Otherwise use the main `endpoint`.
606
- * 4. Apply `{{var}}` substitution using `vars`.
607
- */
608
- export function resolveAppEndpoint(
609
- manifest: Pick<AppManifestData, 'endpoint' | 'endpoint_overrides'>,
610
- envName?: string,
611
- vars?: Endpoints,
612
- requestedOverride?: string,
613
- ): string | undefined {
614
- let raw: string | undefined;
615
- if (
616
- requestedOverride &&
617
- manifest.endpoint_overrides?.[requestedOverride] &&
618
- isValidEndpointOverrideEnv(requestedOverride)
619
- ) {
620
- raw = manifest.endpoint_overrides[requestedOverride];
621
- } else if (envName && manifest.endpoint_overrides?.[envName] && isValidEndpointOverrideEnv(envName)) {
622
- raw = manifest.endpoint_overrides[envName];
623
- } else {
624
- raw = manifest.endpoint;
625
- }
626
- return raw ? substituteEndpoints(raw, vars) : raw;
983
+ /** One entry in an app git-repo directory listing (see {@link AppRepoTree}). */
984
+ export interface AppRepoTreeEntry {
985
+ /** File or directory name (last path segment). */
986
+ name: string;
987
+ /** Path relative to the repo root. */
988
+ path: string;
989
+ /** Whether the entry is a file (`blob`) or a directory (`tree`). */
990
+ type: 'blob' | 'tree';
991
+ }
992
+
993
+ /** A non-recursive listing of an app git repo directory at a given ref. */
994
+ export interface AppRepoTree {
995
+ /** The ref the listing was read at (empty/undefined = default branch / HEAD). */
996
+ ref?: string;
997
+ /** The directory prefix that was listed (empty = repo root). */
998
+ prefix?: string;
999
+ entries: AppRepoTreeEntry[];
1000
+ }
1001
+
1002
+ /** Browser-side limits mirrored by the app Git service document endpoint. */
1003
+ export const APP_REPO_DOCUMENT_UPLOAD_MAX_FILE_BYTES = 20 * 1024 * 1024;
1004
+ export const APP_REPO_DOCUMENT_UPLOAD_MAX_TOTAL_BYTES = 80 * 1024 * 1024;
1005
+ export const APP_REPO_DOCUMENT_UPLOAD_MAX_FILES = 20;
1006
+ export const APP_REPO_DOCUMENT_UPLOAD_PREFIX = 'docs/';
1007
+
1008
+ /** Result of committing one or more uploaded documents to an app repository. */
1009
+ export interface AppRepoDocumentCommit {
1010
+ /** Updated branch name. */
1011
+ ref: string;
1012
+ /** Branch HEAD before the commit. */
1013
+ previous_commit: string;
1014
+ /** Newly created commit SHA. */
1015
+ commit: string;
1016
+ /** Repository paths changed by the commit. */
1017
+ paths: string[];
1018
+ }
1019
+
1020
+ /** One commit that inserted or changed a file in an app git repository. */
1021
+ export interface AppRepoCommit {
1022
+ /** Full commit SHA. */
1023
+ commit: string;
1024
+ /** Complete commit message. */
1025
+ message: string;
1026
+ /** Commit author name, when available. */
1027
+ author?: string;
1028
+ /** Commit author date as an ISO-8601 string, when available. */
1029
+ date?: string;
1030
+ }
1031
+
1032
+ /** Commit history in an app git repository, optionally filtered to a file. */
1033
+ export interface AppRepoCommits {
1034
+ /** Ref from which history traversal started (empty/undefined = default branch / HEAD). */
1035
+ ref?: string;
1036
+ /** File path relative to the repository root, when history was filtered to a file. */
1037
+ path?: string;
1038
+ /** Commits ordered newest first. */
1039
+ commits: AppRepoCommit[];
1040
+ /** Pass this cursor to retrieve the next page. Absent when history is exhausted. */
1041
+ next_cursor?: string;
1042
+ }
1043
+
1044
+ /** A branch or tag in an app git repo, resolved to its latest commit. */
1045
+ export interface AppRepoRef {
1046
+ /** Short ref name (e.g. `main`, `v1.0.0`). */
1047
+ name: string;
1048
+ /** Commit hash the ref points at (annotated tags are peeled to their commit). */
1049
+ commit: string;
1050
+ /** First line of the commit message, when available. */
1051
+ commit_subject?: string;
1052
+ /** Commit date as an ISO-8601 string, when available. */
1053
+ commit_date?: string;
1054
+ /** Commit author name, when available. */
1055
+ commit_author?: string;
627
1056
  }
628
1057
 
629
- /**
630
- * Resolves all URL placeholders in a manifest in place (both `endpoint` and
631
- * `tool_collections[].url`). Intended for server-side serialization — clients and
632
- * downstream workers receive already-substituted URLs so they don't need to know
633
- * about deployment-time vars.
634
- *
635
- * Mutates the manifest rather than returning a copy so it works cleanly with
636
- * Mongoose populated subdocs.
637
- */
638
- export function resolveManifestUrls(
639
- manifest: Partial<AppManifestData> | null | undefined,
640
- envName?: string,
641
- vars?: Endpoints,
642
- requestedOverride?: string,
643
- ): void {
644
- if (!manifest) return;
645
-
646
- if (manifest.endpoint) {
647
- const resolved = resolveAppEndpoint(manifest, envName, vars, requestedOverride);
648
- if (resolved && resolved !== manifest.endpoint) {
649
- manifest.endpoint = resolved;
650
- }
651
- }
652
-
653
- const toolCollections = manifest.tool_collections as ToolCollectionObject[] | undefined;
654
- if (toolCollections && Array.isArray(toolCollections)) {
655
- for (let i = 0; i < toolCollections.length; i++) {
656
- const item = toolCollections[i];
657
- if (item && typeof item === 'object' && item.url) {
658
- const sub = substituteEndpoints(item.url, vars);
659
- if (sub !== item.url) item.url = sub;
660
- }
661
- }
662
- }
1058
+ /** The branches and tags of an app git repo (see {@link AppRepoRef}). */
1059
+ export interface AppRepoRefs {
1060
+ /** The repository's default branch (HEAD target), when resolvable. */
1061
+ default_branch?: string;
1062
+ branches: AppRepoRef[];
1063
+ tags: AppRepoRef[];
663
1064
  }
664
1065
 
665
- export type AppPackageScope =
666
- | 'ui'
667
- | 'tools'
668
- | 'interactions'
669
- | 'types'
670
- | 'processes'
671
- | 'templates'
672
- | 'settings'
673
- | 'widgets'
674
- | 'activities'
675
- | 'all';
1066
+ /**
1067
+ * Canonical package scopes, including the catch-all `all`. The public type is derived
1068
+ * from this list so request parsing and TypeScript cannot drift.
1069
+ */
1070
+ export const APP_PACKAGE_SCOPES = [
1071
+ 'ui',
1072
+ 'tools',
1073
+ 'interactions',
1074
+ 'types',
1075
+ 'processes',
1076
+ 'views',
1077
+ 'templates',
1078
+ 'dashboards',
1079
+ 'settings',
1080
+ 'widgets',
1081
+ 'activities',
1082
+ 'all',
1083
+ ] as const;
1084
+
1085
+ export type AppPackageScope = (typeof APP_PACKAGE_SCOPES)[number];
676
1086
  export interface AppPackage {
677
1087
  /**
678
1088
  * The UI configuration of the app
@@ -707,11 +1117,21 @@ export interface AppPackage {
707
1117
  */
708
1118
  processes?: InCodeProcessDefinition[];
709
1119
 
1120
+ /**
1121
+ * View Experiences exposed by the app as in-code definitions.
1122
+ */
1123
+ views?: InCodeViewDefinition[];
1124
+
710
1125
  /**
711
1126
  * Templates provided by the app.
712
1127
  */
713
1128
  templates?: RenderingTemplateDefinitionRef[];
714
1129
 
1130
+ /**
1131
+ * Dashboards provided by the app.
1132
+ */
1133
+ dashboards?: AppDashboardDefinition[];
1134
+
715
1135
  /**
716
1136
  * Widgets provided by the app.
717
1137
  */
@@ -730,6 +1150,61 @@ export interface AppPackage {
730
1150
  settings_schema?: JSONSchema;
731
1151
  }
732
1152
 
1153
+ /**
1154
+ * A single diagnostic produced while inspecting an app's registration state.
1155
+ */
1156
+ export interface AppInspectionIssue {
1157
+ severity: 'error' | 'warning';
1158
+ /** The capability this issue relates to, when applicable (e.g. 'types'). */
1159
+ capability?: AppPackageScope;
1160
+ /** Stable machine code, e.g. 'capability_declared_but_empty', 'endpoint_unreachable', 'not_installed'. */
1161
+ code: string;
1162
+ /** Human-readable explanation, safe to surface to the model and the UI. */
1163
+ message: string;
1164
+ }
1165
+
1166
+ /**
1167
+ * Per-capability report of what an app's promoted package actually exposes,
1168
+ * compared against what its manifest declares.
1169
+ */
1170
+ export interface AppInspectionCapabilityReport {
1171
+ capability: AppPackageScope;
1172
+ /** True when the manifest's `capabilities` array declares this capability. */
1173
+ declared: boolean;
1174
+ /** The local ids the promoted package actually serves for this capability. */
1175
+ exposed_ids: string[];
1176
+ /** Convenience count of `exposed_ids`. */
1177
+ exposed_count: number;
1178
+ }
1179
+
1180
+ /**
1181
+ * Result of inspecting an app's registration: the resolved manifest state, what
1182
+ * the promoted package actually exposes per capability, and diagnostics. This
1183
+ * is the ground truth used by the `app_inspect_registration` agent tool and the
1184
+ * Build › App inspection UI to verify what is registered vs declared, instead of
1185
+ * inferring it from failed object/import calls.
1186
+ */
1187
+ export interface AppInspectionResult {
1188
+ app_id: string;
1189
+ name: string;
1190
+ version?: string;
1191
+ /** The resolved package endpoint for the current environment, if any. */
1192
+ endpoint?: string;
1193
+ /** True when the package endpoint responded to the capability probe. */
1194
+ endpoint_reachable: boolean;
1195
+ /** True when the app is installed in the current project. */
1196
+ installed: boolean;
1197
+ access_control?: string;
1198
+ /** The capabilities declared on the manifest. */
1199
+ capabilities: AppPackageScope[];
1200
+ /** What the promoted package exposes, per capability. */
1201
+ package: AppInspectionCapabilityReport[];
1202
+ /** Diagnostics — errors and warnings about the registration state. */
1203
+ issues: AppInspectionIssue[];
1204
+ /** Populated when the package probe itself failed (endpoint error/unreachable). */
1205
+ probe_error?: string;
1206
+ }
1207
+
733
1208
  export interface AppWidgetInfo {
734
1209
  collection: string;
735
1210
  skill: string;
@@ -775,6 +1250,7 @@ export interface AppManifestSource {
775
1250
  git: {
776
1251
  url: string;
777
1252
  default_branch?: string;
1253
+ production_branch?: string;
778
1254
  development_branch?: string;
779
1255
  };
780
1256
  }
@@ -1322,3 +1798,20 @@ export interface ValidateUrlRequest {
1322
1798
  export interface ValidateUrlResponse {
1323
1799
  valid: true;
1324
1800
  }
1801
+
1802
+ /**
1803
+ * Result of DELETE /api/v1/apps/:id. With `?confirm=true` the cascade runs and
1804
+ * `deleted: true` is set; without it the endpoint returns a dry-run summary so
1805
+ * the UI can show what would be removed.
1806
+ */
1807
+ export interface AppDeleteSummary {
1808
+ confirmed: boolean;
1809
+ app_id: string;
1810
+ app_name: string;
1811
+ versions: number;
1812
+ installations: number;
1813
+ storage_prefix: string;
1814
+ git_repo_url?: string;
1815
+ deleted: boolean;
1816
+ warnings: string[];
1817
+ }