@smthrs/core 0.0.0-stage → 1.0.0-rc.3

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.
Files changed (124) hide show
  1. package/CHANGELOG.md +189 -0
  2. package/LICENSE +21 -0
  3. package/README.md +107 -2
  4. package/dist/cjs/Annotations.d.ts +114 -0
  5. package/dist/cjs/Annotations.d.ts.map +1 -0
  6. package/dist/cjs/Annotations.js +50 -0
  7. package/dist/cjs/Annotations.js.map +7 -0
  8. package/dist/cjs/Digest.d.ts +46 -0
  9. package/dist/cjs/Digest.d.ts.map +1 -0
  10. package/dist/cjs/Digest.js +46 -0
  11. package/dist/cjs/Digest.js.map +7 -0
  12. package/dist/cjs/Effects.d.ts +29 -0
  13. package/dist/cjs/Effects.d.ts.map +1 -0
  14. package/dist/cjs/Effects.js +29 -0
  15. package/dist/cjs/Effects.js.map +7 -0
  16. package/dist/cjs/Flow.d.ts +4 -0
  17. package/dist/cjs/Flow.d.ts.map +1 -0
  18. package/dist/cjs/Flow.js +29 -0
  19. package/dist/cjs/Flow.js.map +7 -0
  20. package/dist/cjs/Graph.d.ts +15 -0
  21. package/dist/cjs/Graph.d.ts.map +1 -0
  22. package/dist/cjs/Graph.js +19 -0
  23. package/dist/cjs/Graph.js.map +7 -0
  24. package/dist/cjs/KeyMaterial.d.ts +64 -0
  25. package/dist/cjs/KeyMaterial.d.ts.map +1 -0
  26. package/dist/cjs/KeyMaterial.js +17 -0
  27. package/dist/cjs/KeyMaterial.js.map +7 -0
  28. package/dist/cjs/Markdown.d.ts +184 -0
  29. package/dist/cjs/Markdown.d.ts.map +1 -0
  30. package/dist/cjs/Markdown.js +180 -0
  31. package/dist/cjs/Markdown.js.map +7 -0
  32. package/dist/cjs/Node.d.ts +16 -0
  33. package/dist/cjs/Node.d.ts.map +1 -0
  34. package/dist/cjs/Node.js +19 -0
  35. package/dist/cjs/Node.js.map +7 -0
  36. package/dist/cjs/Placement.d.ts +30 -0
  37. package/dist/cjs/Placement.d.ts.map +1 -0
  38. package/dist/cjs/Placement.js +28 -0
  39. package/dist/cjs/Placement.js.map +7 -0
  40. package/dist/cjs/index.d.ts +65 -0
  41. package/dist/cjs/index.d.ts.map +1 -0
  42. package/dist/cjs/index.js +51 -0
  43. package/dist/cjs/index.js.map +7 -0
  44. package/dist/cjs/internal/Signature.d.ts +265 -0
  45. package/dist/cjs/internal/Signature.d.ts.map +1 -0
  46. package/dist/cjs/internal/Signature.js +142 -0
  47. package/dist/cjs/internal/Signature.js.map +7 -0
  48. package/dist/cjs/internal/skillFrontmatter.d.ts +34 -0
  49. package/dist/cjs/internal/skillFrontmatter.d.ts.map +1 -0
  50. package/dist/cjs/internal/skillFrontmatter.js +116 -0
  51. package/dist/cjs/internal/skillFrontmatter.js.map +7 -0
  52. package/dist/cjs/package.json +1 -0
  53. package/dist/esm/Annotations.d.ts +114 -0
  54. package/dist/esm/Annotations.d.ts.map +1 -0
  55. package/dist/esm/Annotations.js +84 -0
  56. package/dist/esm/Annotations.js.map +1 -0
  57. package/dist/esm/Digest.d.ts +46 -0
  58. package/dist/esm/Digest.d.ts.map +1 -0
  59. package/dist/esm/Digest.js +51 -0
  60. package/dist/esm/Digest.js.map +1 -0
  61. package/dist/esm/Effects.d.ts +29 -0
  62. package/dist/esm/Effects.d.ts.map +1 -0
  63. package/dist/esm/Effects.js +22 -0
  64. package/dist/esm/Effects.js.map +1 -0
  65. package/dist/esm/Flow.d.ts +4 -0
  66. package/dist/esm/Flow.d.ts.map +1 -0
  67. package/dist/esm/Flow.js +3 -0
  68. package/dist/esm/Flow.js.map +1 -0
  69. package/dist/esm/Graph.d.ts +15 -0
  70. package/dist/esm/Graph.d.ts.map +1 -0
  71. package/dist/esm/Graph.js +15 -0
  72. package/dist/esm/Graph.js.map +1 -0
  73. package/dist/esm/KeyMaterial.d.ts +64 -0
  74. package/dist/esm/KeyMaterial.d.ts.map +1 -0
  75. package/dist/esm/KeyMaterial.js +19 -0
  76. package/dist/esm/KeyMaterial.js.map +1 -0
  77. package/dist/esm/Markdown.d.ts +184 -0
  78. package/dist/esm/Markdown.d.ts.map +1 -0
  79. package/dist/esm/Markdown.js +248 -0
  80. package/dist/esm/Markdown.js.map +1 -0
  81. package/dist/esm/Node.d.ts +16 -0
  82. package/dist/esm/Node.d.ts.map +1 -0
  83. package/dist/esm/Node.js +16 -0
  84. package/dist/esm/Node.js.map +1 -0
  85. package/dist/esm/Placement.d.ts +30 -0
  86. package/dist/esm/Placement.d.ts.map +1 -0
  87. package/dist/esm/Placement.js +23 -0
  88. package/dist/esm/Placement.js.map +1 -0
  89. package/dist/esm/index.d.ts +65 -0
  90. package/dist/esm/index.d.ts.map +1 -0
  91. package/dist/esm/index.js +65 -0
  92. package/dist/esm/index.js.map +1 -0
  93. package/dist/esm/internal/Signature.d.ts +265 -0
  94. package/dist/esm/internal/Signature.d.ts.map +1 -0
  95. package/dist/esm/internal/Signature.js +176 -0
  96. package/dist/esm/internal/Signature.js.map +1 -0
  97. package/dist/esm/internal/skillFrontmatter.d.ts +34 -0
  98. package/dist/esm/internal/skillFrontmatter.d.ts.map +1 -0
  99. package/dist/esm/internal/skillFrontmatter.js +126 -0
  100. package/dist/esm/internal/skillFrontmatter.js.map +1 -0
  101. package/docs/README.md +111 -0
  102. package/docs/api.md +582 -0
  103. package/docs/concepts/effects.md +112 -0
  104. package/docs/concepts/identity.md +160 -0
  105. package/docs/concepts/plan-time.md +145 -0
  106. package/docs/guides/declare-a-flow.md +102 -0
  107. package/docs/guides/declare-reads-and-writes.md +119 -0
  108. package/docs/guides/load-an-agent-skill.md +168 -0
  109. package/docs/installation.md +89 -0
  110. package/docs/quickstart.md +169 -0
  111. package/docs/troubleshooting.md +247 -0
  112. package/package.json +204 -3
  113. package/src/Annotations.ts +93 -0
  114. package/src/Digest.ts +57 -0
  115. package/src/Effects.ts +30 -0
  116. package/src/Flow.ts +3 -0
  117. package/src/Graph.ts +15 -0
  118. package/src/KeyMaterial.ts +69 -0
  119. package/src/Markdown.ts +355 -0
  120. package/src/Node.ts +16 -0
  121. package/src/Placement.ts +31 -0
  122. package/src/index.ts +73 -0
  123. package/src/internal/Signature.ts +457 -0
  124. package/src/internal/skillFrontmatter.ts +138 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,189 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ### Removed
6
+
7
+ - Removed the object-form `Flow.make(options)` and `Flow.MakeOptions` under
8
+ [RELEASE_SUPPORT.md (MVP compatibility changes)](../../../../RELEASE_SUPPORT.md#mvp-compatibility-changes).
9
+ Replace executable declarations with `Flow.make("tag", { payload, success, body })`
10
+ from `@smthrs/flow`. For host handlers, pass a plain `FlowBinding` record with
11
+ `name`, `input`, `output`, `capabilities` and `effects`. `Flow.isFlow` and
12
+ `Flow.TypeId` remain available for retained Markdown metadata signatures.
13
+
14
+ - Removed `Flow.withCapabilities`, `Flow.sealed` and `Flow.annotateMerge` from
15
+ core's deprecated object-form flow API. Nothing outside this package called
16
+ them. Declare capabilities and effects on the flow itself, or use
17
+ `@smthrs/flow`'s tag-first `Flow.make` with its `annotate` and
18
+ `annotateMerge` methods.
19
+
20
+ ### Added
21
+
22
+ - Added `Graph.maximumGraphNodes`, `Graph.maximumGraphEdges`,
23
+ `Graph.maximumGraphConflicts`, and `Graph.maximumPayloadMembers`, the width
24
+ bounds `Graph.build` enforces alongside its depth bounds, and the
25
+ `plan_too_large` and `payload_too_large` diagnostics they throw.
26
+ - Added `Graph.maximumEffectPaths` and `Graph.maximumPlanEffectPaths`, the
27
+ bounds on the read and write paths one effect declaration may list and on
28
+ the paths admitted across a plan. `Graph.build` refuses either with
29
+ `plan_too_large` naming the node before it copies a path and before the
30
+ write-conflict pass runs.
31
+ - Added `Graph.maximumEffectPathLength` and `Graph.maximumEffectGlobs`, the
32
+ bounds on the length of one effect path (4096 code units, `PATH_MAX`) and on
33
+ the patterns one read or write list may carry (128). `Graph.build` refuses
34
+ either with `plan_too_large` naming the node, or `payload_too_large` for a
35
+ flow placed inside a plan value, reading only the path's length or last
36
+ character, so every per-character cost of a build is bounded by the two
37
+ limits together with `Graph.maximumPlanEffectPaths`.
38
+ - Added `Markdown.validateSkillFrontmatter` and the `Markdown.SkillFrontmatter`
39
+ shape, so a caller holding already-parsed frontmatter can apply the Agent
40
+ Skills rules without a document, and the `skill_invalid_name`,
41
+ `skill_invalid_description`, `skill_invalid_allowed_tools`,
42
+ `skill_invalid_compatibility`, `skill_invalid_metadata`, and
43
+ `skill_invalid_license` error codes.
44
+
45
+ ### Fixed
46
+
47
+ - Fixed `Markdown.parseSkill`, which accepted documents the Agent Skills
48
+ specification forbids: any non-empty `name`, a `description` of any length,
49
+ and a sequence-valued `allowed-tools`. It now enforces the specification's
50
+ name grammar and 64-character limit, the 1024-character description limit
51
+ counted in code points, a scalar `allowed-tools`, and the optional
52
+ `license`, `compatibility`, and `metadata` shapes, each with its own stable
53
+ code. A sequence-valued `allowed-tools` now fails with
54
+ `skill_invalid_allowed_tools` instead of being lowered.
55
+ - Fixed `Graph.build`, which bounded depth but not width, so a shallow plan of
56
+ a few thousand siblings, or one plan value holding an enormous array, could
57
+ exhaust CPU or memory before any documented limit applied. Node, edge,
58
+ conflict, and reflected-member counts are now refused at fixed limits before
59
+ allocation, the write-conflict pass indexes literal writers by path instead
60
+ of comparing every pair, and reachability walks an adjacency index instead
61
+ of every recorded edge.
62
+ - Fixed `Effects.overlaps` and `Effects.narrow`, which compared every path of
63
+ one declaration against every path of the other, so two writers naming the
64
+ same twenty thousand files kept `Graph.build` busy for minutes with no limit
65
+ reached. Both now index exact paths in a set and find the paths a glob
66
+ covers by binary search over the sorted declaration, and `Graph.build`
67
+ bounds the paths it admits. A flow placed inside a plan value now charges
68
+ its effect paths to the member budget instead of copying them unbounded.
69
+ - Fixed `Effects.overlaps`, `Effects.narrow`, and the write-conflict pass,
70
+ whose cost inside the limits still grew with the product of two
71
+ declarations when their patterns nested, because every candidate under a
72
+ pattern's prefix was compared as a string and rescanned for a dot segment:
73
+ two writers of 1024 nested patterns took a second to compare and 16 of them
74
+ minutes to build. Paths are now indexed once per comparison, each scanned
75
+ once for a dot segment and located by rank, nested patterns collapse into
76
+ the outermost, and every match is an integer comparison, so the same pair
77
+ compares in milliseconds and 16 writers of the widest nested declaration
78
+ the limits admit build in well under a second. An envelope is prepared once
79
+ for every node it encloses instead of being re-sorted per node, so a wide
80
+ envelope of long paths narrowed by thousands of nodes builds in under a
81
+ second instead of several. Reachability in the conflict pass is answered
82
+ from a transitive closure computed once, and a graph's conflict and
83
+ diagnostic path lists are frozen in place instead of through allocated
84
+ property descriptors, so the widest shared-literal conflict set the limits
85
+ admit builds in about two seconds instead of eight.
86
+
87
+ ## [1.0.0-rc.0] - 2026-08-31
88
+
89
+ ### Added
90
+
91
+ - Added the Schema-first `Flow` and pipeable `Node` builders, placement and
92
+ effect annotations, markdown lowering, graph introspection, and digest-free
93
+ key-material handoff.
94
+ - Added `Node.priority` and the `Annotations.Priority` key, carried onto the
95
+ graph node and inherited lexically. Priority stays out of key material.
96
+ - Added `Node.catch`, which recovers a node's typed failures with a statically
97
+ planned arm, and `Node.fail`, which re-raises from one.
98
+ - Added `Node.capture`, which folds the inert values a plan-time function closes
99
+ over into deterministic, cross-process function identity. Unannotated
100
+ functions keep process-local identity.
101
+ - Added `Flow.annotate`, which attaches one typed annotation to a flow, and
102
+ `Flow.withFlows`, which replaces the collaborators a flow declares.
103
+ - Added the `Digest` module: the synchronous, SHA-256-only `Crypto` service,
104
+ its layer, `runSync`, `digest`, and `canonical`, delegating to
105
+ `@smthrs/crypto`'s `digestSync` and `syncCrypto` and `@smthrs/canonical`'s
106
+ `Canonical` after `@smthrs/keys/Digest` was deleted.
107
+ - Added `Graph.maximumGraphDepth` and `Graph.maximumPayloadDepth`, the
108
+ documented bounds `Graph.build` enforces instead of overflowing the host
109
+ stack, and `Graph.isFatalDiagnostic`, which reports whether a diagnostic
110
+ blocks `Graph.keyMaterial`.
111
+ - Added the `capability_outside_grant`, `duplicate_node_id`, `invalid_node`,
112
+ `plan_too_deep`, and `payload_too_deep` graph diagnostics, and the
113
+ `unrepresentable_value` node build error.
114
+ - Added `model`, `flows`, and `prompt` to the `Flow` value, so a flow declaring
115
+ collaborators alongside a body reports them and `Flow.withFlows` can rewrite
116
+ them.
117
+ - Exported `Flow.MakeOptions` and `Graph.EdgeReason`, so a consumer can name
118
+ what `Flow.make` and `Flow.agent` accept, and why one node depends on
119
+ another, without reaching for `Parameters<typeof Flow.make>[0]`.
120
+ - Added `TestRuntime`, a pure evaluator for the deferred callbacks in in-memory
121
+ Node declarations. It resolves execution leaves explicitly and can inline
122
+ called flow bodies without pretending to model durable host behavior.
123
+
124
+ ### Fixed
125
+
126
+ - Replaced the provisional `skill_parser_not_implemented` failure with complete
127
+ Agent Skills YAML parsing. Callers now receive the stable
128
+ `skill_missing_frontmatter`, `skill_invalid_frontmatter`,
129
+ `skill_missing_name`, and `skill_missing_description` error codes.
130
+ - Made the plan-value projection injective. A `Date`, `Map`, `Set`, typed array,
131
+ `RegExp`, or `Error` used to reflect to `{}`, every function to one constant
132
+ tag, and two distinct symbols to the same value, so behaviorally different
133
+ plans shared one content step key. Encoder tags are no longer forgeable from a
134
+ user literal, own `__proto__` data properties survive, accessors are recorded
135
+ rather than invoked, and a value the projection cannot represent is refused
136
+ instead of collapsed.
137
+ - Fixed `Node.capture` of an already-captured function, which discarded the
138
+ inner source and captures and produced one digest for every nesting.
139
+ - Fixed `Node.all`, which silently dropped a member named `__proto__`, deleting
140
+ an executable branch with no error.
141
+ - Fixed `Effects.covers` for the universal `**` glob, which matched nothing and
142
+ therefore turned an "anywhere" envelope into a spurious
143
+ `effect_outside_envelope` diagnostic on every child step. A path containing a
144
+ `.` or `..` segment is now never covered, so a declaration can no longer
145
+ escape its own envelope.
146
+ - Fixed `Node.withEffects` on non-work nodes: the declaration was checked and
147
+ projected, then dropped from key material, so two nodes with opposite
148
+ declarations were byte-identical.
149
+ - Fixed `Flow.make`, which discarded `model`, `flows`, and `prompt` whenever
150
+ `body` was present, making every `flows:` declaration in `@smthrs/patterns`
151
+ dead configuration and `Flow.withFlows` a no-op on body flows.
152
+ - Fixed `Flow.make` capability normalization, which disagreed with
153
+ `Flow.withCapabilities`, and the unnamed-flow `name` property, which was an
154
+ own enumerable `undefined`.
155
+ - Fixed `Graph.keyMaterial`, which compiled step keys for a graph the builder
156
+ had already recorded as invalid. Fatal diagnostics now block key material and
157
+ are returned unchanged.
158
+ - Fixed `Node.all` member ordering, which leaked a record literal's insertion
159
+ order into content step keys, and `schemaIdentity`, which collapsed branded
160
+ and annotated schemas onto one empty JSON Schema document.
161
+ - Fixed silent capability attenuation: a capability a callee declares and its
162
+ caller does not grant now records a `capability_outside_grant` diagnostic, and
163
+ a flow called from a bare-node root keeps the capabilities it declares.
164
+ - Fixed envelope-narrowing diagnostics, which omitted the `nodeId` their own
165
+ schema provides.
166
+ - Fixed `Markdown.parseSkill`, whose `extra` record could have its prototype
167
+ replaced by a `__proto__` frontmatter key, and whose invalid-frontmatter
168
+ message echoed the offending source line into a public error.
169
+ - Fixed `Markdown.lowerMarkdown`, which fabricated an empty hermetic envelope
170
+ for a markdown flow that declared none, so the lowered flow stopped
171
+ inheriting its caller's envelope.
172
+ - Replaced raw host `TypeError`s with package-shaped failures for a
173
+ non-function passed to `Node.capture` and a malformed AST passed to
174
+ `Graph.build`, and replaced the host stack overflow on a deep plan with coded
175
+ `plan_too_deep` and `payload_too_deep` diagnostics.
176
+ - Detected colliding structural node ids, which previously dropped a node's key
177
+ material without a word, as a `duplicate_node_id` diagnostic.
178
+
179
+ ### Changed
180
+
181
+ - Bumped graph key material to `flows/key-material/v2` and captured-function
182
+ identity to `sha256-source-captures/v4`, so the hardened reflection and
183
+ capture encodings can never alias keys produced by their predecessors.
184
+ - Graph identity now has explicit encodings for `Option`, `Result`, `Chunk`,
185
+ and `URL` values while continuing to reject unsupported class instances.
186
+
187
+ - A built graph is now deeply frozen, so `Graph.nodes`, `Graph.edges`,
188
+ `Graph.conflicts`, and `Graph.diagnostics` can no longer be used to edit the
189
+ plan being observed.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 William Cory and the Smithers Flows contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,108 @@
1
- # Temporary Holding Version
1
+ # @smthrs/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Release candidate scope, host requirements and compatibility review are defined in the [library support policy](https://github.com/smithersai/smithers/blob/main/RELEASE_SUPPORT.md).
4
+
5
+ This package declares `effect` as an exact
6
+ `4.0.0-rc.115` peer dependency. Keep the application on that version so
7
+ all Smithers packages share one Effect runtime.
8
+
9
+ **Documentation:** https://core.smithers.sh
10
+
11
+ Metadata and compatibility adapters over `@smthrs/flow`. Author flows with its canonical `Flow.make(tag, { payload, success, body })`. Beside that it publishes the metadata projections the registry and execution layers read: annotations, effects, placement, key material, digests, and Markdown lowering. The node model is `@smthrs/plan`'s and the graph builder is `@smthrs/flow`'s; `Node` and `Graph` here are the names this package's consumers reach them through.
12
+
13
+ JavaScript and TypeScript declarations and all planning callbacks must be trusted. `Graph.build` executes flow bodies, `Node.andThen` builders, `Node.catch` recovery callbacks, and an optional `resolveLayers` callback in the caller process with ambient process authority. Purity is a caller obligation, not an enforced boundary. Placement, capability, and effect metadata does not sandbox planning, including sandbox placement, empty capability grants, and sealed effects.
14
+
15
+ For agent-generated declarations, use a constrained data-only ingestion boundary that trusted code validates and translates into nodes, or load and plan untrusted code in an externally isolated environment with restricted permissions and resources. See [Plan time](https://core.smithers.sh/concepts/plan-time/#planning-requires-trusted-declarations).
16
+
17
+ Not on npm yet; see [Installation](https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/flow/docs/installation.md#use-the-libraries).
18
+
19
+ The full API reference lives at [core.smithers.sh/reference/api](https://core.smithers.sh/reference/api/).
20
+
21
+ ## Public API
22
+
23
+ The root entry point exports these namespaces; each is also importable from `@smthrs/core/<Module>`.
24
+
25
+ | Module | Public exports | Description |
26
+ | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
27
+ | `Annotations` | `empty`, `add`, `merge`, `getOption`, `Placement`, `Effects`, `Priority` | Builds and reads typed lexical annotations carried by flows and plan nodes. |
28
+ | `Digest` | `provideSync`, `digest`, `canonical` | Synchronous SHA-256 and canonical JSON for pure identity constructors. |
29
+ | `Effects` | `Declaration`, `NarrowResult`, `make`, `covers`, `narrow`, `overlaps`, `sealed` | Normalizes effect declarations and checks path coverage, narrowing, and conflicts. |
30
+ | `Flow` | `TypeId`, `Flow`, `Any`, `Payload`, `Reference`, `Seat`, `Input`, `Output`, `Error`, `isFlow`, `within`, `annotate`, `withFlows` | Retains Markdown signatures and their metadata combinators. |
31
+ | `Graph` | `build`, `nodes`, `edges`, `drafts`, `diagnostics`, `evaluatedFrom`, `maximumGraphDepth`, `Graph`, `GraphNode`, `Edge`, `EdgeReason`, `LayerRequest`, `BuildOptions` | `@smthrs/flow`'s plan-time graph builder, re-exported. |
32
+ | `KeyMaterial` | `InputRef`, `KeyMaterial`, `Entry` | Defines the stable key projection emitted from a built graph. Types only. |
33
+ | `Markdown` | `splitFrontmatter`, `MarkdownFrontmatter`, `SkillFrontmatter`, `SkillDocument`, `MarkdownErrorCode`, `MarkdownError`, `lowerMarkdown`, `isSkillName`, `validateSkillFrontmatter`, `parseSkill`, `lowerSkill` | Parses and lowers Markdown and Agent Skills declarations to signatures. |
34
+ | `Node` | `TypeId`, `Ast`, `Node`, `Any`, `Success`, `Error`, `CallMode`, `isNode`, `succeed`, `fail`, `all`, `race`, `any`, `quorum`, `map`, `andThen`, `branch`, `catch`, `capture`, `priority`, `declaredPriority`, `bindPlanned`, `plannedReference`, `branchSubject`, `catchSubject`, `catchFilter`, `continuation`, `mapper`, `predicate`, `declaration`, `flowCall`, `actionCall`, `functionIdentity` | `@smthrs/plan`'s inert, pipeable plan AST, re-exported. |
35
+ | `Placement` | `Options`, `Placement`, `local`, `client`, `sandbox`, `remote` | Creates serializable host-placement declarations. |
36
+
37
+ ```ts
38
+ import { Graph, Node, Placement } from "@smthrs/core"
39
+ import { Flow } from "@smthrs/flow"
40
+ import { Schema } from "effect"
41
+
42
+ const greeting = Flow.make("greeting", {
43
+ payload: Schema.Struct({ name: Schema.String }),
44
+ success: Schema.String,
45
+ body: ({ name }) => Node.succeed(`Hello, ${name}`)
46
+ }).annotate(Flow.Placement, Placement.sandbox())
47
+
48
+ const graph = Graph.build(greeting, { name: "world" })
49
+ ```
50
+
51
+ `@smthrs/core/package.json` is also exported. `internal/*` and nested `*/index` subpaths are not public.
52
+
53
+ ## Canonical flows and actions
54
+
55
+ A flow has a required tag, a struct payload schema, a success schema, and a body returning a node. Work a host implements is an explicit action:
56
+
57
+ ```ts
58
+ import { Action } from "@smthrs/flow"
59
+ import { Effect, Schema } from "effect"
60
+
61
+ const read = Action.make("std/read", {
62
+ payload: Schema.Struct({ path: Schema.String }),
63
+ success: Schema.String,
64
+ capabilities: ["fs"],
65
+ tier: "irreversible"
66
+ })
67
+
68
+ const layer = read.toLayer(({ path }) => Effect.succeed(path))
69
+ ```
70
+
71
+ Struct schemas, including `Schema.Class`, can be the canonical payload schema. Calls accept their constructor input.
72
+
73
+ ## Identity and caching
74
+
75
+ `@smthrs/plan` compiles a built graph's digest-free key material into step keys, so two declarations with equal key material are the same step.
76
+
77
+ An unannotated mapper, continuation, or flow body receives a process-local `sha256-source-ephemeral/v4` identity, because JavaScript cannot inspect closure state: two processes give the same function two different digests. Only `Node.capture` produces the cross-process-stable `sha256-source-captures/v5` identity, by folding the canonicalized inert values a function closes over into its digest. A step whose result must survive a restart has to declare its captures.
78
+
79
+ ```ts
80
+ const scaled = Node.capture({ factor: 3 }, (value: number) => value * 3)
81
+ ```
82
+
83
+ An authored captured body retains its identity through core lowering and
84
+ decorators, including the adapter for a non-struct input. An uncaptured body
85
+ remains process-local. Generated action-only wrappers also remain process-local:
86
+ use `Interpreter.layer`, or explicitly select `callbackIdentity: "process-local"`
87
+ when registering them. A stable composition uses authored captured bodies or
88
+ native declarations with explicit capture contracts.
89
+
90
+ Capture data must be finite, inert, plain data. Accessors, cycles, non-finite numbers, symbols, functions, and non-plain prototypes are rejected rather than hashed incompletely, and accepted capture data is copied and deeply frozen. A function expression reads the copy through its `this` receiver; the returned function keeps its ordinary arguments. Caller objects remain unchanged. Built-in brands and Proxies are refused, and object capture requires `structuredClone`. Captures are compared by structural value: two references to one shared object digest identically to two structurally equal copies, so aliasing is not identity.
91
+
92
+ ## Failure behavior
93
+
94
+ Construction failures throw; declaration failures are recorded.
95
+
96
+ | Surface | Failure |
97
+ | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
98
+ | `Node.capture` on a non-function operation or non-inert capture data | throws `TypeError`; a capture-data failure names the offending path in its `Node.capture:`-prefixed message |
99
+ | `Markdown.parseSkill`, `Markdown.lowerSkill`, `Markdown.validateSkillFrontmatter` | returns `Result.fail(MarkdownError)` with code `skill_missing_frontmatter`, `skill_invalid_frontmatter`, `skill_missing_name`, `skill_invalid_name`, `skill_missing_description`, `skill_invalid_description`, `skill_invalid_allowed_tools`, `skill_invalid_compatibility`, `skill_invalid_metadata`, or `skill_invalid_license` |
100
+ | `Graph.build` on an invalid declaration | records a `GraphBuildError` in `Graph.diagnostics`; `@smthrs/flow` documents the codes and which of them are fatal |
101
+
102
+ `Markdown.parseSkill` enforces the intrinsic rules of the Agent Skills specification: a `name` of 1 to 64 lowercase ASCII letters, digits, or single hyphens that does not start or end with a hyphen, a `description` of 1 to 1024 characters counted in code points, a scalar `allowed-tools`, a scalar `license`, a `compatibility` of 1 to 500 characters, and `metadata` mapping string keys to scalar values. `Markdown.validateSkillFrontmatter` applies the same rules to already-parsed frontmatter. The rule that `name` equals the skill directory name needs the file system and stays with `@smthrs/registry`.
103
+
104
+ ## Mutability
105
+
106
+ A compatibility signature is immutable: every combinator returns a fresh one built from the same declaration, and the original keeps the capabilities, annotations, and collaborators it was made with. A collaborator array handed to `Flow.withFlows` is copied, so mutating it afterwards changes nothing.
107
+
108
+ Plan values are not copied. `Node.succeed`, `Node.fail`, and a call retain the caller's value by reference and read it when the graph is built, so mutating one between construction and `Graph.build` changes the recorded identity.
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Typed immutable annotations attached to flow graph values.
3
+ *
4
+ * Governing contract: `packages/smithers/flows/core/docs/api.md`, published as
5
+ * https://smithers.sh/docs/reference/api/core.
6
+ *
7
+ * @since 0.0.0
8
+ */
9
+ import * as PlanEffects from "@smthrs/plan/Effects";
10
+ import { Context, type Option } from "effect";
11
+ /**
12
+ * The empty annotation bag.
13
+ *
14
+ * @category constructors
15
+ * @since 0.0.0
16
+ * @slop
17
+ */
18
+ export declare const empty: Context.Context<never>;
19
+ /**
20
+ * Adds or replaces one annotation without changing the original context.
21
+ *
22
+ * @category adders
23
+ * @since 0.0.0
24
+ * @slop
25
+ */
26
+ export declare const add: {
27
+ <I, S>(key: Context.Key<I, S>, service: import("effect/Types").NoInfer<S>): <Services>(self: Context.Context<Services>) => Context.Context<Services | I>;
28
+ <Services, I, S>(self: Context.Context<Services>, key: Context.Key<I, S>, service: import("effect/Types").NoInfer<S>): Context.Context<Services | I>;
29
+ };
30
+ /**
31
+ * Merges parent and child annotation bags. Child values override parent values
32
+ * for matching keys.
33
+ *
34
+ * @category combining
35
+ * @since 0.0.0
36
+ * @slop
37
+ */
38
+ export declare const merge: (parent: Context.Context<never>, child: Context.Context<never>) => Context.Context<never>;
39
+ /**
40
+ * Safely retrieves an annotation. An absent service key returns `Option.none()`;
41
+ * a `Context.Reference` key supplies its declared default.
42
+ *
43
+ * @category getters
44
+ * @since 0.0.0
45
+ * @slop
46
+ */
47
+ export declare const getOption: <I, S>(context: Context.Context<never>, key: Context.Key<I, S>) => Option.Option<S>;
48
+ /**
49
+ * Annotation key for a node's placement directive.
50
+ *
51
+ * This is `@smthrs/plan`'s `Placement.Annotation`, the ONE key, which
52
+ * `@smthrs/flow` also publishes as `Flow.Placement`. While the two packages
53
+ * each declared a key with its own value type, crossing between them cost a
54
+ * cast in `@smthrs/registry`.
55
+ *
56
+ * @category annotations
57
+ * @since 0.0.0
58
+ * @slop
59
+ */
60
+ export declare const Placement: Context.Service<{
61
+ readonly _tag: "flows/core/Placement/Local";
62
+ } | {
63
+ readonly _tag: "flows/core/Placement/Client";
64
+ } | {
65
+ readonly _tag: "flows/core/Placement/Sandbox";
66
+ readonly image?: string | undefined | undefined;
67
+ readonly profile?: string | undefined | undefined;
68
+ readonly target?: string | undefined | undefined;
69
+ } | {
70
+ readonly _tag: "flows/core/Placement/Remote";
71
+ readonly image?: string | undefined | undefined;
72
+ readonly profile?: string | undefined | undefined;
73
+ readonly target?: string | undefined | undefined;
74
+ }, {
75
+ readonly _tag: "flows/core/Placement/Local";
76
+ } | {
77
+ readonly _tag: "flows/core/Placement/Client";
78
+ } | {
79
+ readonly _tag: "flows/core/Placement/Sandbox";
80
+ readonly image?: string | undefined | undefined;
81
+ readonly profile?: string | undefined | undefined;
82
+ readonly target?: string | undefined | undefined;
83
+ } | {
84
+ readonly _tag: "flows/core/Placement/Remote";
85
+ readonly image?: string | undefined | undefined;
86
+ readonly profile?: string | undefined | undefined;
87
+ readonly target?: string | undefined | undefined;
88
+ }>;
89
+ /**
90
+ * Annotation key for a flow or node effect declaration.
91
+ *
92
+ * This is `@smthrs/plan`'s `Effects.Envelope`, the ONE key, which
93
+ * `@smthrs/flow` also publishes as `Flow.EffectEnvelope`. While the two
94
+ * packages each declared their own key a flow annotated for one graph builder
95
+ * was invisible to the other.
96
+ *
97
+ * @category annotations
98
+ * @since 0.0.0
99
+ * @slop
100
+ */
101
+ export declare const Effects: Context.Service<PlanEffects.Declaration, PlanEffects.Declaration>;
102
+ /**
103
+ * Annotation key for a node's scheduling priority.
104
+ *
105
+ * The value is a signed integer that orders ready work: a scheduler runs a
106
+ * higher number before a lower one. Priority is a scheduling hint, never part
107
+ * of step identity, so raising it never invalidates a cached step.
108
+ *
109
+ * @category annotations
110
+ * @since 0.1.0
111
+ * @slop
112
+ */
113
+ export declare const Priority: Context.Service<number, number>;
114
+ //# sourceMappingURL=Annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Annotations.d.ts","sourceRoot":"","sources":["../../src/Annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AAEnD,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAmB,CAAA;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,GAAG;;;CAAc,CAAA;AAE9B;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAC7E,CAAA;AAE9B;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,SAAS,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CACxE,CAAA;AAEjC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA2B,CAAA;AAEjD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,mEAAuB,CAAA;AAE3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,iCAA6D,CAAA"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var Annotations_exports = {};
30
+ __export(Annotations_exports, {
31
+ Effects: () => Effects,
32
+ Placement: () => Placement,
33
+ Priority: () => Priority,
34
+ add: () => add,
35
+ empty: () => empty,
36
+ getOption: () => getOption,
37
+ merge: () => merge
38
+ });
39
+ module.exports = __toCommonJS(Annotations_exports);
40
+ var PlanEffects = __toESM(require("@smthrs/plan/Effects"), 1);
41
+ var PlanPlacement = __toESM(require("@smthrs/plan/Placement"), 1);
42
+ var import_effect = require("effect");
43
+ const empty = import_effect.Context.empty();
44
+ const add = import_effect.Context.add;
45
+ const merge = (parent, child) => import_effect.Context.merge(parent, child);
46
+ const getOption = (context, key) => import_effect.Context.getOption(context, key);
47
+ const Placement = PlanPlacement.Annotation;
48
+ const Effects = PlanEffects.Envelope;
49
+ const Priority = import_effect.Context.Service("flows/core/Annotations/Priority");
50
+ //# sourceMappingURL=Annotations.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Annotations.ts"],
4
+ "sourcesContent": ["/**\n * Typed immutable annotations attached to flow graph values.\n *\n * Governing contract: `packages/smithers/flows/core/docs/api.md`, published as\n * https://smithers.sh/docs/reference/api/core.\n *\n * @since 0.0.0\n */\n\nimport * as PlanEffects from \"@smthrs/plan/Effects\"\nimport * as PlanPlacement from \"@smthrs/plan/Placement\"\nimport { Context, type Option } from \"effect\"\n\n/**\n * The empty annotation bag.\n *\n * @category constructors\n * @since 0.0.0\n * @slop\n */\nexport const empty: Context.Context<never> = Context.empty()\n\n/**\n * Adds or replaces one annotation without changing the original context.\n *\n * @category adders\n * @since 0.0.0\n * @slop\n */\nexport const add = Context.add\n\n/**\n * Merges parent and child annotation bags. Child values override parent values\n * for matching keys.\n *\n * @category combining\n * @since 0.0.0\n * @slop\n */\nexport const merge = (parent: Context.Context<never>, child: Context.Context<never>): Context.Context<never> =>\n Context.merge(parent, child)\n\n/**\n * Safely retrieves an annotation. An absent service key returns `Option.none()`;\n * a `Context.Reference` key supplies its declared default.\n *\n * @category getters\n * @since 0.0.0\n * @slop\n */\nexport const getOption = <I, S>(context: Context.Context<never>, key: Context.Key<I, S>): Option.Option<S> =>\n Context.getOption(context, key)\n\n/**\n * Annotation key for a node's placement directive.\n *\n * This is `@smthrs/plan`'s `Placement.Annotation`, the ONE key, which\n * `@smthrs/flow` also publishes as `Flow.Placement`. While the two packages\n * each declared a key with its own value type, crossing between them cost a\n * cast in `@smthrs/registry`.\n *\n * @category annotations\n * @since 0.0.0\n * @slop\n */\nexport const Placement = PlanPlacement.Annotation\n\n/**\n * Annotation key for a flow or node effect declaration.\n *\n * This is `@smthrs/plan`'s `Effects.Envelope`, the ONE key, which\n * `@smthrs/flow` also publishes as `Flow.EffectEnvelope`. While the two\n * packages each declared their own key a flow annotated for one graph builder\n * was invisible to the other.\n *\n * @category annotations\n * @since 0.0.0\n * @slop\n */\nexport const Effects = PlanEffects.Envelope\n\n/**\n * Annotation key for a node's scheduling priority.\n *\n * The value is a signed integer that orders ready work: a scheduler runs a\n * higher number before a lower one. Priority is a scheduling hint, never part\n * of step identity, so raising it never invalidates a cached step.\n *\n * @category annotations\n * @since 0.1.0\n * @slop\n */\nexport const Priority = Context.Service<number>(\"flows/core/Annotations/Priority\")\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,kBAA6B;AAC7B,oBAA+B;AAC/B,oBAAqC;AAS9B,MAAM,QAAgC,sBAAQ,MAAM;AASpD,MAAM,MAAM,sBAAQ;AAUpB,MAAM,QAAQ,CAAC,QAAgC,UACpD,sBAAQ,MAAM,QAAQ,KAAK;AAUtB,MAAM,YAAY,CAAO,SAAiC,QAC/D,sBAAQ,UAAU,SAAS,GAAG;AAczB,MAAM,YAAY,cAAc;AAchC,MAAM,UAAU,YAAY;AAa5B,MAAM,WAAW,sBAAQ,QAAgB,iCAAiC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Synchronous identity construction.
3
+ *
4
+ * The agent side computes content fingerprints inside *pure, synchronous*
5
+ * constructors: a prompt section's identity, a context-window segment, a
6
+ * cell's source digest, a plan card's digest. `@smthrs/crypto` now owns that
7
+ * policy and its only handwritten implementation. This module delegates to
8
+ * `digestSync`.
9
+ *
10
+ * The digest is therefore the *same digest*: same canonical bytes, same hash,
11
+ * same hexadecimal encoding, just reached without suspending. `Digest.test.ts`
12
+ * pins that equivalence against the platform Crypto layer.
13
+ *
14
+ * @since 0.1.0
15
+ */
16
+ import * as Crypto from "effect/Crypto";
17
+ import * as Effect from "effect/Effect";
18
+ /**
19
+ * Provides the synchronous SHA-256 service to an Effect-shaped derivation.
20
+ *
21
+ * @category hashing
22
+ * @since 1.0.0
23
+ */
24
+ export declare const provideSync: <A, E>(effect: Effect.Effect<A, E, Crypto.Crypto>) => Effect.Effect<A, E>;
25
+ /**
26
+ * Returns the full lowercase SHA-256 digest of UTF-8 string or byte input.
27
+ *
28
+ * @category hashing
29
+ * @since 0.1.0
30
+ * @slop
31
+ */
32
+ export declare const digest: (input: string | Uint8Array) => import("@smthrs/crypto").Digest;
33
+ /**
34
+ * Returns the RFC 8785 canonical JSON serialization of a value.
35
+ *
36
+ * A function, symbol, `bigint`, cyclic object, non-finite number, or top-level
37
+ * `undefined` has no canonical JSON representation. For those values this
38
+ * throws the `SchemaError` from `effect/Schema` raised through
39
+ * `Effect.runSync`; the canonical package's failure is not wrapped.
40
+ *
41
+ * @category serialization
42
+ * @since 0.1.0
43
+ * @slop
44
+ */
45
+ export declare const canonical: (value: unknown) => string;
46
+ //# sourceMappingURL=Digest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Digest.d.ts","sourceRoot":"","sources":["../../src/Digest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CACvC,CAAA;AAM1D;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,iEAAa,CAAA;AAEhC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,MAAyC,CAAA"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var Digest_exports = {};
30
+ __export(Digest_exports, {
31
+ canonical: () => canonical,
32
+ digest: () => digest,
33
+ provideSync: () => provideSync
34
+ });
35
+ module.exports = __toCommonJS(Digest_exports);
36
+ var import_canonical = require("@smthrs/canonical");
37
+ var import_crypto = require("@smthrs/crypto");
38
+ var Crypto = __toESM(require("effect/Crypto"), 1);
39
+ var Effect = __toESM(require("effect/Effect"), 1);
40
+ var Schema = __toESM(require("effect/Schema"), 1);
41
+ const provideSync = (effect) => Effect.provideService(effect, Crypto.Crypto, import_crypto.syncCrypto);
42
+ const runSync = (effect) => Effect.runSync(provideSync(effect));
43
+ const decodeCanonical = Schema.decodeUnknownEffect(import_canonical.Canonical);
44
+ const digest = import_crypto.digestSync;
45
+ const canonical = (value) => runSync(decodeCanonical(value));
46
+ //# sourceMappingURL=Digest.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Digest.ts"],
4
+ "sourcesContent": ["/**\n * Synchronous identity construction.\n *\n * The agent side computes content fingerprints inside *pure, synchronous*\n * constructors: a prompt section's identity, a context-window segment, a\n * cell's source digest, a plan card's digest. `@smthrs/crypto` now owns that\n * policy and its only handwritten implementation. This module delegates to\n * `digestSync`.\n *\n * The digest is therefore the *same digest*: same canonical bytes, same hash,\n * same hexadecimal encoding, just reached without suspending. `Digest.test.ts`\n * pins that equivalence against the platform Crypto layer.\n *\n * @since 0.1.0\n */\n\nimport { Canonical } from \"@smthrs/canonical\"\nimport { digestSync, syncCrypto } from \"@smthrs/crypto\"\nimport * as Crypto from \"effect/Crypto\"\nimport * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\n\n/**\n * Provides the synchronous SHA-256 service to an Effect-shaped derivation.\n *\n * @category hashing\n * @since 1.0.0\n */\nexport const provideSync = <A, E>(effect: Effect.Effect<A, E, Crypto.Crypto>): Effect.Effect<A, E> =>\n Effect.provideService(effect, Crypto.Crypto, syncCrypto)\n\nconst runSync = <A, E>(effect: Effect.Effect<A, E, Crypto.Crypto>): A => Effect.runSync(provideSync(effect))\n\nconst decodeCanonical = Schema.decodeUnknownEffect(Canonical)\n\n/**\n * Returns the full lowercase SHA-256 digest of UTF-8 string or byte input.\n *\n * @category hashing\n * @since 0.1.0\n * @slop\n */\nexport const digest = digestSync\n\n/**\n * Returns the RFC 8785 canonical JSON serialization of a value.\n *\n * A function, symbol, `bigint`, cyclic object, non-finite number, or top-level\n * `undefined` has no canonical JSON representation. For those values this\n * throws the `SchemaError` from `effect/Schema` raised through\n * `Effect.runSync`; the canonical package's failure is not wrapped.\n *\n * @category serialization\n * @since 0.1.0\n * @slop\n */\nexport const canonical = (value: unknown): string => runSync(decodeCanonical(value))\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,uBAA0B;AAC1B,oBAAuC;AACvC,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AAQjB,MAAM,cAAc,CAAO,WAChC,OAAO,eAAe,QAAQ,OAAO,QAAQ,wBAAU;AAEzD,MAAM,UAAU,CAAO,WAAkD,OAAO,QAAQ,YAAY,MAAM,CAAC;AAE3G,MAAM,kBAAkB,OAAO,oBAAoB,0BAAS;AASrD,MAAM,SAAS;AAcf,MAAM,YAAY,CAAC,UAA2B,QAAQ,gBAAgB,KAAK,CAAC;",
6
+ "names": []
7
+ }