@synap-core/workspace-templates 0.6.0 → 0.6.1
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 +247 -4
- package/dist/index.js +1762 -630
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/agent-fleet.yaml +16 -8
- package/src/catalog.test.ts +156 -0
- package/src/catalog.ts +285 -0
- package/src/communication.yaml +28 -1
- package/src/content-os.yaml +545 -0
- package/src/content-studio.yaml +0 -268
- package/src/crm.yaml +196 -0
- package/src/define.ts +268 -5
- package/src/enterprise-os.yaml +183 -0
- package/src/index.ts +27 -1
- package/src/marketing.yaml +14 -5
- package/src/templates.ts +1676 -656
- package/src/the-arch.yaml +182 -0
- package/src/types.ts +51 -1
package/dist/index.d.ts
CHANGED
|
@@ -269,6 +269,49 @@ interface TemplateExtendsRef {
|
|
|
269
269
|
* `grants` → `operations`). Distinct from `extends` (which imports from a live
|
|
270
270
|
* workspace, tRPC-only) — `dependencies` is template→template.
|
|
271
271
|
*/
|
|
272
|
+
/**
|
|
273
|
+
* PACKAGE_DEPENDENCY_KINDS — the dependency-kind vocabulary, declared ONCE.
|
|
274
|
+
*
|
|
275
|
+
* This tuple exists so consumers can IMPORT the vocabulary instead of
|
|
276
|
+
* hand-copying it. `TemplateDependency` is currently mirrored by hand in six
|
|
277
|
+
* other places, four of which carry a comment promising they match "VERBATIM so
|
|
278
|
+
* the wire shape never drifts" — a comment doing a type's job. A comment cannot
|
|
279
|
+
* fail a build; an import can. Those mirrors live in repos this package does not
|
|
280
|
+
* own, so this tuple does not fix them by existing — it makes the fix possible:
|
|
281
|
+
*
|
|
282
|
+
* - marketplace `types.ts:102`
|
|
283
|
+
* - onboarding `workspace-templates.ts:27`
|
|
284
|
+
* - synap-backend `package-definition.ts:204` (exports its own
|
|
285
|
+
* `PackageDependencyKind` — the closest peer)
|
|
286
|
+
* - hub-protocol REST `rest/packages.ts:140` (zod enum)
|
|
287
|
+
* - browser `InstallPackageDialog.tsx:262`
|
|
288
|
+
* - control-plane-api `routes/packages.ts:436` (zod enum)
|
|
289
|
+
*
|
|
290
|
+
* ⚠️ `'automation'` IS RETIRED VOCABULARY, deliberately still listed here.
|
|
291
|
+
* CP migration `0049_package_vocabulary` retired the `automation` package
|
|
292
|
+
* category in favour of `workflow` ("workflow — a triggered/sequenced run
|
|
293
|
+
* (absorbs 'automation' + 'playbook')", `PACKAGE_TYPES` in CP
|
|
294
|
+
* `db/schema/packages.ts`). A dependency's `kind` names the TYPE of package it
|
|
295
|
+
* points at, so this vocabulary should track `PACKAGE_TYPES` — meaning the live
|
|
296
|
+
* spelling is `workflow`, not `automation`.
|
|
297
|
+
*
|
|
298
|
+
* It is NOT renamed here, on purpose. This is latent, not live: 0/21 templates
|
|
299
|
+
* declare any `kind` other than the default `'workspace'`. And all four wire
|
|
300
|
+
* enums (CP + hub zod, above) still accept `'automation'` and do NOT accept
|
|
301
|
+
* `'workflow'` — so emitting `'workflow'` today would be rejected with a 400 at
|
|
302
|
+
* both doors, and dropping `'automation'` from this tuple would make any
|
|
303
|
+
* consumer that derives a zod enum from it start rejecting a value the wire
|
|
304
|
+
* still legally accepts (a published third-party package may carry it; CP's own
|
|
305
|
+
* schema permits it). Narrowing must therefore follow the wire, not lead it.
|
|
306
|
+
*
|
|
307
|
+
* ORDERED FIX (each step deployable alone, no flag day):
|
|
308
|
+
* 1. Widen the CP + hub zod enums to accept BOTH `'automation'` and `'workflow'`.
|
|
309
|
+
* 2. Add `'workflow'` here; mark `'automation'` deprecated; migrate any authored use.
|
|
310
|
+
* 3. Once no payload carries `'automation'`, drop it from the wire enums and this tuple.
|
|
311
|
+
*/
|
|
312
|
+
declare const PACKAGE_DEPENDENCY_KINDS: readonly ["workspace", "capability", "automation"];
|
|
313
|
+
/** What a `TemplateDependency` points at. Derived — never re-declare the list. */
|
|
314
|
+
type PackageDependencyKind = (typeof PACKAGE_DEPENDENCY_KINDS)[number];
|
|
272
315
|
interface TemplateDependency {
|
|
273
316
|
/** Slug of the template/package this one depends on. */
|
|
274
317
|
slug: string;
|
|
@@ -277,7 +320,7 @@ interface TemplateDependency {
|
|
|
277
320
|
* dependencies can be `compose`d; `'capability'`/`'automation'` are always
|
|
278
321
|
* `require`d present without merging.
|
|
279
322
|
*/
|
|
280
|
-
kind?:
|
|
323
|
+
kind?: PackageDependencyKind;
|
|
281
324
|
/**
|
|
282
325
|
* How this template relates to the dependency:
|
|
283
326
|
* - `'compose'`: this template is an OVERLAY on the dependency's workspace.
|
|
@@ -385,8 +428,171 @@ declare const WORKSPACE_TEMPLATES: Record<string, WorkspaceYaml>;
|
|
|
385
428
|
type WorkspaceTemplateSlug = keyof typeof WORKSPACE_TEMPLATES;
|
|
386
429
|
declare function getWorkspaceTemplate(slug: string): WorkspaceYaml | undefined;
|
|
387
430
|
declare function listWorkspaceTemplates(): WorkspaceYaml[];
|
|
431
|
+
/**
|
|
432
|
+
* Public templates only (`meta.isPublic !== false`). This is a CONVENIENCE
|
|
433
|
+
* filter for the default picker — NOT a security boundary: the private YAML
|
|
434
|
+
* still ships in the published tarball, so anything that must not leak cannot
|
|
435
|
+
* rely on this. `listWorkspaceTemplates()` returns all of them (CLI, seeder,
|
|
436
|
+
* tripwire need the full set). Publicity is also expressed per-entry as
|
|
437
|
+
* `CatalogEntry.isPrivate` by `mergeCatalog()`, so a caller can pass ALL
|
|
438
|
+
* templates and filter at the presentation layer instead of choosing a list
|
|
439
|
+
* function up front — the merge door itself never filters (it stays pure).
|
|
440
|
+
*/
|
|
388
441
|
declare function listPublicTemplates(): WorkspaceYaml[];
|
|
389
442
|
|
|
443
|
+
/**
|
|
444
|
+
* mergeCatalog — the ONE merge door for the workspace-template catalog.
|
|
445
|
+
* ====================================================================
|
|
446
|
+
*
|
|
447
|
+
* Both marketplace entry points (browser + CLI) and the pod need to show ONE
|
|
448
|
+
* list of installable workspace templates drawn from TWO sources:
|
|
449
|
+
*
|
|
450
|
+
* 1. BUNDLED — the canonical `@synap-core/workspace-templates` package that
|
|
451
|
+
* ships inside every client (this package). Always present, zero network.
|
|
452
|
+
* 2. REMOTE — rows in the control-plane package registry (`GET /api/packages`),
|
|
453
|
+
* which includes both the official templates re-published by
|
|
454
|
+
* `seed-templates.ts` AND private / third-party packages that never shipped
|
|
455
|
+
* in the bundle.
|
|
456
|
+
*
|
|
457
|
+
* The two overlap: every official template exists in BOTH sources (once bundled,
|
|
458
|
+
* once seeded to the CP). Naively concatenating them shows 21 duplicate cards.
|
|
459
|
+
* `mergeCatalog` de-dupes them into ONE catalog with a deterministic winner.
|
|
460
|
+
*
|
|
461
|
+
* WHY THIS LIVES HERE (and is PURE):
|
|
462
|
+
* This is the ONLY module the root `pnpm-workspace.yaml` lets `synap-cli`,
|
|
463
|
+
* `browser`, `synap-control-plane-api`, AND `synap-backend/packages/api` all
|
|
464
|
+
* resolve. `@synap-core/marketplace` pulls React and is `private: true`, so the
|
|
465
|
+
* Node CLI cannot import it. Keep this file pure data — no fetch, no auth, no
|
|
466
|
+
* React, no Node-only APIs. Each entry point has a DIFFERENT transport (browser
|
|
467
|
+
* cookie/`cpFetch`, CLI Bearer, pod anonymous); a door that fetched would force
|
|
468
|
+
* ONE auth model on all three and become the next lossy seam. Transport lives
|
|
469
|
+
* in the consumers; this door only merges arrays they already fetched.
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* A bundled template — the canonical `WorkspaceYaml` this package ships. Callers
|
|
474
|
+
* pass `listPublicTemplates()` (18) or `listWorkspaceTemplates()` (21); the door
|
|
475
|
+
* merges whatever it is given and does NOT filter (see the publicity note below).
|
|
476
|
+
*/
|
|
477
|
+
type BundledEntry = WorkspaceYaml;
|
|
478
|
+
/**
|
|
479
|
+
* A control-plane registry row, mapped into the minimal shape the door needs.
|
|
480
|
+
* Consumers build this from a `MarketplacePackage` (browser) / the CP
|
|
481
|
+
* `GET /api/packages` JSON (CLI) — a thin, transport-specific projection.
|
|
482
|
+
*
|
|
483
|
+
* `definition` is carried OPAQUE: it is both (a) the install payload the consumer
|
|
484
|
+
* feeds back to the pod, and (b) the home of the ONE comparable version signal,
|
|
485
|
+
* `definition.sourcePackage.version` — the real npm semver of the published
|
|
486
|
+
* `@synap-core/workspace-templates` build that generated an official row
|
|
487
|
+
* (`seed-templates.ts` stamps it). The door only reads that one nested field; the
|
|
488
|
+
* rest of `definition` is passed through untouched.
|
|
489
|
+
*/
|
|
490
|
+
interface RemoteEntry {
|
|
491
|
+
slug: string;
|
|
492
|
+
name: string;
|
|
493
|
+
description?: string;
|
|
494
|
+
/** CP package category / type (e.g. `"workspace"`, `"view"`). */
|
|
495
|
+
category?: string;
|
|
496
|
+
tags?: string[];
|
|
497
|
+
icon?: string | null;
|
|
498
|
+
/**
|
|
499
|
+
* `true` when the CP row is not publicly listed (`isPublic === false`). Browse
|
|
500
|
+
* rows leave this `undefined` BY CONSTRUCTION — the browse route hard-filters
|
|
501
|
+
* `WHERE is_public = true`, so every browse row is public; `undefined` ⇒ public,
|
|
502
|
+
* never "unknown-so-hide".
|
|
503
|
+
*/
|
|
504
|
+
isPrivate?: boolean;
|
|
505
|
+
/**
|
|
506
|
+
* The CP `definition` jsonb — opaque install payload. The door reads only
|
|
507
|
+
* `definition.sourcePackage.version` (the winner signal). Absent on browse rows
|
|
508
|
+
* (the list route strips `definition`), which is fine: absence ⇒ bundle wins.
|
|
509
|
+
*/
|
|
510
|
+
definition?: {
|
|
511
|
+
sourcePackage?: {
|
|
512
|
+
name?: string;
|
|
513
|
+
version?: string;
|
|
514
|
+
};
|
|
515
|
+
[k: string]: unknown;
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
/** Whether the caller could reach / authenticate against the remote source. */
|
|
519
|
+
type RemoteSourceStatus = "ok" | "unauthenticated" | "unreachable";
|
|
520
|
+
interface MergeCatalogInput {
|
|
521
|
+
/** Bundled templates (this package). Always "ok" — it is in-process data. */
|
|
522
|
+
bundled: BundledEntry[];
|
|
523
|
+
/** Already-fetched CP rows. Empty/omitted when the fetch failed. */
|
|
524
|
+
remote?: RemoteEntry[];
|
|
525
|
+
/**
|
|
526
|
+
* This client's bundled-package version (`package.json` `version`, live `0.6.0`).
|
|
527
|
+
* Compared against each remote row's `sourcePackage.version` to decide whether
|
|
528
|
+
* THIS client's bundle is stale. Callers pass the compiled-in package version.
|
|
529
|
+
*/
|
|
530
|
+
bundleVersion: string;
|
|
531
|
+
/**
|
|
532
|
+
* The transport's verdict on the remote fetch. `"ok"` (default) ⇒ merge the
|
|
533
|
+
* `remote` array. `"unauthenticated"` / `"unreachable"` ⇒ ignore `remote` and
|
|
534
|
+
* surface the degradation in `sources.remote`, so the consumer can render
|
|
535
|
+
* "18 available — private ones need login" instead of FAILING OPEN EMPTY.
|
|
536
|
+
*/
|
|
537
|
+
remoteStatus?: RemoteSourceStatus;
|
|
538
|
+
}
|
|
539
|
+
interface CatalogEntryBase {
|
|
540
|
+
slug: string;
|
|
541
|
+
name: string;
|
|
542
|
+
description?: string;
|
|
543
|
+
/** Package category / type. Bundled templates are always `"workspace"`. */
|
|
544
|
+
category?: string;
|
|
545
|
+
tags: string[];
|
|
546
|
+
icon?: string | null;
|
|
547
|
+
/** `true` ⇒ not publicly listed (internal bundled template, or private CP row). */
|
|
548
|
+
isPrivate: boolean;
|
|
549
|
+
}
|
|
550
|
+
/** A catalog entry backed by a bundled template. Install via `toWorkspaceDefinition()` / `toPackageDefinition()` on `template`. */
|
|
551
|
+
interface BundledCatalogEntry extends CatalogEntryBase {
|
|
552
|
+
source: "bundled";
|
|
553
|
+
template: WorkspaceYaml;
|
|
554
|
+
}
|
|
555
|
+
/** A catalog entry backed by a CP registry row. Install from `remote.definition`. */
|
|
556
|
+
interface RemoteCatalogEntry extends CatalogEntryBase {
|
|
557
|
+
source: "remote";
|
|
558
|
+
remote: RemoteEntry;
|
|
559
|
+
}
|
|
560
|
+
/** One merged card. `source` discriminates the install path; common fields feed a picker. */
|
|
561
|
+
type CatalogEntry = BundledCatalogEntry | RemoteCatalogEntry;
|
|
562
|
+
interface MergeCatalogResult {
|
|
563
|
+
entries: CatalogEntry[];
|
|
564
|
+
/**
|
|
565
|
+
* Per-source health. LOAD-BEARING, not decoration: it is what lets a consumer
|
|
566
|
+
* distinguish "remote returned nothing" from "remote unreachable" and avoid the
|
|
567
|
+
* FAILS-OPEN-EMPTY trap (agent sees empty catalog → thinks pod is empty → dupes).
|
|
568
|
+
*/
|
|
569
|
+
sources: {
|
|
570
|
+
bundled: "ok";
|
|
571
|
+
remote: RemoteSourceStatus;
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Merge bundled + remote template catalogs into ONE de-duplicated list.
|
|
576
|
+
*
|
|
577
|
+
* DEDUPE KEY = `slug` — NOT `slug@version`. This is forced by the live data, not
|
|
578
|
+
* a preference: every CP flagship row is hardcoded `version: "1.0.0"`
|
|
579
|
+
* (`seed-templates.ts`) and `TemplateMeta` carries NO version field at all, so a
|
|
580
|
+
* `slug@version` key would collide on nothing → 21 duplicate cards. The real
|
|
581
|
+
* per-build version lives only in `definition.sourcePackage.version`, which is
|
|
582
|
+
* the WINNER signal, never the identity key.
|
|
583
|
+
*
|
|
584
|
+
* CONFLICT RESOLUTION (remote slug already claimed by a bundled template):
|
|
585
|
+
* • remote `sourcePackage.version` strictly > `bundleVersion` → remote wins
|
|
586
|
+
* (this client is stale — the CP has a fresher official build).
|
|
587
|
+
* • otherwise (equal / older / no `sourcePackage`) → BUNDLE wins. The
|
|
588
|
+
* no-`sourcePackage` case is a third-party package SQUATTING an official slug;
|
|
589
|
+
* the bundle wins unconditionally (squatting defense).
|
|
590
|
+
*
|
|
591
|
+
* A remote slug that does NOT collide with any bundled template is a DISTINCT
|
|
592
|
+
* entry (a private or third-party package) and is always kept.
|
|
593
|
+
*/
|
|
594
|
+
declare function mergeCatalog(input: MergeCatalogInput): MergeCatalogResult;
|
|
595
|
+
|
|
390
596
|
/**
|
|
391
597
|
* @synap-core/workspace-templates — Definition adapter
|
|
392
598
|
*
|
|
@@ -399,6 +605,24 @@ declare function listPublicTemplates(): WorkspaceYaml[];
|
|
|
399
605
|
* shape never drifts per call-site.
|
|
400
606
|
*/
|
|
401
607
|
|
|
608
|
+
/** A widget block as the wire expects it: `bentoLayout[]`, keyed by `widgetType`. */
|
|
609
|
+
interface BentoWidgetBlockWire {
|
|
610
|
+
widgetType: string;
|
|
611
|
+
pos: TemplateBentoBlock['pos'];
|
|
612
|
+
config?: Record<string, unknown>;
|
|
613
|
+
}
|
|
614
|
+
/** A view block as the wire expects it: `bentoViewBlocks[]`, keyed by `viewName`. */
|
|
615
|
+
interface BentoViewBlockWire {
|
|
616
|
+
kind: 'view';
|
|
617
|
+
viewName: string;
|
|
618
|
+
pos: TemplateBentoBlock['pos'];
|
|
619
|
+
overrides?: Record<string, unknown>;
|
|
620
|
+
}
|
|
621
|
+
interface SplitBentoBlocks {
|
|
622
|
+
bentoLayout: BentoWidgetBlockWire[];
|
|
623
|
+
bentoViewBlocks: BentoViewBlockWire[];
|
|
624
|
+
}
|
|
625
|
+
declare function splitBentoBlocks(blocks: TemplateBentoBlock[] | undefined): SplitBentoBlocks;
|
|
402
626
|
/** The flat definition object accepted by createFromDefinition. */
|
|
403
627
|
interface WorkspaceDefinitionInput {
|
|
404
628
|
workspaceName: string;
|
|
@@ -412,7 +636,16 @@ interface WorkspaceDefinitionInput {
|
|
|
412
636
|
displayTemplates?: WorkspaceYaml['displayTemplates'];
|
|
413
637
|
layoutConfig: WorkspaceYaml['layout'] | undefined;
|
|
414
638
|
bentoViewName?: string;
|
|
415
|
-
|
|
639
|
+
/**
|
|
640
|
+
* WIDGET half of the authored bento union. The door declares this field
|
|
641
|
+
* (`workspaces.createFromDefinition` zod) and the pod maps it as widgets via
|
|
642
|
+
* `widget.widgetType`. It was missing from this interface entirely, which is
|
|
643
|
+
* why `toWorkspaceDefinition` had nowhere to put widgets and dumped the whole
|
|
644
|
+
* union into `bentoViewBlocks` — where every widget was silently filtered out.
|
|
645
|
+
*/
|
|
646
|
+
bentoLayout?: BentoWidgetBlockWire[];
|
|
647
|
+
/** VIEW half of the authored bento union — resolved against the viewMap. */
|
|
648
|
+
bentoViewBlocks?: BentoViewBlockWire[];
|
|
416
649
|
profileEntityBentoTemplates?: WorkspaceYaml['profileEntityBentoTemplates'];
|
|
417
650
|
workspaceSubtype?: string;
|
|
418
651
|
workspaceType?: NonNullable<WorkspaceYaml['workspace']>['workspaceType'];
|
|
@@ -477,7 +710,17 @@ interface PackageDefinitionOutput {
|
|
|
477
710
|
suggestedRelations?: WorkspaceYaml['suggestedRelations'];
|
|
478
711
|
displayTemplates?: WorkspaceYaml['displayTemplates'];
|
|
479
712
|
entityLinks?: WorkspaceYaml['entityLinks'];
|
|
480
|
-
|
|
713
|
+
/** WIDGET half of the authored bento union — mapped by the pod via `widgetType`. */
|
|
714
|
+
bentoLayout?: BentoWidgetBlockWire[];
|
|
715
|
+
/**
|
|
716
|
+
* VIEW half of the authored bento union. Widgets go to `bentoLayout`, views
|
|
717
|
+
* here — the pod splits by field (create-workspace-from-definition.ts:1373
|
|
718
|
+
* reads `bentoViewBlocks`), so both wire fields must be carried. The apply
|
|
719
|
+
* door's `PackageApplySchema` now declares this field (it is a plain
|
|
720
|
+
* `z.object`, so an undeclared field would be silently stripped) — the inbound
|
|
721
|
+
* seam is closed to match this outbound emit.
|
|
722
|
+
*/
|
|
723
|
+
bentoViewBlocks?: BentoViewBlockWire[];
|
|
481
724
|
bentoViewName?: string;
|
|
482
725
|
profileEntityBentoTemplates?: WorkspaceYaml['profileEntityBentoTemplates'];
|
|
483
726
|
layoutConfig?: WorkspaceYaml['layout'];
|
|
@@ -495,4 +738,4 @@ interface PackageDefinitionOutput {
|
|
|
495
738
|
*/
|
|
496
739
|
declare function toPackageDefinition(slugOrYaml: string | WorkspaceYaml): PackageDefinitionOutput;
|
|
497
740
|
|
|
498
|
-
export { type PackageDefinitionOutput, 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 TemplateView, type ToDefinitionResult, WORKSPACE_TEMPLATES, type WorkspaceDefinitionInput, type WorkspaceTemplateSlug, type WorkspaceYaml, getWorkspaceTemplate, listPublicTemplates, listWorkspaceTemplates, toPackageDefinition, toWorkspaceDefinition };
|
|
741
|
+
export { type BentoViewBlockWire, type BentoWidgetBlockWire, type BundledCatalogEntry, type BundledEntry, type CatalogEntry, type MergeCatalogInput, type MergeCatalogResult, PACKAGE_DEPENDENCY_KINDS, type PackageDefinitionOutput, type PackageDependencyKind, type RemoteCatalogEntry, type RemoteEntry, type RemoteSourceStatus, type SplitBentoBlocks, 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 TemplateView, type ToDefinitionResult, WORKSPACE_TEMPLATES, type WorkspaceDefinitionInput, type WorkspaceTemplateSlug, type WorkspaceYaml, getWorkspaceTemplate, listPublicTemplates, listWorkspaceTemplates, mergeCatalog, splitBentoBlocks, toPackageDefinition, toWorkspaceDefinition };
|