@jam-overture/loom 0.1.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/LICENSE +21 -0
- package/README.md +743 -0
- package/dist/catalogue.d.ts +70 -0
- package/dist/catalogue.js +88 -0
- package/dist/cli/args.d.ts +17 -0
- package/dist/cli/args.js +83 -0
- package/dist/cli/filesystem.d.ts +15 -0
- package/dist/cli/filesystem.js +31 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.js +12 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +30 -0
- package/dist/cli/namespace.d.ts +40 -0
- package/dist/cli/namespace.js +40 -0
- package/dist/cli/plan.d.ts +84 -0
- package/dist/cli/plan.js +113 -0
- package/dist/cli/run.d.ts +17 -0
- package/dist/cli/run.js +75 -0
- package/dist/cli/templates.d.ts +43 -0
- package/dist/cli/templates.js +134 -0
- package/dist/closed-set.d.ts +34 -0
- package/dist/closed-set.js +34 -0
- package/dist/data/adapter.d.ts +123 -0
- package/dist/data/adapter.js +91 -0
- package/dist/data/binding.d.ts +48 -0
- package/dist/data/binding.js +39 -0
- package/dist/data/catalogue.d.ts +26 -0
- package/dist/data/catalogue.js +6 -0
- package/dist/data/index.d.ts +14 -0
- package/dist/data/index.js +14 -0
- package/dist/data/plan.d.ts +58 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +91 -0
- package/dist/data/resolution.js +96 -0
- package/dist/data/resolve.d.ts +46 -0
- package/dist/data/resolve.js +37 -0
- package/dist/data/source.d.ts +40 -0
- package/dist/data/source.js +45 -0
- package/dist/deadline.d.ts +57 -0
- package/dist/deadline.js +78 -0
- package/dist/frame/catalogue.d.ts +24 -0
- package/dist/frame/catalogue.js +5 -0
- package/dist/frame/index.d.ts +12 -0
- package/dist/frame/index.js +12 -0
- package/dist/frame/origin.d.ts +87 -0
- package/dist/frame/origin.js +114 -0
- package/dist/frame/resolution.d.ts +85 -0
- package/dist/frame/resolution.js +79 -0
- package/dist/grammar.d.ts +26 -0
- package/dist/grammar.js +28 -0
- package/dist/ids.d.ts +57 -0
- package/dist/ids.js +104 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/interactivity.d.ts +50 -0
- package/dist/interactivity.js +22 -0
- package/dist/interpretation/anthropic.d.ts +22 -0
- package/dist/interpretation/anthropic.js +76 -0
- package/dist/interpretation/client.d.ts +83 -0
- package/dist/interpretation/client.js +2 -0
- package/dist/interpretation/draft.d.ts +234 -0
- package/dist/interpretation/draft.js +84 -0
- package/dist/interpretation/index.d.ts +15 -0
- package/dist/interpretation/index.js +15 -0
- package/dist/interpretation/interpreter.d.ts +62 -0
- package/dist/interpretation/interpreter.js +151 -0
- package/dist/interpretation/materialize.d.ts +42 -0
- package/dist/interpretation/materialize.js +107 -0
- package/dist/interpretation/prompt.d.ts +229 -0
- package/dist/interpretation/prompt.js +285 -0
- package/dist/interpretation/render.d.ts +76 -0
- package/dist/interpretation/render.js +272 -0
- package/dist/interpretation/schema.d.ts +49 -0
- package/dist/interpretation/schema.js +131 -0
- package/dist/json.d.ts +35 -0
- package/dist/json.js +11 -0
- package/dist/paging.d.ts +60 -0
- package/dist/paging.js +49 -0
- package/dist/primitive-type.d.ts +32 -0
- package/dist/primitive-type.js +39 -0
- package/dist/render/addressing.d.ts +59 -0
- package/dist/render/addressing.js +60 -0
- package/dist/render/anchor.d.ts +105 -0
- package/dist/render/anchor.js +84 -0
- package/dist/render/behaviour-adjust.d.ts +62 -0
- package/dist/render/behaviour-adjust.js +78 -0
- package/dist/render/behaviour-copy.d.ts +53 -0
- package/dist/render/behaviour-copy.js +75 -0
- package/dist/render/behaviour-disclose.d.ts +74 -0
- package/dist/render/behaviour-disclose.js +77 -0
- package/dist/render/behaviour-present.d.ts +123 -0
- package/dist/render/behaviour-present.js +173 -0
- package/dist/render/behaviour.d.ts +243 -0
- package/dist/render/behaviour.js +284 -0
- package/dist/render/control.d.ts +81 -0
- package/dist/render/control.js +80 -0
- package/dist/render/decorative.d.ts +62 -0
- package/dist/render/decorative.js +2 -0
- package/dist/render/diagnostics.d.ts +260 -0
- package/dist/render/diagnostics.js +61 -0
- package/dist/render/disclosed.d.ts +37 -0
- package/dist/render/disclosed.js +37 -0
- package/dist/render/editable.d.ts +34 -0
- package/dist/render/editable.js +35 -0
- package/dist/render/frame.d.ts +42 -0
- package/dist/render/frame.js +31 -0
- package/dist/render/index.d.ts +35 -0
- package/dist/render/index.js +35 -0
- package/dist/render/inline-variables.d.ts +77 -0
- package/dist/render/inline-variables.js +220 -0
- package/dist/render/presented.d.ts +82 -0
- package/dist/render/presented.js +82 -0
- package/dist/render/primitive.d.ts +228 -0
- package/dist/render/primitive.js +36 -0
- package/dist/render/props.d.ts +48 -0
- package/dist/render/props.js +2 -0
- package/dist/render/reads.d.ts +73 -0
- package/dist/render/reads.js +45 -0
- package/dist/render/render.d.ts +164 -0
- package/dist/render/render.js +571 -0
- package/dist/render/request.d.ts +111 -0
- package/dist/render/request.js +60 -0
- package/dist/render/text.d.ts +91 -0
- package/dist/render/text.js +44 -0
- package/dist/render/theme.d.ts +61 -0
- package/dist/render/theme.js +52 -0
- package/dist/reserved-props.d.ts +35 -0
- package/dist/reserved-props.js +45 -0
- package/dist/result.d.ts +27 -0
- package/dist/result.js +30 -0
- package/dist/role.d.ts +71 -0
- package/dist/role.js +22 -0
- package/dist/runtime/analysis.d.ts +149 -0
- package/dist/runtime/analysis.js +187 -0
- package/dist/runtime/assessment.d.ts +35 -0
- package/dist/runtime/assessment.js +13 -0
- package/dist/runtime/disposition.d.ts +102 -0
- package/dist/runtime/disposition.js +59 -0
- package/dist/runtime/events.d.ts +187 -0
- package/dist/runtime/events.js +7 -0
- package/dist/runtime/gate.d.ts +43 -0
- package/dist/runtime/gate.js +169 -0
- package/dist/runtime/index.d.ts +27 -0
- package/dist/runtime/index.js +27 -0
- package/dist/runtime/intent.d.ts +60 -0
- package/dist/runtime/intent.js +36 -0
- package/dist/runtime/interpreter.d.ts +117 -0
- package/dist/runtime/interpreter.js +46 -0
- package/dist/runtime/inverse-interpreter.d.ts +90 -0
- package/dist/runtime/inverse-interpreter.js +56 -0
- package/dist/runtime/inverse.d.ts +87 -0
- package/dist/runtime/inverse.js +48 -0
- package/dist/runtime/narration.d.ts +24 -0
- package/dist/runtime/narration.js +36 -0
- package/dist/runtime/nesting.d.ts +31 -0
- package/dist/runtime/nesting.js +46 -0
- package/dist/runtime/pipeline.d.ts +124 -0
- package/dist/runtime/pipeline.js +178 -0
- package/dist/runtime/policy-fingerprint.d.ts +29 -0
- package/dist/runtime/policy-fingerprint.js +119 -0
- package/dist/runtime/policy-source.d.ts +42 -0
- package/dist/runtime/policy-source.js +8 -0
- package/dist/runtime/policy.d.ts +156 -0
- package/dist/runtime/policy.js +107 -0
- package/dist/runtime/proposal.d.ts +423 -0
- package/dist/runtime/proposal.js +109 -0
- package/dist/runtime/redirection.d.ts +53 -0
- package/dist/runtime/redirection.js +38 -0
- package/dist/runtime/repointing.d.ts +71 -0
- package/dist/runtime/repointing.js +0 -0
- package/dist/runtime/reversibility.d.ts +36 -0
- package/dist/runtime/reversibility.js +39 -0
- package/dist/runtime/stake-level.d.ts +33 -0
- package/dist/runtime/stake-level.js +58 -0
- package/dist/runtime/stakes.d.ts +47 -0
- package/dist/runtime/stakes.js +305 -0
- package/dist/runtime/vocabulary.d.ts +122 -0
- package/dist/runtime/vocabulary.js +87 -0
- package/dist/sdk/audit.d.ts +195 -0
- package/dist/sdk/audit.js +128 -0
- package/dist/sdk/catalogue.d.ts +37 -0
- package/dist/sdk/catalogue.js +16 -0
- package/dist/sdk/conformance.d.ts +342 -0
- package/dist/sdk/conformance.js +494 -0
- package/dist/sdk/copy.d.ts +105 -0
- package/dist/sdk/copy.js +90 -0
- package/dist/sdk/definition.d.ts +242 -0
- package/dist/sdk/definition.js +64 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.js +19 -0
- package/dist/sdk/interactivity.d.ts +29 -0
- package/dist/sdk/interactivity.js +34 -0
- package/dist/sdk/pairings.d.ts +124 -0
- package/dist/sdk/pairings.js +81 -0
- package/dist/sdk/registry.d.ts +162 -0
- package/dist/sdk/registry.js +329 -0
- package/dist/sdk/selection.d.ts +46 -0
- package/dist/sdk/selection.js +24 -0
- package/dist/sdk/text.d.ts +100 -0
- package/dist/sdk/text.js +105 -0
- package/dist/sdk/vocabulary.d.ts +39 -0
- package/dist/sdk/vocabulary.js +36 -0
- package/dist/signals/broadcast.d.ts +134 -0
- package/dist/signals/broadcast.js +451 -0
- package/dist/signals/collect.d.ts +184 -0
- package/dist/signals/collect.js +196 -0
- package/dist/signals/deliver.d.ts +64 -0
- package/dist/signals/deliver.js +85 -0
- package/dist/signals/fold.d.ts +112 -0
- package/dist/signals/fold.js +76 -0
- package/dist/signals/index.d.ts +31 -0
- package/dist/signals/index.js +31 -0
- package/dist/signals/ingest.d.ts +51 -0
- package/dist/signals/ingest.js +70 -0
- package/dist/signals/intake.d.ts +149 -0
- package/dist/signals/intake.js +154 -0
- package/dist/signals/journal.d.ts +94 -0
- package/dist/signals/journal.js +11 -0
- package/dist/signals/kinds.d.ts +22 -0
- package/dist/signals/kinds.js +22 -0
- package/dist/signals/ledger.d.ts +46 -0
- package/dist/signals/ledger.js +81 -0
- package/dist/signals/memory.d.ts +17 -0
- package/dist/signals/memory.js +99 -0
- package/dist/signals/migrate.d.ts +27 -0
- package/dist/signals/migrate.js +78 -0
- package/dist/signals/postgres.d.ts +7 -0
- package/dist/signals/postgres.js +295 -0
- package/dist/signals/rollup.d.ts +142 -0
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +534 -0
- package/dist/signals/schema.js +92 -0
- package/dist/signals/signal.d.ts +381 -0
- package/dist/signals/signal.js +150 -0
- package/dist/signals/tally.d.ts +70 -0
- package/dist/signals/tally.js +2 -0
- package/dist/signals/view.d.ts +51 -0
- package/dist/signals/view.js +54 -0
- package/dist/store/attribution.d.ts +125 -0
- package/dist/store/attribution.js +116 -0
- package/dist/store/database.d.ts +14 -0
- package/dist/store/database.js +2 -0
- package/dist/store/driver.d.ts +29 -0
- package/dist/store/driver.js +39 -0
- package/dist/store/errors.d.ts +56 -0
- package/dist/store/errors.js +37 -0
- package/dist/store/index.d.ts +16 -0
- package/dist/store/index.js +16 -0
- package/dist/store/memory.d.ts +3 -0
- package/dist/store/memory.js +115 -0
- package/dist/store/migrate.d.ts +54 -0
- package/dist/store/migrate.js +122 -0
- package/dist/store/postgres-holds.d.ts +4 -0
- package/dist/store/postgres-holds.js +192 -0
- package/dist/store/postgres.d.ts +8 -0
- package/dist/store/postgres.js +262 -0
- package/dist/store/replay.d.ts +94 -0
- package/dist/store/replay.js +82 -0
- package/dist/store/revert.d.ts +116 -0
- package/dist/store/revert.js +243 -0
- package/dist/store/schema.d.ts +371 -0
- package/dist/store/schema.js +78 -0
- package/dist/store/source.d.ts +23 -0
- package/dist/store/source.js +37 -0
- package/dist/store/store.d.ts +231 -0
- package/dist/store/store.js +52 -0
- package/dist/store/undone.d.ts +18 -0
- package/dist/store/undone.js +89 -0
- package/dist/submit/catalogue.d.ts +20 -0
- package/dist/submit/catalogue.js +5 -0
- package/dist/submit/declaration.d.ts +39 -0
- package/dist/submit/declaration.js +30 -0
- package/dist/submit/endpoint.d.ts +131 -0
- package/dist/submit/endpoint.js +160 -0
- package/dist/submit/index.d.ts +13 -0
- package/dist/submit/index.js +13 -0
- package/dist/submit/plan.d.ts +49 -0
- package/dist/submit/plan.js +47 -0
- package/dist/submit/resolution.d.ts +61 -0
- package/dist/submit/resolution.js +64 -0
- package/dist/submit/resolve.d.ts +45 -0
- package/dist/submit/resolve.js +36 -0
- package/dist/telemetry/calibration.d.ts +132 -0
- package/dist/telemetry/calibration.js +151 -0
- package/dist/telemetry/episode.d.ts +140 -0
- package/dist/telemetry/episode.js +272 -0
- package/dist/telemetry/event.d.ts +2310 -0
- package/dist/telemetry/event.js +405 -0
- package/dist/telemetry/index.d.ts +15 -0
- package/dist/telemetry/index.js +15 -0
- package/dist/telemetry/journal.d.ts +116 -0
- package/dist/telemetry/journal.js +11 -0
- package/dist/telemetry/memory.d.ts +24 -0
- package/dist/telemetry/memory.js +75 -0
- package/dist/telemetry/migrate.d.ts +26 -0
- package/dist/telemetry/migrate.js +40 -0
- package/dist/telemetry/postgres.d.ts +6 -0
- package/dist/telemetry/postgres.js +139 -0
- package/dist/telemetry/retention.d.ts +131 -0
- package/dist/telemetry/retention.js +217 -0
- package/dist/telemetry/schema.d.ts +113 -0
- package/dist/telemetry/schema.js +33 -0
- package/dist/telemetry/sink.d.ts +42 -0
- package/dist/telemetry/sink.js +61 -0
- package/dist/testing/contracts.d.ts +34 -0
- package/dist/testing/contracts.js +34 -0
- package/dist/testing/definitions.d.ts +15 -0
- package/dist/testing/definitions.js +48 -0
- package/dist/testing/doubles.d.ts +94 -0
- package/dist/testing/doubles.js +141 -0
- package/dist/testing/episode-harness.d.ts +49 -0
- package/dist/testing/episode-harness.js +65 -0
- package/dist/testing/filesystem.d.ts +17 -0
- package/dist/testing/filesystem.js +17 -0
- package/dist/testing/fixtures.d.ts +57 -0
- package/dist/testing/fixtures.js +84 -0
- package/dist/testing/hold-contract.d.ts +19 -0
- package/dist/testing/hold-contract.js +374 -0
- package/dist/testing/index.d.ts +41 -0
- package/dist/testing/index.js +41 -0
- package/dist/testing/journal-contract.d.ts +17 -0
- package/dist/testing/journal-contract.js +353 -0
- package/dist/testing/model-replies.d.ts +34 -0
- package/dist/testing/model-replies.js +101 -0
- package/dist/testing/primitives.d.ts +7 -0
- package/dist/testing/primitives.js +29 -0
- package/dist/testing/reader-signal-contract.d.ts +38 -0
- package/dist/testing/reader-signal-contract.js +318 -0
- package/dist/testing/row-security.d.ts +17 -0
- package/dist/testing/row-security.js +21 -0
- package/dist/testing/store-contract.d.ts +25 -0
- package/dist/testing/store-contract.js +500 -0
- package/dist/theme/apply.d.ts +17 -0
- package/dist/theme/apply.js +60 -0
- package/dist/theme/contrast.d.ts +197 -0
- package/dist/theme/contrast.js +259 -0
- package/dist/theme/derive.d.ts +77 -0
- package/dist/theme/derive.js +167 -0
- package/dist/theme/faces.d.ts +73 -0
- package/dist/theme/faces.js +119 -0
- package/dist/theme/font-packs.d.ts +25 -0
- package/dist/theme/font-packs.js +257 -0
- package/dist/theme/index.d.ts +20 -0
- package/dist/theme/index.js +20 -0
- package/dist/theme/lab.d.ts +30 -0
- package/dist/theme/lab.js +46 -0
- package/dist/theme/library.d.ts +114 -0
- package/dist/theme/library.js +300 -0
- package/dist/theme/measure.d.ts +144 -0
- package/dist/theme/measure.js +145 -0
- package/dist/theme/palettes.d.ts +64 -0
- package/dist/theme/palettes.js +497 -0
- package/dist/theme/registry.d.ts +59 -0
- package/dist/theme/registry.js +60 -0
- package/dist/theme/separation.d.ts +177 -0
- package/dist/theme/separation.js +203 -0
- package/dist/theme/style-presets.d.ts +60 -0
- package/dist/theme/style-presets.js +124 -0
- package/dist/theme/theme.d.ts +253 -0
- package/dist/theme/theme.js +171 -0
- package/dist/tree/apply.d.ts +16 -0
- package/dist/tree/apply.js +104 -0
- package/dist/tree/builders.d.ts +19 -0
- package/dist/tree/builders.js +20 -0
- package/dist/tree/compare.d.ts +68 -0
- package/dist/tree/compare.js +75 -0
- package/dist/tree/configuration.d.ts +25 -0
- package/dist/tree/configuration.js +108 -0
- package/dist/tree/delta.d.ts +288 -0
- package/dist/tree/delta.js +88 -0
- package/dist/tree/errors.d.ts +69 -0
- package/dist/tree/errors.js +34 -0
- package/dist/tree/identity.d.ts +117 -0
- package/dist/tree/identity.js +145 -0
- package/dist/tree/index.d.ts +21 -0
- package/dist/tree/index.js +21 -0
- package/dist/tree/inverse.d.ts +24 -0
- package/dist/tree/inverse.js +112 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +49 -0
- package/dist/tree/naming.d.ts +4 -0
- package/dist/tree/naming.js +35 -0
- package/dist/tree/navigation.d.ts +38 -0
- package/dist/tree/navigation.js +83 -0
- package/dist/tree/node.d.ts +103 -0
- package/dist/tree/node.js +46 -0
- package/dist/tree/outline.d.ts +28 -0
- package/dist/tree/outline.js +10 -0
- package/dist/tree/tree.d.ts +83 -0
- package/dist/tree/tree.js +62 -0
- package/dist/write/commit.d.ts +124 -0
- package/dist/write/commit.js +234 -0
- package/dist/write/held.d.ts +674 -0
- package/dist/write/held.js +185 -0
- package/dist/write/index.d.ts +11 -0
- package/dist/write/index.js +11 -0
- package/dist/write/liveness.d.ts +132 -0
- package/dist/write/liveness.js +91 -0
- package/dist/write/revert.d.ts +79 -0
- package/dist/write/revert.js +134 -0
- package/package.json +160 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* What a primitive says about whether it renders a target the reader aims at.
|
|
4
|
+
*
|
|
5
|
+
* HTML forbids interactive content inside interactive content: an `a` inside an
|
|
6
|
+
* `a`, a `button` inside either. A browser handed that markup does not report
|
|
7
|
+
* it — it resolves the ambiguity by dropping one of the two targets, so the
|
|
8
|
+
* page renders, looks right, and one of the things on it silently does not
|
|
9
|
+
* work. It is the rare structural mistake that is invisible in a screenshot and
|
|
10
|
+
* obvious to a reader.
|
|
11
|
+
*
|
|
12
|
+
* The declaration says what a *node* is, never what a *parent may hold*.
|
|
13
|
+
* `loom.card` renders an anchor when the tree gives it an `href` and a plain
|
|
14
|
+
* surface when it does not, which is a fact about that primitive alone;
|
|
15
|
+
* whether two of them sit inside one another is derived from the tree rather
|
|
16
|
+
* than declared. That is the distinction
|
|
17
|
+
* [0054](../decisions/0054-a-container-is-its-childs-name-plus-the-arrangement.md)
|
|
18
|
+
* drew when it rejected a `childType` field, and the reason this is not that.
|
|
19
|
+
*
|
|
20
|
+
* It lives here, beside the identifier schemas, because it has two readers that
|
|
21
|
+
* do not know about each other: the SDK, where an author declares it, and the
|
|
22
|
+
* Gate's policy, where a deployment's set of them arrives as vocabulary.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* The conditional case is the common one, and collapsing it into `always` would
|
|
26
|
+
* make the check worse than useless: a `loom.card` with no `href` holding a
|
|
27
|
+
* `loom.action` is the ordinary composition, and a rule that refused it is a
|
|
28
|
+
* rule hosts turn off.
|
|
29
|
+
*/
|
|
30
|
+
export type InteractiveWhen = "always" | {
|
|
31
|
+
readonly whenProps: readonly string[];
|
|
32
|
+
};
|
|
33
|
+
export declare const interactiveWhenSchema: z.ZodType<InteractiveWhen, z.ZodTypeDef, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* The primitives of a deployment that render a target, by type.
|
|
36
|
+
*
|
|
37
|
+
* Keyed by plain `string` rather than by the branded `PrimitiveType`, so a host
|
|
38
|
+
* can write the map as a literal. The schema still validates every key as a
|
|
39
|
+
* primitive type on the way in; what it does not do is make the ordinary
|
|
40
|
+
* spelling of a policy fail to compile.
|
|
41
|
+
*/
|
|
42
|
+
export type InteractiveTypes = Readonly<Record<string, InteractiveWhen | undefined>>;
|
|
43
|
+
export declare const interactiveTypesSchema: z.ZodType<InteractiveTypes, z.ZodTypeDef, unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* The own-property test is load-bearing rather than belt-and-braces: a trigger
|
|
46
|
+
* named `constructor` or `toString` would otherwise read a function off
|
|
47
|
+
* `Object.prototype` and make every node of that type a target.
|
|
48
|
+
*/
|
|
49
|
+
export declare const isInteractiveWith: (when: InteractiveWhen, props: Readonly<Record<string, unknown>>) => boolean;
|
|
50
|
+
//# sourceMappingURL=interactivity.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { primitiveTypeSchema } from "./primitive-type.js";
|
|
3
|
+
export const interactiveWhenSchema = z.union([
|
|
4
|
+
z.literal("always"),
|
|
5
|
+
z.object({ whenProps: z.array(z.string().min(1)).min(1).readonly() }).strict(),
|
|
6
|
+
]);
|
|
7
|
+
export const interactiveTypesSchema = z.record(primitiveTypeSchema, interactiveWhenSchema);
|
|
8
|
+
/**
|
|
9
|
+
* A prop turns a primitive into a target when the tree actually gave it one.
|
|
10
|
+
* `null` and the empty string do not count: a card whose `href` was cleared
|
|
11
|
+
* renders the surface again, and reading a blank as a link would refuse the
|
|
12
|
+
* change that fixed the nesting.
|
|
13
|
+
*/
|
|
14
|
+
const isSet = (value) => value !== undefined && value !== null && value !== "";
|
|
15
|
+
/**
|
|
16
|
+
* The own-property test is load-bearing rather than belt-and-braces: a trigger
|
|
17
|
+
* named `constructor` or `toString` would otherwise read a function off
|
|
18
|
+
* `Object.prototype` and make every node of that type a target.
|
|
19
|
+
*/
|
|
20
|
+
export const isInteractiveWith = (when, props) => when === "always" ||
|
|
21
|
+
when.whenProps.some((key) => Object.hasOwn(props, key) && isSet(props[key]));
|
|
22
|
+
//# sourceMappingURL=interactivity.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
import type { ModelClient } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* The Anthropic adapter: the one module in Loom that knows a specific vendor
|
|
5
|
+
* exists. It is not exported from the package root — a host that brings its own
|
|
6
|
+
* model never loads it, and the SDK stays an optional peer dependency.
|
|
7
|
+
*
|
|
8
|
+
* Its whole job is translation. It makes no decisions about prompts, schemas,
|
|
9
|
+
* retries, or what a bad answer means; those belong to the interpreter, which
|
|
10
|
+
* is why they are testable without this file.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Structurally satisfied by an `Anthropic` instance, so production passes the
|
|
14
|
+
* real client and tests pass a stub, without either needing the other.
|
|
15
|
+
*/
|
|
16
|
+
export type AnthropicMessages = {
|
|
17
|
+
readonly create: (params: Anthropic.MessageCreateParamsNonStreaming, options?: {
|
|
18
|
+
readonly signal?: AbortSignal;
|
|
19
|
+
}) => Promise<Anthropic.Message>;
|
|
20
|
+
};
|
|
21
|
+
export declare const anthropicModelClient: (messages: AnthropicMessages) => ModelClient;
|
|
22
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { err, ok } from "../result.js";
|
|
2
|
+
const firstTextBlock = (message) => message.content.find((block) => block.type === "text")?.text;
|
|
3
|
+
const errorDetail = (cause) => cause instanceof Error ? cause.message : "unknown transport failure";
|
|
4
|
+
/**
|
|
5
|
+
* Read structurally rather than with `instanceof`, for the same reason this
|
|
6
|
+
* module takes `AnthropicMessages` rather than an `Anthropic`: the SDK is an
|
|
7
|
+
* optional peer, and a stub in a test throws whatever it likes.
|
|
8
|
+
*/
|
|
9
|
+
const statusOf = (cause) => {
|
|
10
|
+
if (typeof cause !== "object" || cause === null)
|
|
11
|
+
return undefined;
|
|
12
|
+
const { status } = cause;
|
|
13
|
+
return typeof status === "number" ? status : undefined;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Which of the three "could not answer" codes a thrown error is.
|
|
17
|
+
*
|
|
18
|
+
* Only a status we positively recognise as this side's fault becomes `rejected`
|
|
19
|
+
* or `misconfigured`; everything else — including a transport failure that
|
|
20
|
+
* never got a response — stays `unavailable`. Guessing wrong in that direction
|
|
21
|
+
* costs a retry that fails, where guessing wrong the other way tells a host to
|
|
22
|
+
* stop trying something that would have worked.
|
|
23
|
+
*
|
|
24
|
+
* 408, 409 and 429 are the 4xx statuses that mean "later", and the SDK has
|
|
25
|
+
* already retried them twice by the time one reaches here, so a 429 that
|
|
26
|
+
* escapes is a rate limit that outlasted the client's own backoff.
|
|
27
|
+
*/
|
|
28
|
+
const classifyThrown = (status) => {
|
|
29
|
+
if (status === undefined)
|
|
30
|
+
return "unavailable";
|
|
31
|
+
if (status === 401 || status === 402 || status === 403)
|
|
32
|
+
return "misconfigured";
|
|
33
|
+
const asksAgainLater = status === 408 || status === 409 || status === 429;
|
|
34
|
+
return status >= 400 && status < 500 && !asksAgainLater ? "rejected" : "unavailable";
|
|
35
|
+
};
|
|
36
|
+
const toCompletion = (message) => {
|
|
37
|
+
if (message.stop_reason === "refusal") {
|
|
38
|
+
return err({ code: "refused", detail: message.stop_details?.category ?? "unspecified" });
|
|
39
|
+
}
|
|
40
|
+
if (message.stop_reason === "max_tokens") {
|
|
41
|
+
return err({ code: "incomplete", detail: "hit the output token ceiling" });
|
|
42
|
+
}
|
|
43
|
+
const text = firstTextBlock(message);
|
|
44
|
+
if (text === undefined) {
|
|
45
|
+
return err({ code: "incomplete", detail: "reply contained no text block" });
|
|
46
|
+
}
|
|
47
|
+
return ok({ text, servedBy: message.model });
|
|
48
|
+
};
|
|
49
|
+
export const anthropicModelClient = (messages) => ({
|
|
50
|
+
complete: async (request, options) => {
|
|
51
|
+
try {
|
|
52
|
+
const message = await messages.create({
|
|
53
|
+
model: request.model,
|
|
54
|
+
max_tokens: request.maxTokens,
|
|
55
|
+
system: request.system,
|
|
56
|
+
output_config: {
|
|
57
|
+
effort: request.effort,
|
|
58
|
+
format: { type: "json_schema", schema: request.outputSchema },
|
|
59
|
+
},
|
|
60
|
+
messages: [{ role: "user", content: request.userMessage }],
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* The caller's ceiling, forwarded so the SDK closes the connection
|
|
64
|
+
* rather than holding one nobody is waiting on. It is the whole reason
|
|
65
|
+
* this adapter takes the options at all — the answer would arrive on
|
|
66
|
+
* time without it.
|
|
67
|
+
*/
|
|
68
|
+
options?.signal === undefined ? undefined : { signal: options.signal });
|
|
69
|
+
return toCompletion(message);
|
|
70
|
+
}
|
|
71
|
+
catch (cause) {
|
|
72
|
+
return err({ code: classifyThrown(statusOf(cause)), detail: errorDetail(cause) });
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { JsonObject } from "../json.js";
|
|
2
|
+
import type { Result } from "../result.js";
|
|
3
|
+
/**
|
|
4
|
+
* The network boundary, and nothing else.
|
|
5
|
+
*
|
|
6
|
+
* Everything an interpreter does — assembling the request, parsing the reply,
|
|
7
|
+
* validating the delta, deciding what a malformed answer means — sits above
|
|
8
|
+
* this interface and is therefore testable with no network and no credentials.
|
|
9
|
+
* A `ModelClient` implementation is allowed to do exactly one thing: turn a
|
|
10
|
+
* request into text or into a reason it could not.
|
|
11
|
+
*/
|
|
12
|
+
export type ModelEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
13
|
+
export type ModelRequest = {
|
|
14
|
+
readonly model: string;
|
|
15
|
+
readonly maxTokens: number;
|
|
16
|
+
readonly effort: ModelEffort;
|
|
17
|
+
readonly system: string;
|
|
18
|
+
readonly userMessage: string;
|
|
19
|
+
/** JSON Schema the reply is constrained to. */
|
|
20
|
+
readonly outputSchema: JsonObject;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* How the call is being made, as distinct from what is being asked.
|
|
24
|
+
*
|
|
25
|
+
* `signal` is aborted when the runtime has stopped waiting — its ceiling was
|
|
26
|
+
* reached, or whatever asked for the change went away. An implementation is free
|
|
27
|
+
* to ignore it and the caller will still get an answer on time; what it loses by
|
|
28
|
+
* ignoring it is the connection it is holding, which nobody is going to read.
|
|
29
|
+
*/
|
|
30
|
+
export type ModelCallOptions = {
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
};
|
|
33
|
+
export type ModelCompletion = {
|
|
34
|
+
/** The reply body, expected to be JSON matching `outputSchema`. */
|
|
35
|
+
readonly text: string;
|
|
36
|
+
/** The model that actually served the request, which may differ from the one asked for. */
|
|
37
|
+
readonly servedBy: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Five failure modes, kept apart because each names a different actor — the one
|
|
41
|
+
* who would have to do something for the next attempt to go differently.
|
|
42
|
+
*
|
|
43
|
+
* - `unavailable` — the service could not answer now. Nobody has to act; the
|
|
44
|
+
* same request may succeed later.
|
|
45
|
+
* - `rejected` — the service refused the request itself. Repeating it unchanged
|
|
46
|
+
* fails identically, so what has to change is the request, which is Loom's.
|
|
47
|
+
* - `misconfigured` — this deployment may not talk to this model at all:
|
|
48
|
+
* credentials, entitlement, billing. An operator has to act.
|
|
49
|
+
* - `refused` — the model would not answer this content.
|
|
50
|
+
* - `incomplete` — the answer was cut off mid-sentence, which is a malformed
|
|
51
|
+
* reply rather than a missing one.
|
|
52
|
+
*
|
|
53
|
+
* The first three were one code until day 37. Collapsing them meant a request
|
|
54
|
+
* the API rejected outright was reported as "ask again later", which is a lie
|
|
55
|
+
* downstream cannot detect and cannot recover from.
|
|
56
|
+
*/
|
|
57
|
+
export type ModelClientError = {
|
|
58
|
+
readonly code: "unavailable";
|
|
59
|
+
readonly detail: string;
|
|
60
|
+
} | {
|
|
61
|
+
readonly code: "rejected";
|
|
62
|
+
readonly detail: string;
|
|
63
|
+
} | {
|
|
64
|
+
readonly code: "misconfigured";
|
|
65
|
+
readonly detail: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly code: "refused";
|
|
68
|
+
readonly detail: string;
|
|
69
|
+
} | {
|
|
70
|
+
readonly code: "incomplete";
|
|
71
|
+
readonly detail: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* An implementation is allowed to take as long as it likes; it is not allowed to
|
|
75
|
+
* decide how long the runtime waits. `modelInterpreter` puts a ceiling on every
|
|
76
|
+
* call it makes (0140), so a client that hangs is reported as `unavailable`
|
|
77
|
+
* rather than becoming a page that never finishes loading — which is true of a
|
|
78
|
+
* host's own client as much as of the Anthropic adapter.
|
|
79
|
+
*/
|
|
80
|
+
export interface ModelClient {
|
|
81
|
+
readonly complete: (request: ModelRequest, options?: ModelCallOptions) => Promise<Result<ModelCompletion, ModelClientError>>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type PrimitiveType } from "../primitive-type.js";
|
|
3
|
+
/**
|
|
4
|
+
* What a model is allowed to say.
|
|
5
|
+
*
|
|
6
|
+
* A draft is the tree schema with three things taken away. Inserted nodes carry
|
|
7
|
+
* no `id`, because identity is minted by the runtime and never by the proposer.
|
|
8
|
+
* Props arrive as one JSON-encoded object rather than a typed structure, and the
|
|
9
|
+
* node kinds an insert may introduce are element and text only. None of this
|
|
10
|
+
* changes the AST — a draft is a projection of it, and `materializeDelta` is the
|
|
11
|
+
* inverse projection.
|
|
12
|
+
*
|
|
13
|
+
* The last two are not aesthetic choices. Structured output compiles the emitted
|
|
14
|
+
* schema into a grammar with a size ceiling, and the typed prop union 0004
|
|
15
|
+
* specified — repeated at every element at every level — put the schema four
|
|
16
|
+
* times over that ceiling, so no live call ever succeeded. Measured and adopted
|
|
17
|
+
* in 0014, which supersedes 0004.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* A JSON-encoded object of props: `{"tone":"quiet","count":2}`.
|
|
21
|
+
*
|
|
22
|
+
* A string costs the compiled grammar one production no matter how many props it
|
|
23
|
+
* carries or how deeply their values nest, which is what buys back the nesting
|
|
24
|
+
* depth. Nothing is trusted about the contents: `materializeDelta` parses it,
|
|
25
|
+
* requires an object, and validates every value against the JSON value space, so
|
|
26
|
+
* a malformed bag is a `malformed-proposal` rather than something that reaches a
|
|
27
|
+
* tree.
|
|
28
|
+
*/
|
|
29
|
+
export declare const draftPropsSchema: z.ZodString;
|
|
30
|
+
export type DraftNode = {
|
|
31
|
+
readonly kind: "element";
|
|
32
|
+
readonly type: PrimitiveType;
|
|
33
|
+
readonly props: string;
|
|
34
|
+
readonly children: readonly DraftNode[];
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: "text";
|
|
37
|
+
readonly value: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* `slot` is absent on purpose. A slot is a projection region a primitive
|
|
41
|
+
* declares, not content an edit adds — §4's catalogue tells a model which slots
|
|
42
|
+
* a primitive has, and slots already in a tree stay addressable, configurable,
|
|
43
|
+
* and projectable. Dropping the third variant is also part of what keeps depth 4
|
|
44
|
+
* affordable.
|
|
45
|
+
*/
|
|
46
|
+
export declare const draftNodeSchema: z.ZodType<DraftNode, z.ZodTypeDef, unknown>;
|
|
47
|
+
export declare const draftOperationSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
|
|
48
|
+
op: z.ZodLiteral<"insert">;
|
|
49
|
+
parentId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
50
|
+
index: z.ZodNumber;
|
|
51
|
+
node: z.ZodType<DraftNode, z.ZodTypeDef, unknown>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
index: number;
|
|
54
|
+
op: "insert";
|
|
55
|
+
parentId: string & z.BRAND<"NodeId">;
|
|
56
|
+
node: DraftNode;
|
|
57
|
+
}, {
|
|
58
|
+
index: number;
|
|
59
|
+
op: "insert";
|
|
60
|
+
parentId: string;
|
|
61
|
+
node?: unknown;
|
|
62
|
+
}>, z.ZodObject<{
|
|
63
|
+
op: z.ZodLiteral<"remove">;
|
|
64
|
+
nodeId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
op: "remove";
|
|
67
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
68
|
+
}, {
|
|
69
|
+
op: "remove";
|
|
70
|
+
nodeId: string;
|
|
71
|
+
}>, z.ZodObject<{
|
|
72
|
+
op: z.ZodLiteral<"move">;
|
|
73
|
+
nodeId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
74
|
+
parentId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
75
|
+
index: z.ZodNumber;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
index: number;
|
|
78
|
+
op: "move";
|
|
79
|
+
parentId: string & z.BRAND<"NodeId">;
|
|
80
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
81
|
+
}, {
|
|
82
|
+
index: number;
|
|
83
|
+
op: "move";
|
|
84
|
+
parentId: string;
|
|
85
|
+
nodeId: string;
|
|
86
|
+
}>, z.ZodObject<{
|
|
87
|
+
op: z.ZodLiteral<"configure">;
|
|
88
|
+
nodeId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
89
|
+
set: z.ZodString;
|
|
90
|
+
unset: z.ZodReadonly<z.ZodArray<z.ZodString, "many">>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
set: string;
|
|
93
|
+
op: "configure";
|
|
94
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
95
|
+
unset: readonly string[];
|
|
96
|
+
}, {
|
|
97
|
+
set: string;
|
|
98
|
+
op: "configure";
|
|
99
|
+
nodeId: string;
|
|
100
|
+
unset: readonly string[];
|
|
101
|
+
}>]>;
|
|
102
|
+
export type DraftOperation = z.infer<typeof draftOperationSchema>;
|
|
103
|
+
/**
|
|
104
|
+
* The reply is a three-way outcome rather than a delta, because "I understood
|
|
105
|
+
* you and nothing needs to change" and "I did not understand you" are answers,
|
|
106
|
+
* not failures to answer. Both map onto an `InterpretationError` code; neither
|
|
107
|
+
* is a rejected proposal.
|
|
108
|
+
*/
|
|
109
|
+
export declare const interpretationReplySchema: z.ZodDiscriminatedUnion<"outcome", [z.ZodObject<{
|
|
110
|
+
outcome: z.ZodLiteral<"change">;
|
|
111
|
+
rationale: z.ZodString;
|
|
112
|
+
confidence: z.ZodNumber;
|
|
113
|
+
operations: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
|
|
114
|
+
op: z.ZodLiteral<"insert">;
|
|
115
|
+
parentId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
116
|
+
index: z.ZodNumber;
|
|
117
|
+
node: z.ZodType<DraftNode, z.ZodTypeDef, unknown>;
|
|
118
|
+
}, "strip", z.ZodTypeAny, {
|
|
119
|
+
index: number;
|
|
120
|
+
op: "insert";
|
|
121
|
+
parentId: string & z.BRAND<"NodeId">;
|
|
122
|
+
node: DraftNode;
|
|
123
|
+
}, {
|
|
124
|
+
index: number;
|
|
125
|
+
op: "insert";
|
|
126
|
+
parentId: string;
|
|
127
|
+
node?: unknown;
|
|
128
|
+
}>, z.ZodObject<{
|
|
129
|
+
op: z.ZodLiteral<"remove">;
|
|
130
|
+
nodeId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
op: "remove";
|
|
133
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
134
|
+
}, {
|
|
135
|
+
op: "remove";
|
|
136
|
+
nodeId: string;
|
|
137
|
+
}>, z.ZodObject<{
|
|
138
|
+
op: z.ZodLiteral<"move">;
|
|
139
|
+
nodeId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
140
|
+
parentId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
141
|
+
index: z.ZodNumber;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
index: number;
|
|
144
|
+
op: "move";
|
|
145
|
+
parentId: string & z.BRAND<"NodeId">;
|
|
146
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
147
|
+
}, {
|
|
148
|
+
index: number;
|
|
149
|
+
op: "move";
|
|
150
|
+
parentId: string;
|
|
151
|
+
nodeId: string;
|
|
152
|
+
}>, z.ZodObject<{
|
|
153
|
+
op: z.ZodLiteral<"configure">;
|
|
154
|
+
nodeId: z.ZodBranded<z.ZodString, "NodeId">;
|
|
155
|
+
set: z.ZodString;
|
|
156
|
+
unset: z.ZodReadonly<z.ZodArray<z.ZodString, "many">>;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
set: string;
|
|
159
|
+
op: "configure";
|
|
160
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
161
|
+
unset: readonly string[];
|
|
162
|
+
}, {
|
|
163
|
+
set: string;
|
|
164
|
+
op: "configure";
|
|
165
|
+
nodeId: string;
|
|
166
|
+
unset: readonly string[];
|
|
167
|
+
}>]>, "many">>;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
outcome: "change";
|
|
170
|
+
rationale: string;
|
|
171
|
+
confidence: number;
|
|
172
|
+
operations: readonly ({
|
|
173
|
+
index: number;
|
|
174
|
+
op: "insert";
|
|
175
|
+
parentId: string & z.BRAND<"NodeId">;
|
|
176
|
+
node: DraftNode;
|
|
177
|
+
} | {
|
|
178
|
+
op: "remove";
|
|
179
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
180
|
+
} | {
|
|
181
|
+
index: number;
|
|
182
|
+
op: "move";
|
|
183
|
+
parentId: string & z.BRAND<"NodeId">;
|
|
184
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
185
|
+
} | {
|
|
186
|
+
set: string;
|
|
187
|
+
op: "configure";
|
|
188
|
+
nodeId: string & z.BRAND<"NodeId">;
|
|
189
|
+
unset: readonly string[];
|
|
190
|
+
})[];
|
|
191
|
+
}, {
|
|
192
|
+
outcome: "change";
|
|
193
|
+
rationale: string;
|
|
194
|
+
confidence: number;
|
|
195
|
+
operations: readonly ({
|
|
196
|
+
index: number;
|
|
197
|
+
op: "insert";
|
|
198
|
+
parentId: string;
|
|
199
|
+
node?: unknown;
|
|
200
|
+
} | {
|
|
201
|
+
op: "remove";
|
|
202
|
+
nodeId: string;
|
|
203
|
+
} | {
|
|
204
|
+
index: number;
|
|
205
|
+
op: "move";
|
|
206
|
+
parentId: string;
|
|
207
|
+
nodeId: string;
|
|
208
|
+
} | {
|
|
209
|
+
set: string;
|
|
210
|
+
op: "configure";
|
|
211
|
+
nodeId: string;
|
|
212
|
+
unset: readonly string[];
|
|
213
|
+
})[];
|
|
214
|
+
}>, z.ZodObject<{
|
|
215
|
+
outcome: z.ZodLiteral<"no-change">;
|
|
216
|
+
rationale: z.ZodString;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
outcome: "no-change";
|
|
219
|
+
rationale: string;
|
|
220
|
+
}, {
|
|
221
|
+
outcome: "no-change";
|
|
222
|
+
rationale: string;
|
|
223
|
+
}>, z.ZodObject<{
|
|
224
|
+
outcome: z.ZodLiteral<"not-understood">;
|
|
225
|
+
rationale: z.ZodString;
|
|
226
|
+
}, "strip", z.ZodTypeAny, {
|
|
227
|
+
outcome: "not-understood";
|
|
228
|
+
rationale: string;
|
|
229
|
+
}, {
|
|
230
|
+
outcome: "not-understood";
|
|
231
|
+
rationale: string;
|
|
232
|
+
}>]>;
|
|
233
|
+
export type InterpretationReply = z.infer<typeof interpretationReplySchema>;
|
|
234
|
+
//# sourceMappingURL=draft.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { nodeIdSchema } from "../ids.js";
|
|
3
|
+
import { primitiveTypeSchema } from "../primitive-type.js";
|
|
4
|
+
/**
|
|
5
|
+
* What a model is allowed to say.
|
|
6
|
+
*
|
|
7
|
+
* A draft is the tree schema with three things taken away. Inserted nodes carry
|
|
8
|
+
* no `id`, because identity is minted by the runtime and never by the proposer.
|
|
9
|
+
* Props arrive as one JSON-encoded object rather than a typed structure, and the
|
|
10
|
+
* node kinds an insert may introduce are element and text only. None of this
|
|
11
|
+
* changes the AST — a draft is a projection of it, and `materializeDelta` is the
|
|
12
|
+
* inverse projection.
|
|
13
|
+
*
|
|
14
|
+
* The last two are not aesthetic choices. Structured output compiles the emitted
|
|
15
|
+
* schema into a grammar with a size ceiling, and the typed prop union 0004
|
|
16
|
+
* specified — repeated at every element at every level — put the schema four
|
|
17
|
+
* times over that ceiling, so no live call ever succeeded. Measured and adopted
|
|
18
|
+
* in 0014, which supersedes 0004.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* A JSON-encoded object of props: `{"tone":"quiet","count":2}`.
|
|
22
|
+
*
|
|
23
|
+
* A string costs the compiled grammar one production no matter how many props it
|
|
24
|
+
* carries or how deeply their values nest, which is what buys back the nesting
|
|
25
|
+
* depth. Nothing is trusted about the contents: `materializeDelta` parses it,
|
|
26
|
+
* requires an object, and validates every value against the JSON value space, so
|
|
27
|
+
* a malformed bag is a `malformed-proposal` rather than something that reaches a
|
|
28
|
+
* tree.
|
|
29
|
+
*/
|
|
30
|
+
export const draftPropsSchema = z.string();
|
|
31
|
+
/**
|
|
32
|
+
* `slot` is absent on purpose. A slot is a projection region a primitive
|
|
33
|
+
* declares, not content an edit adds — §4's catalogue tells a model which slots
|
|
34
|
+
* a primitive has, and slots already in a tree stay addressable, configurable,
|
|
35
|
+
* and projectable. Dropping the third variant is also part of what keeps depth 4
|
|
36
|
+
* affordable.
|
|
37
|
+
*/
|
|
38
|
+
export const draftNodeSchema = z.lazy(() => z.discriminatedUnion("kind", [
|
|
39
|
+
z.object({
|
|
40
|
+
kind: z.literal("element"),
|
|
41
|
+
type: primitiveTypeSchema,
|
|
42
|
+
props: draftPropsSchema,
|
|
43
|
+
children: z.array(draftNodeSchema).readonly(),
|
|
44
|
+
}),
|
|
45
|
+
z.object({ kind: z.literal("text"), value: z.string() }),
|
|
46
|
+
]));
|
|
47
|
+
export const draftOperationSchema = z.discriminatedUnion("op", [
|
|
48
|
+
z.object({
|
|
49
|
+
op: z.literal("insert"),
|
|
50
|
+
parentId: nodeIdSchema,
|
|
51
|
+
index: z.number().int().nonnegative(),
|
|
52
|
+
node: draftNodeSchema,
|
|
53
|
+
}),
|
|
54
|
+
z.object({ op: z.literal("remove"), nodeId: nodeIdSchema }),
|
|
55
|
+
z.object({
|
|
56
|
+
op: z.literal("move"),
|
|
57
|
+
nodeId: nodeIdSchema,
|
|
58
|
+
parentId: nodeIdSchema,
|
|
59
|
+
index: z.number().int().nonnegative(),
|
|
60
|
+
}),
|
|
61
|
+
z.object({
|
|
62
|
+
op: z.literal("configure"),
|
|
63
|
+
nodeId: nodeIdSchema,
|
|
64
|
+
set: draftPropsSchema,
|
|
65
|
+
unset: z.array(z.string()).readonly(),
|
|
66
|
+
}),
|
|
67
|
+
]);
|
|
68
|
+
/**
|
|
69
|
+
* The reply is a three-way outcome rather than a delta, because "I understood
|
|
70
|
+
* you and nothing needs to change" and "I did not understand you" are answers,
|
|
71
|
+
* not failures to answer. Both map onto an `InterpretationError` code; neither
|
|
72
|
+
* is a rejected proposal.
|
|
73
|
+
*/
|
|
74
|
+
export const interpretationReplySchema = z.discriminatedUnion("outcome", [
|
|
75
|
+
z.object({
|
|
76
|
+
outcome: z.literal("change"),
|
|
77
|
+
rationale: z.string().min(1),
|
|
78
|
+
confidence: z.number().min(0).max(1),
|
|
79
|
+
operations: z.array(draftOperationSchema).min(1).readonly(),
|
|
80
|
+
}),
|
|
81
|
+
z.object({ outcome: z.literal("no-change"), rationale: z.string().min(1) }),
|
|
82
|
+
z.object({ outcome: z.literal("not-understood"), rationale: z.string().min(1) }),
|
|
83
|
+
]);
|
|
84
|
+
//# sourceMappingURL=draft.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking a model what to change, and reading the answer.
|
|
3
|
+
*
|
|
4
|
+
* The client seam, the prompt a proposal is built from, and the parse that turns a
|
|
5
|
+
* reply into a delta the tree can be asked to apply — or a refusal that says why
|
|
6
|
+
* it could not be read.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./client.js";
|
|
9
|
+
export * from "./draft.js";
|
|
10
|
+
export * from "./interpreter.js";
|
|
11
|
+
export * from "./materialize.js";
|
|
12
|
+
export * from "./prompt.js";
|
|
13
|
+
export * from "./render.js";
|
|
14
|
+
export * from "./schema.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking a model what to change, and reading the answer.
|
|
3
|
+
*
|
|
4
|
+
* The client seam, the prompt a proposal is built from, and the parse that turns a
|
|
5
|
+
* reply into a delta the tree can be asked to apply — or a refusal that says why
|
|
6
|
+
* it could not be read.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./client.js";
|
|
9
|
+
export * from "./draft.js";
|
|
10
|
+
export * from "./interpreter.js";
|
|
11
|
+
export * from "./materialize.js";
|
|
12
|
+
export * from "./prompt.js";
|
|
13
|
+
export * from "./render.js";
|
|
14
|
+
export * from "./schema.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { IdFactory } from "../ids.js";
|
|
2
|
+
import type { Clock } from "../runtime/events.js";
|
|
3
|
+
import type { ChangeInterpreter, ChangeRepairer } from "../runtime/interpreter.js";
|
|
4
|
+
import type { ModelClient, ModelEffort } from "./client.js";
|
|
5
|
+
import { type PromptVocabularies } from "./prompt.js";
|
|
6
|
+
/**
|
|
7
|
+
* A ChangeInterpreter backed by a model.
|
|
8
|
+
*
|
|
9
|
+
* Every step except the call itself is pure: assemble the prompt, hand it to
|
|
10
|
+
* the client seam, parse what comes back, project it onto a TreeDelta. The
|
|
11
|
+
* distinction the pipeline depends on is preserved here — a reply this module
|
|
12
|
+
* cannot make sense of is an `InterpretationError`, never a proposal the Gate
|
|
13
|
+
* gets to refuse, and never a thrown exception.
|
|
14
|
+
*
|
|
15
|
+
* The delta is authored against the revision the *intent* named, not the tree
|
|
16
|
+
* as it stands now. An intent raised against a tree that has since moved on
|
|
17
|
+
* therefore produces a proposal that fails to apply, which the pipeline reports
|
|
18
|
+
* as `not-applicable` — rather than being quietly re-targeted at a tree the
|
|
19
|
+
* asker never saw.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_INTERPRETER_MODEL = "claude-opus-5";
|
|
22
|
+
export declare const DEFAULT_MAX_TOKENS = 16000;
|
|
23
|
+
export declare const DEFAULT_EFFORT: ModelEffort;
|
|
24
|
+
/**
|
|
25
|
+
* Three minutes, which is long enough that no interpretation this repository has
|
|
26
|
+
* measured comes near it and short enough that a request nobody is ever going to
|
|
27
|
+
* answer is reported while somebody is still looking at the screen.
|
|
28
|
+
*
|
|
29
|
+
* It is a default rather than a constant because the right number is a property
|
|
30
|
+
* of the deployment: a portal with a reader waiting wants less, a batch job
|
|
31
|
+
* rewriting a hundred pages can afford more. What is not a property of the
|
|
32
|
+
* deployment is whether to have one (0140).
|
|
33
|
+
*/
|
|
34
|
+
export declare const DEFAULT_INTERPRETER_CEILING_MS = 180000;
|
|
35
|
+
/**
|
|
36
|
+
* Everything wired once per deployment: how to reach a model, and what to tell
|
|
37
|
+
* it about this deployment. The second half is `PromptVocabularies`, composed
|
|
38
|
+
* rather than restated so that a vocabulary added there reaches a host's wiring
|
|
39
|
+
* and the prompt in the same change (0172).
|
|
40
|
+
*/
|
|
41
|
+
export type ModelInterpreterConfig = PromptVocabularies & {
|
|
42
|
+
readonly client: ModelClient;
|
|
43
|
+
readonly idFactory: IdFactory;
|
|
44
|
+
readonly clock: Clock;
|
|
45
|
+
readonly model?: string;
|
|
46
|
+
readonly maxTokens?: number;
|
|
47
|
+
readonly effort?: ModelEffort;
|
|
48
|
+
/**
|
|
49
|
+
* How long to wait for a reply before reporting that there was not one.
|
|
50
|
+
* Defaults to `DEFAULT_INTERPRETER_CEILING_MS`; there is no way to wait
|
|
51
|
+
* forever, deliberately (0140).
|
|
52
|
+
*/
|
|
53
|
+
readonly ceilingMs?: number;
|
|
54
|
+
readonly draftDepth?: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Implements both seams. Whether a deployment actually repairs is decided by
|
|
58
|
+
* whether this object is also wired in as the runtime's `repairer` — the
|
|
59
|
+
* capability is offered here, but never assumed.
|
|
60
|
+
*/
|
|
61
|
+
export declare const modelInterpreter: (config: ModelInterpreterConfig) => ChangeInterpreter & ChangeRepairer;
|
|
62
|
+
//# sourceMappingURL=interpreter.d.ts.map
|