@synap-core/workspace-templates 0.6.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -243,6 +243,52 @@ interface TemplatePlaybook {
243
243
  };
244
244
  status?: 'draft' | 'active' | 'paused';
245
245
  }
246
+ interface TemplateAutomation {
247
+ /** Stable local key (unused on the wire today — reserved for dedup/refs). */
248
+ key?: string;
249
+ name: string;
250
+ description?: string;
251
+ triggerType: 'event' | 'cron' | 'webhook' | 'manual';
252
+ triggerConfig?: Record<string, unknown>;
253
+ flow: {
254
+ nodes: unknown[];
255
+ edges: unknown[];
256
+ precondition?: string;
257
+ };
258
+ status?: 'draft' | 'active' | 'paused';
259
+ }
260
+ interface TemplateActionPlacement {
261
+ /** Entity kind whose detail surface this action appears on. */
262
+ profileSlug: string;
263
+ /** Where the action renders. Only "entity-detail" is consumed today. */
264
+ surface: 'entity-detail' | string;
265
+ /** What the action does when clicked. */
266
+ kind: 'capability' | 'playbook' | 'automation';
267
+ /**
268
+ * Reference to the thing to run: a capability verb key, or a playbook /
269
+ * automation NAME (resolved to a row id at apply time).
270
+ */
271
+ ref: string;
272
+ /** Human label shown on the action button. */
273
+ label: string;
274
+ /** Additional entity-state requirements, evaluated by the rendering surface. */
275
+ when?: {
276
+ /** All listed workspace facets must be present on the entity. */
277
+ requiredFacetSlugs?: string[];
278
+ /** Entity property values that must equal their configured literal values. */
279
+ propertyEquals?: Record<string, unknown>;
280
+ /** Any configured property/value match makes the action applicable. */
281
+ propertyAnyEquals?: Record<string, unknown[]>;
282
+ /** Entity property values that must not equal their configured literal values. */
283
+ propertyNotEquals?: Record<string, unknown>;
284
+ };
285
+ /** Explicit intent required before a consequential action is launched. */
286
+ confirmation?: {
287
+ title: string;
288
+ description?: string;
289
+ confirmLabel?: string;
290
+ };
291
+ }
246
292
  interface TemplateIntegration {
247
293
  /** Capability template key to install (matches a capability template). */
248
294
  templateKey: string;
@@ -406,6 +452,16 @@ interface WorkspaceYaml {
406
452
  profileEntityBentoTemplates?: TemplateProfileEntityBentoTemplates;
407
453
  /** Playbooks (session templates) seeded with the workspace */
408
454
  playbooks?: TemplatePlaybook[];
455
+ /**
456
+ * Flow-based automations (WHEN→THEN triggers) seeded with the workspace.
457
+ * Applier-only — see {@link TemplateAutomation}.
458
+ */
459
+ automations?: TemplateAutomation[];
460
+ /**
461
+ * Entity-detail action placements seeded into `settings.actionPlacements`.
462
+ * See {@link TemplateActionPlacement}.
463
+ */
464
+ actionPlacements?: TemplateActionPlacement[];
409
465
  /** Capability templates (tools/connectors) to install on provisioning */
410
466
  integrations?: TemplateIntegration[];
411
467
  /**
@@ -652,6 +708,48 @@ interface AssembleCatalogInput {
652
708
  * per-source `isPrivate` control (e.g. keeping browse and `/mine` distinct).
653
709
  */
654
710
  declare function assembleCatalog(input: AssembleCatalogInput): MergeCatalogResult;
711
+ /** A template a pod has installed — the door reads `settings.packageVersion` off the workspace row. */
712
+ interface InstalledTemplate {
713
+ slug: string;
714
+ version: string;
715
+ }
716
+ /** Per-slug verdict: is a newer catalog version available than what's installed? */
717
+ interface TemplateUpdateCheck {
718
+ slug: string;
719
+ installedVersion: string;
720
+ /** `undefined` when the slug has no matching catalog entry, or a bundled winner and no `bundleVersion` was passed. */
721
+ latestVersion: string | undefined;
722
+ updateAvailable: boolean;
723
+ /** Passed through from the winning catalog entry, so callers can route private updates through the authed path. */
724
+ isPrivate?: boolean;
725
+ }
726
+ /**
727
+ * `true` when `version` is a CP content-hash stamp (`"h-<hash>"`) rather than semver.
728
+ * Content-hash versions are NOT semver-comparable — see `computeTemplateUpdates`.
729
+ */
730
+ declare function isHashVersion(version: string | undefined): boolean;
731
+ /**
732
+ * Compute, per installed template, whether the CATALOG (bundled + remote,
733
+ * already merged by `mergeCatalog`/`assembleCatalog`) carries a newer version
734
+ * than what the pod installed — the shared "update available" check all three
735
+ * doors (browser, synap-app, CLI) reuse instead of re-deriving it.
736
+ *
737
+ * `installed` and `catalog` are BOTH already-fetched/computed by the caller —
738
+ * this stays PURE, same as the rest of this module (no fetch, no auth).
739
+ *
740
+ * The catalog's winning entry carries the latest version signal two ways:
741
+ * • `source: "remote"` → `remote.definition?.sourcePackage?.version` (semver
742
+ * OR, going forward, a CP content-hash `"h-<hash>"` stamp).
743
+ * • `source: "bundled"` → bundled entries carry no version field at all
744
+ * (`TemplateMeta` has none); pass `bundleVersion` (this client's compiled
745
+ * package version, the same value fed to `mergeCatalog`) to compare against
746
+ * it. Omit `bundleVersion` and bundled-backed slugs report `latestVersion:
747
+ * undefined, updateAvailable: false` (nothing comparable).
748
+ *
749
+ * A slug with no matching catalog entry ⇒ `updateAvailable: false`,
750
+ * `latestVersion: undefined` — there is nothing to update TO.
751
+ */
752
+ declare function computeTemplateUpdates(installed: InstalledTemplate[], catalog: CatalogEntry[], bundleVersion?: string): TemplateUpdateCheck[];
655
753
 
656
754
  /**
657
755
  * @synap-core/workspace-templates — Definition adapter
@@ -665,6 +763,25 @@ declare function assembleCatalog(input: AssembleCatalogInput): MergeCatalogResul
665
763
  * shape never drifts per call-site.
666
764
  */
667
765
 
766
+ /**
767
+ * A `TemplateAutomation` as the apply door expects it: `flowDefinition`, not
768
+ * the authored `flow` (mirrors `PackagePostWorkspaceBody['automations'][number]`
769
+ * / the Hub `POST /packages/apply` `AutomationSchema`).
770
+ */
771
+ interface PackageAutomationWire {
772
+ /** Stable template identity; names may be edited without orphaning the flow. */
773
+ key?: string;
774
+ name: string;
775
+ description?: string;
776
+ triggerType: TemplateAutomation['triggerType'];
777
+ triggerConfig?: Record<string, unknown>;
778
+ flowDefinition?: {
779
+ nodes: unknown[];
780
+ edges: unknown[];
781
+ precondition?: string;
782
+ };
783
+ status?: TemplateAutomation['status'];
784
+ }
668
785
  /** A widget block as the wire expects it: `bentoLayout[]`, keyed by `widgetType`. */
669
786
  interface BentoWidgetBlockWire {
670
787
  widgetType: string;
@@ -719,6 +836,21 @@ interface WorkspaceDefinitionInput {
719
836
  * tools/skills/automations silently dropped on that door.
720
837
  */
721
838
  capabilities?: WorkspaceYaml['integrations'];
839
+ /** Playbooks normalized to the workspace-create input contract. */
840
+ playbooks?: Array<Record<string, unknown>>;
841
+ /**
842
+ * Entity-detail action placements — forwarded verbatim to
843
+ * `applyPackagePostWorkspace`, which merges them into
844
+ * `settings.actionPlacements`. The tRPC door (`createFromDefinition`)
845
+ * declares `actionPlacements` in its zod input and carries them through the
846
+ * shared apply door. No shape transform: the authored form IS the wire form.
847
+ */
848
+ actionPlacements?: WorkspaceYaml['actionPlacements'];
849
+ /**
850
+ * Graph-based automations. Deliberately distinct from the legacy
851
+ * `automations` loop/playbook-trigger wire shape accepted by this door.
852
+ */
853
+ flowAutomations?: PackageAutomationWire[];
722
854
  workspaceSubtype?: string;
723
855
  workspaceType?: NonNullable<WorkspaceYaml['workspace']>['workspaceType'];
724
856
  workspaceVisibility?: string;
@@ -798,6 +930,19 @@ interface PackageDefinitionOutput {
798
930
  layoutConfig?: WorkspaceYaml['layout'];
799
931
  capabilities?: WorkspaceYaml['integrations'];
800
932
  playbooks?: WorkspaceYaml['playbooks'];
933
+ /** Flow-based automations — mapped to the apply door's `flowDefinition` field. */
934
+ automations?: PackageAutomationWire[];
935
+ /**
936
+ * Entity-detail action placements — carried verbatim (authored form IS the
937
+ * wire form). NOTE: the Hub `PackageApplySchema` (synap-backend
938
+ * `hub-protocol/rest/packages.ts`) is a plain `z.object` and does not yet
939
+ * declare `actionPlacements`, so on the CLI/Hub install path this field is
940
+ * STRIPPED before `applyPackagePostWorkspace` sees it. The tRPC
941
+ * `createFromDefinition` door DOES carry it. Named follow-up: add an
942
+ * `ActionPlacementSchema` field to `PackageApplySchema` to close the Hub half
943
+ * (out of the T2 fence — flagged in the handoff).
944
+ */
945
+ actionPlacements?: WorkspaceYaml['actionPlacements'];
801
946
  onboarding?: WorkspaceYaml['onboarding'];
802
947
  /** Template-composition dependencies — resolved by the apply endpoint. */
803
948
  dependencies?: WorkspaceYaml['dependencies'];
@@ -810,4 +955,4 @@ interface PackageDefinitionOutput {
810
955
  */
811
956
  declare function toPackageDefinition(slugOrYaml: string | WorkspaceYaml): PackageDefinitionOutput;
812
957
 
813
- export { type AssembleCatalogInput, type BentoViewBlockWire, type BentoWidgetBlockWire, type BundledCatalogEntry, type BundledEntry, type CatalogEntry, type CpPackageRow, type MergeCatalogInput, type MergeCatalogResult, PACKAGE_DEPENDENCY_KINDS, type PackageDefinitionOutput, type PackageDependencyKind, type RemoteCatalogEntry, type RemoteEntry, type RemoteSourceStatus, type SplitBentoBlocks, type TemplateAppKind, type TemplateAppRef, type TemplateBentoBlock, type TemplateDefaultSource, type TemplateDependency, type TemplateDisplayTemplate, type TemplateEntityLink, type TemplateExtendsRef, type TemplateIntegration, type TemplateLayoutConfig, type TemplateMeta, type TemplateOnboarding, type TemplateOnboardingCollectTarget, type TemplatePlaybook, type TemplatePlaybookParam, type TemplateProfile, type TemplateProfileEntityBentoTemplates, type TemplateProperty, type TemplateSeedEntity, type TemplateSidebarItem, type TemplateSidebarSurface, type TemplateSourceRole, type TemplateSuggestedRelation, type TemplateView, type ToDefinitionResult, WORKSPACE_TEMPLATES, type WorkspaceDefinitionInput, type WorkspaceTemplateSlug, type WorkspaceYaml, assembleCatalog, getWorkspaceTemplate, listPublicTemplates, listWorkspaceTemplates, mergeCatalog, rowToRemoteEntry, splitBentoBlocks, toPackageDefinition, toWorkspaceDefinition };
958
+ export { type AssembleCatalogInput, type BentoViewBlockWire, type BentoWidgetBlockWire, type BundledCatalogEntry, type BundledEntry, type CatalogEntry, type CpPackageRow, type InstalledTemplate, type MergeCatalogInput, type MergeCatalogResult, PACKAGE_DEPENDENCY_KINDS, type PackageDefinitionOutput, type PackageDependencyKind, type RemoteCatalogEntry, type RemoteEntry, type RemoteSourceStatus, type SplitBentoBlocks, type TemplateActionPlacement, type TemplateAppKind, type TemplateAppRef, type TemplateAutomation, type TemplateBentoBlock, type TemplateDefaultSource, type TemplateDependency, type TemplateDisplayTemplate, type TemplateEntityLink, type TemplateExtendsRef, type TemplateIntegration, type TemplateLayoutConfig, type TemplateMeta, type TemplateOnboarding, type TemplateOnboardingCollectTarget, type TemplatePlaybook, type TemplatePlaybookParam, type TemplateProfile, type TemplateProfileEntityBentoTemplates, type TemplateProperty, type TemplateSeedEntity, type TemplateSidebarItem, type TemplateSidebarSurface, type TemplateSourceRole, type TemplateSuggestedRelation, type TemplateUpdateCheck, type TemplateView, type ToDefinitionResult, WORKSPACE_TEMPLATES, type WorkspaceDefinitionInput, type WorkspaceTemplateSlug, type WorkspaceYaml, assembleCatalog, computeTemplateUpdates, getWorkspaceTemplate, isHashVersion, listPublicTemplates, listWorkspaceTemplates, mergeCatalog, rowToRemoteEntry, splitBentoBlocks, toPackageDefinition, toWorkspaceDefinition };