@40rty/ams-sdk 0.5.15 → 0.5.16

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.js CHANGED
@@ -475,6 +475,7 @@ __export(src_exports3, {
475
475
  projectCollection: () => projectCollection,
476
476
  projectProduct: () => projectProduct,
477
477
  prose: () => prose,
478
+ proseRuns: () => proseRuns,
478
479
  pruneFilterChips: () => pruneFilterChips,
479
480
  publishClientState: () => publishClientState,
480
481
  queueDiscountCode: () => queueDiscountCode,
@@ -2392,7 +2393,7 @@ function partsText(parts2) {
2392
2393
  var ModelTurnAskSchema = z14.object({
2393
2394
  kind: z14.enum(["choice", "open"]),
2394
2395
  parts: z14.array(PartSchema).min(1)
2395
- }).refine((ask) => partsText(ask.parts).trim().length > 0, { message: "the question reads as nothing" }).transform((ask) => {
2396
+ }).refine((ask) => partsText(ask.parts).trim().length > 0, { message: "the question reads as nothing" }).refine((ask) => /\?["'”’*)\s]*$/.test(partsText(ask.parts)), { message: "an ask is a question" }).transform((ask) => {
2396
2397
  const answers = ask.parts.filter((p) => typeof p !== "string").length;
2397
2398
  if (ask.kind === "choice" && answers >= MIN_CHOICE_ANSWERS && answers <= MAX_CHOICE_ANSWERS) return ask;
2398
2399
  if (ask.kind === "open" && answers === 0) return ask;
@@ -3482,6 +3483,7 @@ var WireCatalogEntrySchema = z24.object({
3482
3483
  examples: z24.array(z24.record(z24.unknown())).optional(),
3483
3484
  renderedBy: z24.string().optional(),
3484
3485
  alwaysInclude: z24.boolean().optional(),
3486
+ asks: z24.boolean().optional(),
3485
3487
  whenToUse: z24.string().optional(),
3486
3488
  dontUseWhen: z24.string().optional(),
3487
3489
  variants: z24.string().optional(),
@@ -8984,6 +8986,7 @@ __export(catalog_exports, {
8984
8986
  listRegisteredPlatforms: () => listRegisteredPlatforms,
8985
8987
  listRegisteredServices: () => listRegisteredServices,
8986
8988
  plain: () => plain,
8989
+ proseRuns: () => proseRuns,
8987
8990
  registerComponent: () => registerComponent,
8988
8991
  registerLibrary: () => registerLibrary,
8989
8992
  registerPlatformHydrators: () => registerPlatformHydrators,
@@ -9098,6 +9101,31 @@ function createAliasedRegistry(baseRegistry, aliases, getPackageComponent) {
9098
9101
 
9099
9102
  // src/catalog/render-inline.tsx
9100
9103
  import React35 from "react";
9104
+
9105
+ // src/catalog/prose-links.ts
9106
+ var LINK = /\[([^\]\n]+)\]\(([^)\s]+)\)/g;
9107
+ var PARTIAL_LINK = /\[([^\]\n]*)(?:\](?:\([^)\s]*)?)?$/;
9108
+ var SAFE_HREF = /^(https?:\/\/|\/(?!\/))/i;
9109
+ function proseRuns(text2) {
9110
+ const runs = [];
9111
+ let at = 0;
9112
+ for (const m of text2.matchAll(LINK)) {
9113
+ if (m.index > at) runs.push({ text: text2.slice(at, m.index), href: void 0 });
9114
+ runs.push({ text: m[1], href: SAFE_HREF.test(m[2]) ? m[2] : void 0 });
9115
+ at = m.index + m[0].length;
9116
+ }
9117
+ const rest = text2.slice(at);
9118
+ const partial = PARTIAL_LINK.exec(rest);
9119
+ if (partial === null) {
9120
+ if (rest.length > 0) runs.push({ text: rest, href: void 0 });
9121
+ return runs;
9122
+ }
9123
+ if (partial.index > 0) runs.push({ text: rest.slice(0, partial.index), href: void 0 });
9124
+ if (partial[1].length > 0) runs.push({ text: partial[1], href: void 0 });
9125
+ return runs;
9126
+ }
9127
+
9128
+ // src/catalog/render-inline.tsx
9101
9129
  import { jsx as jsx21 } from "react/jsx-runtime";
9102
9130
  var linkRenderer = (href, key) => /* @__PURE__ */ jsx21(
9103
9131
  "a",
@@ -9112,6 +9140,14 @@ var linkRenderer = (href, key) => /* @__PURE__ */ jsx21(
9112
9140
  );
9113
9141
  var URL_RE = /https?:\/\/[^\s<>()]+[^\s<>().,:;!?'"]/g;
9114
9142
  function linkifyText(text2, keyPrefix) {
9143
+ return proseRuns(text2).flatMap((run, r) => {
9144
+ if (run.href === void 0) return linkifyBareUrls(run.text, `${keyPrefix}-${String(r)}`);
9145
+ return [
9146
+ /* @__PURE__ */ jsx21("a", { className: "fourty-inline-link", href: run.href, target: "_blank", rel: "noopener noreferrer", children: run.text }, `${keyPrefix}-${String(r)}-ll`)
9147
+ ];
9148
+ });
9149
+ }
9150
+ function linkifyBareUrls(text2, keyPrefix) {
9115
9151
  const out = [];
9116
9152
  let last = 0;
9117
9153
  let match;
@@ -12840,7 +12876,7 @@ function useContentActions() {
12840
12876
  import { useEffect as useEffect19, useState as useState19 } from "react";
12841
12877
 
12842
12878
  // package.json
12843
- var version = "0.5.15";
12879
+ var version = "0.5.16";
12844
12880
 
12845
12881
  // src/host/host-modules.ts
12846
12882
  import * as react from "react";
@@ -13398,6 +13434,7 @@ export {
13398
13434
  projectCollection,
13399
13435
  projectProduct,
13400
13436
  prose,
13437
+ proseRuns,
13401
13438
  pruneFilterChips,
13402
13439
  publishClientState,
13403
13440
  queueDiscountCode,
@@ -5,6 +5,7 @@ export { HydratorProvider, useHydrators } from './HydratorContext';
5
5
  export type { ComponentMapping, ComponentsMap, Hydrator, HydratorMap, HydrationContext, } from './normalize-components';
6
6
  export { RegistryProvider, useRegistry, PackageLookupProvider, usePackageLookup, createAliasedRegistry, type ComponentRegistry, type PackageLookupFn, } from './registry';
7
7
  export { renderInline } from './render-inline';
8
+ export { proseRuns, type ProseRun } from './prose-links';
8
9
  export { adaptComponent, NullComponent, buildComponentLibrary, type BrandComponent } from './component-library';
9
10
  export { catalogComponent, catalogComponentFrom, entity, text, plain, token, type CatalogComponent, type CatalogComponentMeta, } from './define';
10
11
  export { adaptCatalogComponent, type CatalogComponentProps, type ValidCatalogComponent, type InteractionContractViolation, } from './interaction-contract';
@@ -0,0 +1,12 @@
1
+ /** A stretch of prose: plain, or the label of a `[label](url)` link. */
2
+ export interface ProseRun {
3
+ text: string;
4
+ /** Set on a link's label. A link to anything but a web page or a site path stays plain text. */
5
+ href: string | undefined;
6
+ }
7
+ /**
8
+ * The prose split into plain runs and link labels. The visitor reads the
9
+ * label, never the URL — also while the link is still streaming in, so a
10
+ * half-written `[our contact form](https://…` shows only "our contact form".
11
+ */
12
+ export declare function proseRuns(text: string): ProseRun[];
@@ -244,6 +244,7 @@ export declare const HOST_MODULES: {
244
244
  usePackageLookup: typeof sdk.usePackageLookup;
245
245
  createAliasedRegistry: typeof sdk.createAliasedRegistry;
246
246
  renderInline: typeof sdk.renderInline;
247
+ proseRuns: typeof sdk.proseRuns;
247
248
  adaptComponent: typeof sdk.adaptComponent;
248
249
  NullComponent: sdk.BrandComponent;
249
250
  buildComponentLibrary: typeof sdk.buildComponentLibrary;
@@ -1166,7 +1167,7 @@ export declare const HOST_MODULES: {
1166
1167
  CHIP_SHOW_SIGNAL: "chip.show";
1167
1168
  chipsFromShowSignal: typeof spacestation.chipsFromShowSignal;
1168
1169
  TURN_ASK_SIGNAL: "turn.ask";
1169
- TurnAskSchema: zod.ZodUnion<[zod.ZodEffects<zod.ZodEffects<zod.ZodObject<{
1170
+ TurnAskSchema: zod.ZodUnion<[zod.ZodEffects<zod.ZodEffects<zod.ZodEffects<zod.ZodObject<{
1170
1171
  kind: zod.ZodEnum<["choice", "open"]>;
1171
1172
  parts: zod.ZodArray<zod.ZodUnion<[zod.ZodString, zod.ZodObject<{
1172
1173
  answer: zod.ZodString;
@@ -1195,6 +1196,16 @@ export declare const HOST_MODULES: {
1195
1196
  parts: (string | {
1196
1197
  answer: string;
1197
1198
  })[];
1199
+ }>, {
1200
+ kind: "choice" | "open";
1201
+ parts: (string | {
1202
+ answer: string;
1203
+ })[];
1204
+ }, {
1205
+ kind: "choice" | "open";
1206
+ parts: (string | {
1207
+ answer: string;
1208
+ })[];
1198
1209
  }>, spacestation.TurnAsk, {
1199
1210
  kind: "choice" | "open";
1200
1211
  parts: (string | {
@@ -1264,6 +1275,7 @@ export declare const HOST_MODULES: {
1264
1275
  examples: zod.ZodOptional<zod.ZodArray<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>, "many">>;
1265
1276
  renderedBy: zod.ZodOptional<zod.ZodString>;
1266
1277
  alwaysInclude: zod.ZodOptional<zod.ZodBoolean>;
1278
+ asks: zod.ZodOptional<zod.ZodBoolean>;
1267
1279
  whenToUse: zod.ZodOptional<zod.ZodString>;
1268
1280
  dontUseWhen: zod.ZodOptional<zod.ZodString>;
1269
1281
  variants: zod.ZodOptional<zod.ZodString>;
@@ -1308,6 +1320,7 @@ export declare const HOST_MODULES: {
1308
1320
  examples?: Record<string, unknown>[] | undefined;
1309
1321
  renderedBy?: string | undefined;
1310
1322
  alwaysInclude?: boolean | undefined;
1323
+ asks?: boolean | undefined;
1311
1324
  whenToUse?: string | undefined;
1312
1325
  dontUseWhen?: string | undefined;
1313
1326
  variants?: string | undefined;
@@ -1334,6 +1347,7 @@ export declare const HOST_MODULES: {
1334
1347
  examples?: Record<string, unknown>[] | undefined;
1335
1348
  renderedBy?: string | undefined;
1336
1349
  alwaysInclude?: boolean | undefined;
1350
+ asks?: boolean | undefined;
1337
1351
  whenToUse?: string | undefined;
1338
1352
  dontUseWhen?: string | undefined;
1339
1353
  variants?: string | undefined;
@@ -1353,6 +1367,7 @@ export declare const HOST_MODULES: {
1353
1367
  examples: zod.ZodOptional<zod.ZodArray<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>, "many">>;
1354
1368
  renderedBy: zod.ZodOptional<zod.ZodString>;
1355
1369
  alwaysInclude: zod.ZodOptional<zod.ZodBoolean>;
1370
+ asks: zod.ZodOptional<zod.ZodBoolean>;
1356
1371
  whenToUse: zod.ZodOptional<zod.ZodString>;
1357
1372
  dontUseWhen: zod.ZodOptional<zod.ZodString>;
1358
1373
  variants: zod.ZodOptional<zod.ZodString>;
@@ -1397,6 +1412,7 @@ export declare const HOST_MODULES: {
1397
1412
  examples?: Record<string, unknown>[] | undefined;
1398
1413
  renderedBy?: string | undefined;
1399
1414
  alwaysInclude?: boolean | undefined;
1415
+ asks?: boolean | undefined;
1400
1416
  whenToUse?: string | undefined;
1401
1417
  dontUseWhen?: string | undefined;
1402
1418
  variants?: string | undefined;
@@ -1423,6 +1439,7 @@ export declare const HOST_MODULES: {
1423
1439
  examples?: Record<string, unknown>[] | undefined;
1424
1440
  renderedBy?: string | undefined;
1425
1441
  alwaysInclude?: boolean | undefined;
1442
+ asks?: boolean | undefined;
1426
1443
  whenToUse?: string | undefined;
1427
1444
  dontUseWhen?: string | undefined;
1428
1445
  variants?: string | undefined;
@@ -1454,6 +1471,7 @@ export declare const HOST_MODULES: {
1454
1471
  examples: zod.ZodOptional<zod.ZodArray<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>, "many">>;
1455
1472
  renderedBy: zod.ZodOptional<zod.ZodString>;
1456
1473
  alwaysInclude: zod.ZodOptional<zod.ZodBoolean>;
1474
+ asks: zod.ZodOptional<zod.ZodBoolean>;
1457
1475
  whenToUse: zod.ZodOptional<zod.ZodString>;
1458
1476
  dontUseWhen: zod.ZodOptional<zod.ZodString>;
1459
1477
  variants: zod.ZodOptional<zod.ZodString>;
@@ -1498,6 +1516,7 @@ export declare const HOST_MODULES: {
1498
1516
  examples?: Record<string, unknown>[] | undefined;
1499
1517
  renderedBy?: string | undefined;
1500
1518
  alwaysInclude?: boolean | undefined;
1519
+ asks?: boolean | undefined;
1501
1520
  whenToUse?: string | undefined;
1502
1521
  dontUseWhen?: string | undefined;
1503
1522
  variants?: string | undefined;
@@ -1524,6 +1543,7 @@ export declare const HOST_MODULES: {
1524
1543
  examples?: Record<string, unknown>[] | undefined;
1525
1544
  renderedBy?: string | undefined;
1526
1545
  alwaysInclude?: boolean | undefined;
1546
+ asks?: boolean | undefined;
1527
1547
  whenToUse?: string | undefined;
1528
1548
  dontUseWhen?: string | undefined;
1529
1549
  variants?: string | undefined;
@@ -1750,6 +1770,7 @@ export declare const HOST_MODULES: {
1750
1770
  examples?: Record<string, unknown>[] | undefined;
1751
1771
  renderedBy?: string | undefined;
1752
1772
  alwaysInclude?: boolean | undefined;
1773
+ asks?: boolean | undefined;
1753
1774
  whenToUse?: string | undefined;
1754
1775
  dontUseWhen?: string | undefined;
1755
1776
  variants?: string | undefined;
@@ -1833,6 +1854,7 @@ export declare const HOST_MODULES: {
1833
1854
  examples?: Record<string, unknown>[] | undefined;
1834
1855
  renderedBy?: string | undefined;
1835
1856
  alwaysInclude?: boolean | undefined;
1857
+ asks?: boolean | undefined;
1836
1858
  whenToUse?: string | undefined;
1837
1859
  dontUseWhen?: string | undefined;
1838
1860
  variants?: string | undefined;
@@ -34,6 +34,11 @@ export interface CatalogEntryStructural {
34
34
  renderedBy?: string;
35
35
  /** If true, always included in catalog prompt even when not in component hints (layout primitives). */
36
36
  alwaysInclude?: boolean;
37
+ /** The component ASKS the visitor something (a quiz, an interview card):
38
+ * once one has been on the canvas, no later turn may introduce another
39
+ * (`@fourty/agent` `layout/spent-ask-guard.ts`). Set from the manifest's
40
+ * `asks: true` frontmatter by `applyManifests`. */
41
+ asks?: boolean;
37
42
  /** When the LLM should select this component. */
38
43
  whenToUse?: string;
39
44
  /** When NOT to use this component. */
@@ -11,6 +11,7 @@ export declare const WireCatalogEntrySchema: z.ZodObject<{
11
11
  examples: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
12
12
  renderedBy: z.ZodOptional<z.ZodString>;
13
13
  alwaysInclude: z.ZodOptional<z.ZodBoolean>;
14
+ asks: z.ZodOptional<z.ZodBoolean>;
14
15
  whenToUse: z.ZodOptional<z.ZodString>;
15
16
  dontUseWhen: z.ZodOptional<z.ZodString>;
16
17
  variants: z.ZodOptional<z.ZodString>;
@@ -55,6 +56,7 @@ export declare const WireCatalogEntrySchema: z.ZodObject<{
55
56
  examples?: Record<string, unknown>[] | undefined;
56
57
  renderedBy?: string | undefined;
57
58
  alwaysInclude?: boolean | undefined;
59
+ asks?: boolean | undefined;
58
60
  whenToUse?: string | undefined;
59
61
  dontUseWhen?: string | undefined;
60
62
  variants?: string | undefined;
@@ -81,6 +83,7 @@ export declare const WireCatalogEntrySchema: z.ZodObject<{
81
83
  examples?: Record<string, unknown>[] | undefined;
82
84
  renderedBy?: string | undefined;
83
85
  alwaysInclude?: boolean | undefined;
86
+ asks?: boolean | undefined;
84
87
  whenToUse?: string | undefined;
85
88
  dontUseWhen?: string | undefined;
86
89
  variants?: string | undefined;
@@ -101,6 +104,7 @@ export declare const WireCatalogSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
101
104
  examples: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
102
105
  renderedBy: z.ZodOptional<z.ZodString>;
103
106
  alwaysInclude: z.ZodOptional<z.ZodBoolean>;
107
+ asks: z.ZodOptional<z.ZodBoolean>;
104
108
  whenToUse: z.ZodOptional<z.ZodString>;
105
109
  dontUseWhen: z.ZodOptional<z.ZodString>;
106
110
  variants: z.ZodOptional<z.ZodString>;
@@ -145,6 +149,7 @@ export declare const WireCatalogSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
145
149
  examples?: Record<string, unknown>[] | undefined;
146
150
  renderedBy?: string | undefined;
147
151
  alwaysInclude?: boolean | undefined;
152
+ asks?: boolean | undefined;
148
153
  whenToUse?: string | undefined;
149
154
  dontUseWhen?: string | undefined;
150
155
  variants?: string | undefined;
@@ -171,6 +176,7 @@ export declare const WireCatalogSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
171
176
  examples?: Record<string, unknown>[] | undefined;
172
177
  renderedBy?: string | undefined;
173
178
  alwaysInclude?: boolean | undefined;
179
+ asks?: boolean | undefined;
174
180
  whenToUse?: string | undefined;
175
181
  dontUseWhen?: string | undefined;
176
182
  variants?: string | undefined;
@@ -48,6 +48,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
48
48
  examples: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
49
49
  renderedBy: z.ZodOptional<z.ZodString>;
50
50
  alwaysInclude: z.ZodOptional<z.ZodBoolean>;
51
+ asks: z.ZodOptional<z.ZodBoolean>;
51
52
  whenToUse: z.ZodOptional<z.ZodString>;
52
53
  dontUseWhen: z.ZodOptional<z.ZodString>;
53
54
  variants: z.ZodOptional<z.ZodString>;
@@ -92,6 +93,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
92
93
  examples?: Record<string, unknown>[] | undefined;
93
94
  renderedBy?: string | undefined;
94
95
  alwaysInclude?: boolean | undefined;
96
+ asks?: boolean | undefined;
95
97
  whenToUse?: string | undefined;
96
98
  dontUseWhen?: string | undefined;
97
99
  variants?: string | undefined;
@@ -118,6 +120,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
118
120
  examples?: Record<string, unknown>[] | undefined;
119
121
  renderedBy?: string | undefined;
120
122
  alwaysInclude?: boolean | undefined;
123
+ asks?: boolean | undefined;
121
124
  whenToUse?: string | undefined;
122
125
  dontUseWhen?: string | undefined;
123
126
  variants?: string | undefined;
@@ -383,6 +386,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
383
386
  examples?: Record<string, unknown>[] | undefined;
384
387
  renderedBy?: string | undefined;
385
388
  alwaysInclude?: boolean | undefined;
389
+ asks?: boolean | undefined;
386
390
  whenToUse?: string | undefined;
387
391
  dontUseWhen?: string | undefined;
388
392
  variants?: string | undefined;
@@ -466,6 +470,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
466
470
  examples?: Record<string, unknown>[] | undefined;
467
471
  renderedBy?: string | undefined;
468
472
  alwaysInclude?: boolean | undefined;
473
+ asks?: boolean | undefined;
469
474
  whenToUse?: string | undefined;
470
475
  dontUseWhen?: string | undefined;
471
476
  variants?: string | undefined;
@@ -33,7 +33,7 @@ export interface TurnAsk {
33
33
  kind: 'choice' | 'open';
34
34
  parts: TurnAskPart[];
35
35
  }
36
- export declare const TurnAskSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodObject<{
36
+ export declare const TurnAskSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
37
37
  kind: z.ZodEnum<["choice", "open"]>;
38
38
  parts: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
39
39
  answer: z.ZodString;
@@ -62,6 +62,16 @@ export declare const TurnAskSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodO
62
62
  parts: (string | {
63
63
  answer: string;
64
64
  })[];
65
+ }>, {
66
+ kind: "choice" | "open";
67
+ parts: (string | {
68
+ answer: string;
69
+ })[];
70
+ }, {
71
+ kind: "choice" | "open";
72
+ parts: (string | {
73
+ answer: string;
74
+ })[];
65
75
  }>, TurnAsk, {
66
76
  kind: "choice" | "open";
67
77
  parts: (string | {
@@ -215,6 +215,16 @@ export type TraceDiagnostic = {
215
215
  rootKey: string;
216
216
  maxSections: number;
217
217
  dropped: string[];
218
+ }
219
+ /** The turn wrote a NEW element of an `asks` type (a quiz, an interview
220
+ * card) the visitor already met this session. Dropped pre-wire by the
221
+ * asks-once guard (`layout/spent-ask-guard.ts`); the visitor never saw it.
222
+ * A model fault — the per-turn `context/spent-asks` line told it not to. */
223
+ | {
224
+ kind: 'spent_ask_component_dropped';
225
+ stage: 'layout_generation';
226
+ element: string;
227
+ elementType: string;
218
228
  } | {
219
229
  kind: 'render_sanitized';
220
230
  stage: 'layout_generation';
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "react": "^18.3.0 || ^19.0.0",
27
27
  "react-dom": "^18.3.0 || ^19.0.0"
28
28
  },
29
- "version": "0.5.15",
29
+ "version": "0.5.16",
30
30
  "homepage": "https://docs.40rty.ai",
31
31
  "license": "UNLICENSED",
32
32
  "engines": {