@40rty/ams-sdk 0.5.0 → 0.5.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.
@@ -1390,6 +1390,7 @@ export declare const HOST_MODULES: {
1390
1390
  label: zod.ZodString;
1391
1391
  version: zod.ZodString;
1392
1392
  description: zod.ZodOptional<zod.ZodString>;
1393
+ builtWithSdk: zod.ZodOptional<zod.ZodString>;
1393
1394
  catalog: zod.ZodRecord<zod.ZodString, zod.ZodObject<{
1394
1395
  type: zod.ZodString;
1395
1396
  propsSchema: zod.ZodOptional<zod.ZodType<spacestation.WireSchema, zod.ZodTypeDef, spacestation.WireSchema>>;
@@ -1707,6 +1708,7 @@ export declare const HOST_MODULES: {
1707
1708
  manifests: Record<string, string>;
1708
1709
  config?: Record<string, unknown> | undefined;
1709
1710
  description?: string | undefined;
1711
+ builtWithSdk?: string | undefined;
1710
1712
  bundle?: {
1711
1713
  js: string;
1712
1714
  css: string;
@@ -1787,6 +1789,7 @@ export declare const HOST_MODULES: {
1787
1789
  manifests: Record<string, string>;
1788
1790
  config?: Record<string, unknown> | undefined;
1789
1791
  description?: string | undefined;
1792
+ builtWithSdk?: string | undefined;
1790
1793
  bundle?: {
1791
1794
  js: string;
1792
1795
  css: string;
@@ -1838,6 +1841,39 @@ export declare const HOST_MODULES: {
1838
1841
  isDraftSource: typeof spacestation.isDraftSource;
1839
1842
  releasePreviewSourceId: typeof spacestation.releasePreviewSourceId;
1840
1843
  parseReleasePreview: typeof spacestation.parseReleasePreview;
1844
+ SDK_VERSION_PATTERN: RegExp;
1845
+ SdkVersionSchema: zod.ZodString;
1846
+ OLDEST_SUPPORTED_SDK: "0.3.0";
1847
+ SDK_SHIMS: {
1848
+ readonly legacyCanvasActions: {
1849
+ readonly below: "0.4.0";
1850
+ };
1851
+ };
1852
+ compareSdkVersions: typeof spacestation.compareSdkVersions;
1853
+ sdkShimsFor: typeof spacestation.sdkShimsFor;
1854
+ sdkWindowProblem: typeof spacestation.sdkWindowProblem;
1855
+ PackageBundleRefSchema: zod.ZodObject<{
1856
+ sourceId: zod.ZodString;
1857
+ js: zod.ZodString;
1858
+ css: zod.ZodString;
1859
+ label: zod.ZodString;
1860
+ version: zod.ZodString;
1861
+ builtWithSdk: zod.ZodOptional<zod.ZodString>;
1862
+ }, "strip", zod.ZodTypeAny, {
1863
+ label: string;
1864
+ sourceId: string;
1865
+ version: string;
1866
+ js: string;
1867
+ css: string;
1868
+ builtWithSdk?: string | undefined;
1869
+ }, {
1870
+ label: string;
1871
+ sourceId: string;
1872
+ version: string;
1873
+ js: string;
1874
+ css: string;
1875
+ builtWithSdk?: string | undefined;
1876
+ }>;
1841
1877
  BRAND_MARK_TYPES: readonly ["svg", "png"];
1842
1878
  BRAND_MARK_SLOTS: readonly ["square", "wordmark"];
1843
1879
  BRAND_MARK_MAX_BYTES: number;
@@ -2359,6 +2395,11 @@ export declare const HOST_MODULES: {
2359
2395
  REFERRER_HOST_PARAM: "referrer_host";
2360
2396
  arrivalFromParams: typeof spacestation.arrivalFromParams;
2361
2397
  arrivalToParams: typeof spacestation.arrivalToParams;
2398
+ SOCKET_TICKET_PARAM: "ticket";
2399
+ WIRE_PROTOCOL_VERSION: 1;
2400
+ MIN_WIRE_PROTOCOL_VERSION: 1;
2401
+ WIRE_PROTOCOL_PARAM: "protocol";
2402
+ WIRE_PROTOCOL_UNSUPPORTED_CLOSE: 4426;
2362
2403
  AttributeDefSchema: zod.ZodType<spacestation.AttributeDef, zod.ZodTypeDef, spacestation.AttributeDef>;
2363
2404
  AttributeScopeBucketSchema: zod.ZodObject<{
2364
2405
  scope: zod.ZodString;
@@ -5,7 +5,9 @@
5
5
  * Transport: upload-on-attach → reference. The bytes are uploaded to storage
6
6
  * the moment the visitor attaches the file; only this lightweight `AttachmentRef`
7
7
  * rides the `prompt` signal, so send-time / TTFT stays clean. The agent resolves
8
- * the bytes at turn start and inlines them as image/file parts.
8
+ * the bytes at turn start BY `id`, from storage under its own session, and
9
+ * inlines them as image/file parts. It never fetches `url`: that came from the
10
+ * visitor, and fetching it made the server an SSRF proxy.
9
11
  *
10
12
  * One home for the allow-list: both the composer (accept attribute + client
11
13
  * pre-check), the upload endpoint (server validation), and any agent-side guard
@@ -26,12 +28,13 @@ export declare function isImageAttachment(mime: string): boolean;
26
28
  * A stored attachment, returned by `POST /sessions/:id/attachments` and carried
27
29
  * on the `prompt` signal payload (`attachments: AttachmentRef[]`).
28
30
  *
29
- * `url` is a fetchable location for the bytes (Supabase Storage). The agent
30
- * fetches it at turn start; the composer never renders `url` for image previews
31
+ * `id` is what the server resolves the bytes by. `url` is a signed Supabase
32
+ * Storage link handed back to the uploader and kept on the wire for engines
33
+ * that already parse it; no server reads it, and the composer never renders it
31
34
  * (it shows the local object URL it already holds).
32
35
  */
33
36
  export interface AttachmentRef {
34
- /** Server-minted id, unique within the session. */
37
+ /** Server-minted UUID, unique within the session — the storage key under it. */
35
38
  id: string;
36
39
  /** Validated MIME type — always one of `ALLOWED_ATTACHMENT_TYPES`. */
37
40
  mimeType: string;
@@ -39,7 +42,7 @@ export interface AttachmentRef {
39
42
  name: string;
40
43
  /** Byte length — within `MAX_ATTACHMENT_BYTES`. */
41
44
  size: number;
42
- /** Fetchable bytes location (Supabase Storage public/signed URL). */
45
+ /** Signed Supabase Storage URL for the uploader. Never fetched server-side. */
43
46
  url: string;
44
47
  }
45
48
  export declare const AttachmentRefSchema: z.ZodObject<{
@@ -3,4 +3,6 @@ export { schemaToWire, UnsupportedSchemaError } from './schema-to-wire';
3
3
  export { schemaFromWire } from './schema-from-wire';
4
4
  export { WireCatalogSchema, WireCatalogEntrySchema, catalogToWire, catalogFromWire, type WireCatalog, type WireCatalogEntry, } from './catalog-wire';
5
5
  export { PackageReleaseSchema, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, type PackageRelease } from './package-release';
6
+ export { SDK_VERSION_PATTERN, SdkVersionSchema, OLDEST_SUPPORTED_SDK, SDK_SHIMS, compareSdkVersions, sdkShimsFor, sdkWindowProblem, type SdkShim, } from './sdk-compat';
7
+ export { PackageBundleRefSchema, type PackageBundleRef } from './package-bundle-ref';
6
8
  export { BRAND_MARK_TYPES, BRAND_MARK_SLOTS, BRAND_MARK_MAX_BYTES, BrandMarkSchema, BrandMarkImageSchema, SpaceBrandMarkSchema, type BrandMark, type BrandMarkFile, type BrandMarkUpload, type BrandMarkStored, type BrandMarkSlot, type BrandMarkType, type BrandMarkImage, type SpaceBrandMark, } from './brand-mark';
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Where one published source's components are served from — immutable URLs in
4
+ * object storage — as the api hands it to a page and the page to the renderer.
5
+ */
6
+ export declare const PackageBundleRefSchema: z.ZodObject<{
7
+ sourceId: z.ZodString;
8
+ js: z.ZodString;
9
+ css: z.ZodString;
10
+ /** The brand's name for itself, and its package's version. */
11
+ label: z.ZodString;
12
+ version: z.ZodString;
13
+ /** The sdk the bundle was built against (`PackageRelease.builtWithSdk`) — absent for a legacy release. Picks its compat shims. */
14
+ builtWithSdk: z.ZodOptional<z.ZodString>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ label: string;
17
+ sourceId: string;
18
+ version: string;
19
+ js: string;
20
+ css: string;
21
+ builtWithSdk?: string | undefined;
22
+ }, {
23
+ label: string;
24
+ sourceId: string;
25
+ version: string;
26
+ js: string;
27
+ css: string;
28
+ builtWithSdk?: string | undefined;
29
+ }>;
30
+ export type PackageBundleRef = z.infer<typeof PackageBundleRefSchema>;
@@ -17,6 +17,14 @@ export declare const PackageReleaseSchema: z.ZodObject<{
17
17
  version: z.ZodString;
18
18
  /** What this release changed, in the publisher's words (`forty publish --message`) — shown in the console's version list. */
19
19
  description: z.ZodOptional<z.ZodString>;
20
+ /**
21
+ * The `@40rty/ams-sdk` version the brand project resolved when `forty
22
+ * publish` built this release. A bundle takes the sdk from the page at
23
+ * runtime, so this is what tells the platform which compat shims it needs
24
+ * and whether it can host it at all (`sdk-compat.ts`). Absent on releases
25
+ * published before the stamp existed — those are legacy.
26
+ */
27
+ builtWithSdk: z.ZodOptional<z.ZodString>;
20
28
  catalog: z.ZodRecord<z.ZodString, z.ZodObject<{
21
29
  type: z.ZodString;
22
30
  propsSchema: z.ZodOptional<z.ZodType<import("./wire-schema").WireSchema, z.ZodTypeDef, import("./wire-schema").WireSchema>>;
@@ -366,6 +374,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
366
374
  manifests: Record<string, string>;
367
375
  config?: Record<string, unknown> | undefined;
368
376
  description?: string | undefined;
377
+ builtWithSdk?: string | undefined;
369
378
  bundle?: {
370
379
  js: string;
371
380
  css: string;
@@ -446,6 +455,7 @@ export declare const PackageReleaseSchema: z.ZodObject<{
446
455
  manifests: Record<string, string>;
447
456
  config?: Record<string, unknown> | undefined;
448
457
  description?: string | undefined;
458
+ builtWithSdk?: string | undefined;
449
459
  bundle?: {
450
460
  js: string;
451
461
  css: string;
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The version contract between a PUBLISHED bundle and the platform that hosts
4
+ * it. A bundle takes `@40rty/ams-sdk` from the page at runtime (the host module
5
+ * map), so it runs against whatever sdk the platform serves today — not the one
6
+ * it was built with. `forty publish` stamps the release with the sdk version the
7
+ * brand project resolved (`builtWithSdk`); this module is the ONE place that
8
+ * says which stamps the platform can host and which compat shims each needs.
9
+ *
10
+ * A release with no stamp predates the stamp: it is LEGACY, treated as the
11
+ * oldest supported sdk — admitted, and given every shim.
12
+ */
13
+ /** A published sdk version: `1.2.3` or `1.2.3-next.4`. */
14
+ export declare const SDK_VERSION_PATTERN: RegExp;
15
+ export declare const SdkVersionSchema: z.ZodString;
16
+ /**
17
+ * The oldest sdk a release may be built against and still be bound to a space.
18
+ * The upper bound is the platform's own sdk version — a bundle built against a
19
+ * newer sdk calls exports this platform does not have.
20
+ */
21
+ export declare const OLDEST_SUPPORTED_SDK = "0.3.0";
22
+ /**
23
+ * Every compat shim the host map applies, and the sdk version it stops being
24
+ * needed at. A shim is deleted once no live release is below its `below`
25
+ * (`GET /admin/package-sdk` answers that).
26
+ */
27
+ export declare const SDK_SHIMS: {
28
+ /** sdk ≤ 0.3 called the vertical verbs on `useCanvasActions()` — `legacy-canvas-actions.ts`. */
29
+ readonly legacyCanvasActions: {
30
+ readonly below: "0.4.0";
31
+ };
32
+ };
33
+ export type SdkShim = keyof typeof SDK_SHIMS;
34
+ /** Semver order of two sdk versions (prerelease below its release). Negative when `a` is older. */
35
+ export declare function compareSdkVersions(a: string, b: string): number;
36
+ /** The shims a bundle built against `builtWithSdk` needs. Unstamped = legacy = every shim. */
37
+ export declare function sdkShimsFor(builtWithSdk: string | undefined): SdkShim[];
38
+ /**
39
+ * Why a release built against `builtWithSdk` cannot be bound to a space on a
40
+ * platform serving `platformSdk` — `null` when it can. Unstamped releases are
41
+ * admitted: they are legacy, and legacy keeps working until a deliberate cutoff.
42
+ */
43
+ export declare function sdkWindowProblem(builtWithSdk: string | undefined, platformSdk: string): string | null;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The query parameter a visitor socket upgrade carries its socket ticket on.
3
+ *
4
+ * A wire contract between every dialer (the engine, the pre-hydration boot dial,
5
+ * the CLI) and the api's upgrade gate, so it lives here once. A browser
6
+ * WebSocket cannot set headers, which is why it rides the URL; the ticket is
7
+ * single-purpose and expires in seconds (`@fourty/platform/socket-ticket`).
8
+ */
9
+ export declare const SOCKET_TICKET_PARAM = "ticket";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The visitor/trace socket's protocol version — the contract between every
3
+ * engine ever published (`/embed/engine/:version`, served forever) and the api
4
+ * it talks to today. ONE number for the whole socket: the frames the engine
5
+ * sends and the `TraceEvent` union it reads.
6
+ *
7
+ * Bump `WIRE_PROTOCOL_VERSION` when a change would make an older engine
8
+ * mis-render (a variant renamed or reshaped, a frame it must send). Raise
9
+ * `MIN_WIRE_PROTOCOL_VERSION` only as the deliberate cutoff, once the older
10
+ * engines are gone: the api then closes their sockets with
11
+ * `WIRE_PROTOCOL_UNSUPPORTED_CLOSE` instead of letting them mis-render.
12
+ *
13
+ * An upgrade that carries NO version is an engine built before this contract.
14
+ * It is admitted (and logged) until the cutoff — see `docs/adr/0006`.
15
+ */
16
+ export declare const WIRE_PROTOCOL_VERSION = 1;
17
+ export declare const MIN_WIRE_PROTOCOL_VERSION = 1;
18
+ /** The query parameter the upgrade carries the version on, beside the socket ticket. */
19
+ export declare const WIRE_PROTOCOL_PARAM = "protocol";
20
+ /**
21
+ * The close code a refused engine receives, right after the upgrade — a refusal
22
+ * BEFORE the upgrade is an HTTP status a browser WebSocket never shows its page.
23
+ * The close reason says which versions the api accepts.
24
+ */
25
+ export declare const WIRE_PROTOCOL_UNSUPPORTED_CLOSE = 4426;
@@ -31,7 +31,7 @@ export { isElementUnfilled, rendersNothing } from './catalog/element-filled';
31
31
  export { carriesShapeToken } from './catalog/shape-tokens';
32
32
  export { applySinglePatch } from './layout/apply-patch';
33
33
  export { derivePropsDoc } from './catalog/derive-props-doc';
34
- export { WireSchemaSchema, WireCatalogSchema, WireCatalogEntrySchema, schemaToWire, schemaFromWire, catalogToWire, catalogFromWire, UnsupportedSchemaError, PackageReleaseSchema, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, BRAND_MARK_TYPES, BRAND_MARK_SLOTS, BRAND_MARK_MAX_BYTES, BrandMarkSchema, BrandMarkImageSchema, SpaceBrandMarkSchema, type BrandMark, type BrandMarkFile, type BrandMarkUpload, type BrandMarkStored, type BrandMarkSlot, type BrandMarkType, type BrandMarkImage, type SpaceBrandMark, type PackageRelease, type WireSchema, type WireCatalog, type WireCatalogEntry, } from './catalog/wire';
34
+ export { WireSchemaSchema, WireCatalogSchema, WireCatalogEntrySchema, schemaToWire, schemaFromWire, catalogToWire, catalogFromWire, UnsupportedSchemaError, PackageReleaseSchema, draftSourceId, isDraftSource, releasePreviewSourceId, parseReleasePreview, SDK_VERSION_PATTERN, SdkVersionSchema, OLDEST_SUPPORTED_SDK, SDK_SHIMS, compareSdkVersions, sdkShimsFor, sdkWindowProblem, type SdkShim, PackageBundleRefSchema, type PackageBundleRef, BRAND_MARK_TYPES, BRAND_MARK_SLOTS, BRAND_MARK_MAX_BYTES, BrandMarkSchema, BrandMarkImageSchema, SpaceBrandMarkSchema, type BrandMark, type BrandMarkFile, type BrandMarkUpload, type BrandMarkStored, type BrandMarkSlot, type BrandMarkType, type BrandMarkImage, type SpaceBrandMark, type PackageRelease, type WireSchema, type WireCatalog, type WireCatalogEntry, } from './catalog/wire';
35
35
  export { LateBoundValueSchema, DirectiveValueSchema, ProjectionDirectiveSchema, ProjectionPreferencesSchema, ProjectionSetPayloadSchema, PROJECTION_SET_SIGNAL, isLateBound, isActiveDirective, projectCollection, type LateBoundValue, type DirectiveValue, type ProjectionDirective, type ProjectionPreferences, type ProjectionSetPayload, type ProjectionAccessors, } from './projection/projection';
36
36
  export { VIEW_FOCUS_ELEMENT_SIGNAL, FocusElementPayloadSchema, type FocusElementPayload, } from './focus/focus';
37
37
  export { VIEW_EXTEND_SIGNAL, VIEW_EXHAUSTED_SIGNAL, ViewExtendPayloadSchema, CONTINUATION_ENABLED, type ViewExtendPayload, } from './view/continuation';
@@ -41,6 +41,8 @@ export { ALLOWED_ATTACHMENT_TYPES, MAX_ATTACHMENT_BYTES, isAllowedAttachmentType
41
41
  export { ENTRY_CONTEXT_MAX_VALUE_CHARS, ENTRY_CONTEXT_MAX_KEYS, ENTRY_CONTEXT_MAX_NAMESPACES, ENTRY_CONTEXT_MAX_NAME_CHARS, EntryContextValueSchema, EntryContextNamespaceSchema, EntryContextSchema, type EntryContext, } from './contracts/entry-context';
42
42
  export { ARRIVAL_MAX_VALUE_CHARS, SURFACES, SurfaceSchema, type Surface, CLICK_ID_KINDS, ClickIdKindSchema, type ClickIdKind, VISITOR_ID_DURABILITIES, VisitorIdDurabilitySchema, type VisitorIdDurability, TRAFFIC_BUCKETS, TrafficBucketSchema, type TrafficBucket, SessionArrivalSchema, type SessionArrival, type RecordedSessionArrival, } from './contracts/session-arrival';
43
43
  export { ARRIVAL_PARAMS, REFERRER_HOST_PARAM, arrivalFromParams, arrivalToParams, type ArrivalEvidence, } from './contracts/session-arrival-params';
44
+ export { SOCKET_TICKET_PARAM } from './contracts/socket-ticket-param';
45
+ export { WIRE_PROTOCOL_VERSION, MIN_WIRE_PROTOCOL_VERSION, WIRE_PROTOCOL_PARAM, WIRE_PROTOCOL_UNSUPPORTED_CLOSE, } from './contracts/wire-protocol';
44
46
  export { type AttributeDef, type AttributeRegistry, type AttributeScopeBucket, type AttributeScopeConfig, AttributeDefSchema, AttributeScopeBucketSchema, AttributeScopeConfigSchema, EXTRAS_PREFIX, } from './catalog/attribute-registry';
45
47
  export { resolveScope, normalizeAttributeField, scopedAttributeKey, scopeOfAttributeKey, } from './catalog/attribute-scope';
46
48
  export type { Space, SpaceName, CreateSpaceInput, UpdateSpaceInput, SpaceConnector, UpsertSpaceConnectorInput } from './space/space';
@@ -439,6 +439,7 @@ export type TraceEvent = {
439
439
  turnId?: string;
440
440
  message: string;
441
441
  step?: string;
442
+ visitorSafe?: true;
442
443
  } | {
443
444
  type: 'diagnostic';
444
445
  diagnostic: TraceDiagnostic;
@@ -1,4 +1,4 @@
1
1
  export { type AgentPresenceFrame, type PresenceFact, SCANNING_FORM, } from './frame';
2
- export { deriveSourceElement, pendingSourceElement, type SourceElementInput, type SourceLookupInput, } from './scan';
2
+ export { deriveSourceElement, pendingSourceElement, projectSourceOutput, type ProjectedSourceOutput, type SourceElementInput, type SourceLookupInput, } from './scan';
3
3
  export { type PresenceElementKind, type PresenceElement, type PresenceSourceRef, type PresenceSourceElement, type PresenceFactArtifact, type PresenceFactElement, type PresenceVoiceElement, type PresenceConcessionElement, type PresenceAskElement, type PresenceRetireOn, type PresenceLifecycle, type PresenceStreamArtifact, isPresenceStreamArtifact, PRESENCE_LIFECYCLE, } from './element';
4
4
  export { type PresenceProfile, PresenceProfileSchema, DEFAULT_PRESENCE_PROFILE } from './profile';
@@ -43,3 +43,24 @@ export declare function pendingSourceElement(input: SourceLookupInput): Presence
43
43
  * rendering gap and an empty shelf are different facts.
44
44
  */
45
45
  export declare function deriveSourceElement(input: SourceElementInput): PresenceSourceElement | undefined;
46
+ /** What `projectSourceOutput` keeps of a tool result: the drawable records under
47
+ * one recognized key, and the tool's own `total` when it reports one. */
48
+ export interface ProjectedSourceOutput {
49
+ results: Record<string, string | number | boolean>[];
50
+ total?: number;
51
+ }
52
+ /**
53
+ * The part of a tool result that may leave the server for a VISITOR.
54
+ *
55
+ * `deriveSourceElement` reads a record's `id`, its image, and its short scalar
56
+ * facets — nothing else. The raw result carries much more (nested objects,
57
+ * documents, audit keys, connector diagnostics), and the visitor wire is
58
+ * public. This keeps exactly what the derivation reads, in a shape it parses
59
+ * to the SAME element, so the trim is invisible to every card while the rest of
60
+ * the result stays on the trace channel.
61
+ *
62
+ * `undefined` when the result carries no recognizable record array — the same
63
+ * line `deriveSourceElement` draws, so a dropped output and an underivable one
64
+ * are the same outcome on the client.
65
+ */
66
+ export declare function projectSourceOutput(output: unknown): ProjectedSourceOutput | undefined;
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.0",
29
+ "version": "0.5.1",
30
30
  "homepage": "https://docs.40rty.ai",
31
31
  "license": "UNLICENSED",
32
32
  "engines": {