@synap-core/workspace-templates 0.9.4 → 0.10.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
@@ -138,6 +138,28 @@ interface TemplateEntityLink {
138
138
  type: string;
139
139
  label?: string;
140
140
  }
141
+ /**
142
+ * A domain-level relation TYPE definition — a `relation_defs` row, the workspace's
143
+ * relation vocabulary. Distinct from {@link TemplateEntityLink}, which is a
144
+ * profile→profile EDGE (and only carries `type` + `label`). A relation def stands
145
+ * alone: it has no source/target profile pairing and it carries the rich metadata
146
+ * (`description`, `isDirectional`, `uiHints`) that the entity-link path drops.
147
+ *
148
+ * Mirrors `DefaultRelationDef` in synap-backend
149
+ * `packages/database/src/utils/default-relation-defs.ts` VERBATIM — the door
150
+ * find-or-creates a `relation_defs` row from each entry (idempotent by
151
+ * `slug` within the workspace), which is `ensureDefaultRelationDefs`'s body.
152
+ */
153
+ interface TemplateRelationDef {
154
+ slug: string;
155
+ displayName: string;
156
+ description?: string;
157
+ isDirectional?: boolean;
158
+ uiHints?: {
159
+ category?: "workflow" | "social" | "reference" | "hierarchy";
160
+ inverseLabel?: string;
161
+ };
162
+ }
141
163
  interface TemplateSeedEntity {
142
164
  profileSlug: string;
143
165
  title: string;
@@ -352,6 +374,22 @@ interface TemplateAutomation {
352
374
  };
353
375
  status?: "draft" | "active" | "paused";
354
376
  }
377
+ interface TemplateCommandDerivedInput {
378
+ name: string;
379
+ label?: string;
380
+ /** Mirrors `DerivedInput.type` (text | number | entity | view | choice). */
381
+ type?: string;
382
+ }
383
+ interface TemplateCommand {
384
+ title: string;
385
+ promptTemplate: string;
386
+ derivedInputs?: TemplateCommandDerivedInput[];
387
+ /** text | proposal | view */
388
+ outputMode?: string;
389
+ canCreateViews?: boolean;
390
+ /** read_only | propose_writes */
391
+ permissionsProfile?: string;
392
+ }
355
393
  interface TemplateActionPlacement {
356
394
  /** Entity kind whose detail surface this action appears on. */
357
395
  profileSlug: string;
@@ -537,6 +575,19 @@ interface WorkspaceYaml {
537
575
  views?: TemplateView[];
538
576
  /** Schema-level links between entity types */
539
577
  entityLinks?: TemplateEntityLink[];
578
+ /**
579
+ * Domain-level relation TYPE vocabulary seeded into the workspace's
580
+ * `relation_defs`. Distinct from `entityLinks` (profile→profile edges): a
581
+ * relation def stands alone and carries `description`/`isDirectional`/`uiHints`.
582
+ * The `base` template carries the universal defaults. See {@link TemplateRelationDef}.
583
+ */
584
+ relationDefs?: TemplateRelationDef[];
585
+ /**
586
+ * Workspace-scoped intelligence commands (prompt-template "Default Command
587
+ * Pack") seeded with the workspace. The `base` template carries the universal
588
+ * pack. See {@link TemplateCommand}.
589
+ */
590
+ commands?: TemplateCommand[];
540
591
  /** Initial data to seed on workspace creation */
541
592
  seedEntities?: TemplateSeedEntity[];
542
593
  /** Relations between seed entities, created on provisioning */
@@ -977,9 +1028,11 @@ declare function layerTemplateGraph(input: LayerTemplateGraphInput): Composition
977
1028
  * Cross-template CONCEPT guard — catches vocabulary forks between templates.
978
1029
  *
979
1030
  * WHY THIS EXISTS (read before weakening or deleting it):
980
- * `business-developer.yaml` introduced workspace-scoped `crm-lead`/`crm-client`
981
- * for the same real-world concept that `foundation.yaml`/`crm.yaml` declare as
982
- * pod-wide shared `lead`/`client`. Nothing failed. Three reasons:
1031
+ * `business-developer.yaml` once introduced workspace-scoped
1032
+ * `crm-lead`/`crm-client` for the same real-world concept that
1033
+ * `foundation.yaml`/`crm.yaml` declare as pod-wide shared `lead`/`client` (that
1034
+ * fork has since been collapsed back onto the shared slugs). Nothing failed at
1035
+ * the time. Three reasons:
983
1036
  *
984
1037
  * 1. `build.mjs`'s `validate()` runs PER FILE, inside the read loop, so it
985
1038
  * structurally cannot see that another template already owns `lead`.
@@ -1017,6 +1070,13 @@ interface ConceptViolation {
1017
1070
  * list cannot rot into a graveyard.
1018
1071
  *
1019
1072
  * Key = the two colliding profile slugs, sorted, joined by "|".
1073
+ *
1074
+ * Currently EMPTY, and that is the healthy state. The two entries this list was
1075
+ * born for — `crm-lead|lead` and `client|crm-client` — were RESOLVED rather
1076
+ * than kept: business-developer.yaml now re-declares the shared `lead`/`client`
1077
+ * roles and carries its business-development fields as workspace-overlay
1078
+ * PROPERTIES. One concept, one slug, workspace-specific fields. Rule 3 below
1079
+ * would have failed CI had the entries been left behind.
1020
1080
  */
1021
1081
  declare const DECLARED_DIVERGENCES: Record<string, string>;
1022
1082
  /**
@@ -1029,7 +1089,14 @@ declare const DECLARED_DIVERGENCES: Record<string, string>;
1029
1089
  * is honest: no guard can know they mean the same thing.
1030
1090
  */
1031
1091
  declare function conceptTerm(semanticSlug: string): string;
1032
- declare function findConceptViolations(templates?: Record<string, WorkspaceYaml>): ConceptViolation[];
1092
+ declare function findConceptViolations(templates?: Record<string, WorkspaceYaml>,
1093
+ /**
1094
+ * The declared-divergence allowlist to enforce against. Defaults to the real
1095
+ * one; injectable so the escape-hatch semantics (rule 1 suppression, rule 3
1096
+ * staleness) stay testable now that the shipped list is empty — previously
1097
+ * those tests could only be written because a live entry happened to exist.
1098
+ */
1099
+ declaredDivergences?: Record<string, string>): ConceptViolation[];
1033
1100
  declare function formatConceptViolations(violations: ConceptViolation[]): string;
1034
1101
 
1035
1102
  /**
@@ -1262,18 +1329,18 @@ declare function validateTemplate(tpl: WorkspaceYaml, opts?: ValidateOptions): V
1262
1329
  * Until then: keep the constant arrays below identical to `@synap/database`
1263
1330
  * `schema/automations.ts`.
1264
1331
  */
1265
- /** The 21 node types — `AutomationNodeBase.type` union (schema/automations.ts). */
1266
- declare const FLOW_NODE_TYPES: readonly ["trigger", "command", "condition", "delay", "output", "loop", "transform", "fetch", "query", "entity_read", "related_entities", "guard", "compute", "select", "claim", "messages_query", "switch", "skill", "capability", "sub_automation", "playbook_run"];
1332
+ /** The 23 node types — `AutomationNodeBase.type` union (schema/automations.ts). */
1333
+ declare const FLOW_NODE_TYPES: readonly ["trigger", "command", "condition", "delay", "output", "loop", "transform", "fetch", "query", "entity_read", "related_entities", "guard", "compute", "select", "claim", "messages_query", "runs_query", "proposals_query", "switch", "skill", "capability", "sub_automation", "playbook_run"];
1267
1334
  /** The 11 output types — `OutputNodeDef.data.outputType` (schema/automations.ts). */
1268
1335
  declare const FLOW_OUTPUT_TYPES: readonly ["notification", "entity_create", "entity_update", "facet_attach", "facet_update", "facet_detach", "relation_create", "webhook", "channel_message", "session_update", "set_state"];
1269
1336
  /**
1270
1337
  * The known `config.channelType` values for a `channel_message` output. Mirrors
1271
1338
  * the executor's channel_message resolution (automation-executor.ts). The output
1272
- * channel is CONTEXT-DERIVED — a channel_message is valid with `channelId`, OR
1273
- * `channelEntityRef` (an entity-id expression → that entity's internal channel),
1274
- * OR a `channelType` from this set, OR NOTHING (the executor defaults a targetless
1275
- * channel_message to the automation's own run channel). A `channelType` that is
1276
- * PRESENT but not one of these is still a typo → still an error.
1339
+ * channel is now CONTEXT-DERIVED — a channel_message is valid with `channelId`,
1340
+ * OR `channelEntityRef` (an entity-id expression → that entity's internal
1341
+ * channel), OR a `channelType` from this set, OR NOTHING (the executor defaults a
1342
+ * targetless channel_message to the automation's own run channel). A `channelType`
1343
+ * that is PRESENT but not one of these is still a typo → still an error.
1277
1344
  */
1278
1345
  declare const CHANNEL_MESSAGE_CHANNEL_TYPES: readonly ["personal_thread", "proactive", "subjectEntity"];
1279
1346
  interface FlowValidationError {
@@ -1390,6 +1457,19 @@ interface WorkspaceDefinitionInput {
1390
1457
  seedEntities: NonNullable<WorkspaceYaml['seedEntities']>;
1391
1458
  suggestedRelations?: WorkspaceYaml['suggestedRelations'];
1392
1459
  displayTemplates?: WorkspaceYaml['displayTemplates'];
1460
+ /**
1461
+ * Domain-level relation TYPE vocabulary — the door find-or-creates a
1462
+ * `relation_defs` row per entry (idempotent by slug within the workspace). NOT
1463
+ * `entityLinks` (those are profile→profile edges and drop the rich metadata).
1464
+ * Carried verbatim; the authored form IS the wire form.
1465
+ */
1466
+ relationDefs?: WorkspaceYaml['relationDefs'];
1467
+ /**
1468
+ * Workspace intelligence commands — the door find-or-creates an
1469
+ * `intelligence_commands` row per entry (idempotent by title). Carried
1470
+ * verbatim; the authored form IS the wire form.
1471
+ */
1472
+ commands?: WorkspaceYaml['commands'];
1393
1473
  layoutConfig: WorkspaceYaml['layout'] | undefined;
1394
1474
  bentoViewName?: string;
1395
1475
  /**
@@ -1494,6 +1574,10 @@ interface PackageDefinitionOutput {
1494
1574
  suggestedRelations?: WorkspaceYaml['suggestedRelations'];
1495
1575
  displayTemplates?: WorkspaceYaml['displayTemplates'];
1496
1576
  entityLinks?: WorkspaceYaml['entityLinks'];
1577
+ /** Relation-type vocabulary — carried verbatim (authored form IS the wire form). */
1578
+ relationDefs?: WorkspaceYaml['relationDefs'];
1579
+ /** Intelligence commands — carried verbatim (authored form IS the wire form). */
1580
+ commands?: WorkspaceYaml['commands'];
1497
1581
  /** WIDGET half of the authored bento union — mapped by the pod via `widgetType`. */
1498
1582
  bentoLayout?: BentoWidgetBlockWire[];
1499
1583
  /**