@younndai/lyt-runner 0.9.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.
Files changed (64) hide show
  1. package/LICENSE +200 -0
  2. package/NOTICE +23 -0
  3. package/README.md +110 -0
  4. package/dist/expander/automator-to-agent.d.ts +4 -0
  5. package/dist/expander/automator-to-agent.d.ts.map +1 -0
  6. package/dist/expander/automator-to-agent.js +129 -0
  7. package/dist/expander/automator-to-agent.js.map +1 -0
  8. package/dist/expander/index.d.ts +17 -0
  9. package/dist/expander/index.d.ts.map +1 -0
  10. package/dist/expander/index.js +62 -0
  11. package/dist/expander/index.js.map +1 -0
  12. package/dist/expander/parse-record.d.ts +10 -0
  13. package/dist/expander/parse-record.d.ts.map +1 -0
  14. package/dist/expander/parse-record.js +162 -0
  15. package/dist/expander/parse-record.js.map +1 -0
  16. package/dist/expander/types.d.ts +39 -0
  17. package/dist/expander/types.d.ts.map +1 -0
  18. package/dist/expander/types.js +17 -0
  19. package/dist/expander/types.js.map +1 -0
  20. package/dist/hooks/frontmatter.d.ts +10 -0
  21. package/dist/hooks/frontmatter.d.ts.map +1 -0
  22. package/dist/hooks/frontmatter.js +90 -0
  23. package/dist/hooks/frontmatter.js.map +1 -0
  24. package/dist/hooks/stamp-on-write.d.ts +43 -0
  25. package/dist/hooks/stamp-on-write.d.ts.map +1 -0
  26. package/dist/hooks/stamp-on-write.js +289 -0
  27. package/dist/hooks/stamp-on-write.js.map +1 -0
  28. package/dist/index.d.ts +21 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +96 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/ops/index.d.ts +24 -0
  33. package/dist/ops/index.d.ts.map +1 -0
  34. package/dist/ops/index.js +56 -0
  35. package/dist/ops/index.js.map +1 -0
  36. package/dist/ops/leases.d.ts +28 -0
  37. package/dist/ops/leases.d.ts.map +1 -0
  38. package/dist/ops/leases.js +93 -0
  39. package/dist/ops/leases.js.map +1 -0
  40. package/dist/ops/llm.d.ts +28 -0
  41. package/dist/ops/llm.d.ts.map +1 -0
  42. package/dist/ops/llm.js +132 -0
  43. package/dist/ops/llm.js.map +1 -0
  44. package/dist/ops/mesh.d.ts +11 -0
  45. package/dist/ops/mesh.d.ts.map +1 -0
  46. package/dist/ops/mesh.js +35 -0
  47. package/dist/ops/mesh.js.map +1 -0
  48. package/dist/ops/vault.d.ts +26 -0
  49. package/dist/ops/vault.d.ts.map +1 -0
  50. package/dist/ops/vault.js +153 -0
  51. package/dist/ops/vault.js.map +1 -0
  52. package/dist/protocol/five-step.d.ts +22 -0
  53. package/dist/protocol/five-step.d.ts.map +1 -0
  54. package/dist/protocol/five-step.js +312 -0
  55. package/dist/protocol/five-step.js.map +1 -0
  56. package/dist/protocol/run-context.d.ts +35 -0
  57. package/dist/protocol/run-context.d.ts.map +1 -0
  58. package/dist/protocol/run-context.js +56 -0
  59. package/dist/protocol/run-context.js.map +1 -0
  60. package/dist/runtime.d.ts +18 -0
  61. package/dist/runtime.d.ts.map +1 -0
  62. package/dist/runtime.js +28 -0
  63. package/dist/runtime.js.map +1 -0
  64. package/package.json +74 -0
@@ -0,0 +1,289 @@
1
+ /*
2
+ * Copyright 2026 MARLINK TRADING SRL (YounndAI)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // Pre-write @STAMP hook — auto-injects provenance + audit_log entries
17
+ // whenever an automator writes to a vault filesystem path.
18
+ //
19
+ // Per arc-thoughts §11.4 (LOCKED 2026-05-27), every automator-driven write
20
+ // follows the 6-step contract:
21
+ // 1. Compute content hash (sha256) of what's about to be written
22
+ // 2. Build the provenance entry (src + method + confidence + hash +
23
+ // tokens + cost + model)
24
+ // 3. Markdown writes → update `last_provenance:` frontmatter scalar
25
+ // YON declaration writes → prepend an inline `@STAMP` record
26
+ // 4. Write the file
27
+ // 5. INSERT the provenance row into the per-vault libSQL `provenance` table
28
+ // 6. INSERT an `audit_log` row with `action='automator.write'`,
29
+ // `target_id = provenance.id` (hex)
30
+ //
31
+ // Per arc-thoughts §11.6 the hook fires ONLY under an active automator-run
32
+ // context — handler-written notes (e.g. /lyt-capture, manual edits) pass
33
+ // `runContext: null` and the hook then performs an inert fs write with no
34
+ // provenance recording. This is the "don't @STAMP every keystroke" guard.
35
+ //
36
+ // The hook DOES NOT monkey-patch fs. Automator bodies invoke the
37
+ // `writeMarkdownWithStamp` / `writeYonWithStamp` helpers explicitly; if a
38
+ // body calls `fs.writeFileSync` directly it bypasses the hook (and the
39
+ // brief tolerates that — the body is misbehaving and won't get
40
+ // provenance). This keeps the hook scoped + testable per arc §11.6.
41
+ import { createHash } from "node:crypto";
42
+ import { mkdirSync, writeFileSync } from "node:fs";
43
+ import { dirname, relative, sep, posix } from "node:path";
44
+ import { appendLedgerRecord, closeVaultDb, incrementVaultWritesCount, insertAutomatorWriteAuditLog, newUuidv7Bytes, openLedgerDb, recordProvenance, } from "@younndai/lyt-vault";
45
+ import { upsertLastProvenance } from "./frontmatter.js";
46
+ // v1.A.2 Lock 0.2 — emit `@AUDIT` companion record to ledger
47
+ // when the hook fires under a vaultRoot-aware run. Mirror of
48
+ // `flows/friction.ts` shape. Direct ledger append (not via `recordAudit`)
49
+ // because we have no audit_log row to mirror — the audit row is emitted by
50
+ // `insertAutomatorWriteAuditLog` separately.
51
+ //
52
+ // v1.A.2c DB SPLIT: post-split, the `vaultDb` parameter is semantically the
53
+ // lyt.db client (carries automator_runs / automator_run_events for the
54
+ // incrementVaultWritesCount call). The hook opens audit.db + provenance.db
55
+ // internally per write call — this is the simplest signature-compatible
56
+ // migration but pays a Windows file-lock cost (~400ms × open/close pair)
57
+ // per fired stamp. Threading three clients through the hook signature is
58
+ // a v1.A.3 optimisation candidate (faster batch performance, larger
59
+ // signature change).
60
+ import { join as pathJoin } from "node:path";
61
+ // ---------------------------------------------------------------------------
62
+ // Markdown writer — upserts `last_provenance:` frontmatter scalar.
63
+ // ---------------------------------------------------------------------------
64
+ export async function writeMarkdownWithStamp(runContext, vaultDb, args) {
65
+ const hash = sha256(args.content);
66
+ const tsMs = runContext?.startedAt ?? Date.now();
67
+ const ts = new Date(tsMs).toISOString();
68
+ // §11.6 guard — handler-written notes get an inert pass-through.
69
+ if (runContext === null || vaultDb === null) {
70
+ ensureParentDir(args.path);
71
+ writeFileSync(args.path, args.content, "utf8");
72
+ return { provenanceId: null, hash, ts, fired: false };
73
+ }
74
+ // Step 3a — upsert last_provenance: line into the frontmatter.
75
+ const mutated = upsertLastProvenance(args.content, {
76
+ src: args.stamp.src,
77
+ ts,
78
+ ...(args.stamp.method !== undefined ? { method: args.stamp.method } : {}),
79
+ ...(args.stamp.confidence !== undefined ? { confidence: args.stamp.confidence } : {}),
80
+ hash: `sha256:${hash}`,
81
+ });
82
+ // Step 4 — write the file.
83
+ ensureParentDir(args.path);
84
+ writeFileSync(args.path, mutated, "utf8");
85
+ // Steps 5+6 — record provenance + audit via the split-DB primitive.
86
+ const provenanceId = newUuidv7Bytes();
87
+ const targetId = computeTargetId(args.path, args.vaultRoot);
88
+ await emitProvenanceAndAudit({
89
+ runContext,
90
+ vaultDb,
91
+ args,
92
+ provenanceId,
93
+ targetId,
94
+ targetKind: "note",
95
+ targetType: "note",
96
+ hash,
97
+ ts,
98
+ tsMs,
99
+ });
100
+ return { provenanceId, hash, ts, fired: true };
101
+ }
102
+ // ---------------------------------------------------------------------------
103
+ // YON declaration writer — prepends an inline `@STAMP` record.
104
+ // ---------------------------------------------------------------------------
105
+ export async function writeYonWithStamp(runContext, vaultDb, args) {
106
+ const hash = sha256(args.content);
107
+ const tsMs = runContext?.startedAt ?? Date.now();
108
+ const ts = new Date(tsMs).toISOString();
109
+ if (runContext === null || vaultDb === null) {
110
+ ensureParentDir(args.path);
111
+ writeFileSync(args.path, args.content, "utf8");
112
+ return { provenanceId: null, hash, ts, fired: false };
113
+ }
114
+ // Step 3b — prepend an inline @STAMP record. Per arc §11.4 step 4 the
115
+ // stamp goes BEFORE the new top-level tag. We treat the content payload
116
+ // as the "new top-level tag" — emit @STAMP first, then the content.
117
+ const stampLine = formatYonStampRecord({
118
+ ts,
119
+ src: args.stamp.src,
120
+ ...(args.stamp.method !== undefined ? { method: args.stamp.method } : {}),
121
+ ...(args.stamp.confidence !== undefined ? { confidence: args.stamp.confidence } : {}),
122
+ hash: `sha256:${hash}`,
123
+ ...(args.stamp.tokens !== undefined ? { tokens: args.stamp.tokens } : {}),
124
+ ...(args.stamp.costUsd !== undefined ? { costUsd: args.stamp.costUsd } : {}),
125
+ ...(args.stamp.model !== undefined ? { model: args.stamp.model } : {}),
126
+ });
127
+ const mutated = `${stampLine}\n\n${args.content}`;
128
+ ensureParentDir(args.path);
129
+ writeFileSync(args.path, mutated, "utf8");
130
+ const provenanceId = newUuidv7Bytes();
131
+ const targetId = computeTargetId(args.path, args.vaultRoot);
132
+ await emitProvenanceAndAudit({
133
+ runContext,
134
+ vaultDb,
135
+ args,
136
+ provenanceId,
137
+ targetId,
138
+ targetKind: "declaration",
139
+ targetType: "declaration",
140
+ hash,
141
+ ts,
142
+ tsMs,
143
+ });
144
+ return { provenanceId, hash, ts, fired: true };
145
+ }
146
+ async function emitProvenanceAndAudit(p) {
147
+ const { runContext, vaultDb, args, provenanceId, targetId, targetKind, targetType, hash, ts, tsMs, } = p;
148
+ const vaultRoot = args.vaultRoot;
149
+ if (vaultRoot === undefined || vaultRoot.length === 0) {
150
+ throw new Error("lyt-runner pre-write hook requires args.vaultRoot post-v1.A.2c DB SPLIT (no libSQL-only fallback).");
151
+ }
152
+ const provenanceArgs = {
153
+ id: provenanceId,
154
+ targetType,
155
+ targetId,
156
+ ts: tsMs,
157
+ src: args.stamp.src,
158
+ ...(args.stamp.method !== undefined ? { method: args.stamp.method } : {}),
159
+ ...(args.stamp.confidence !== undefined ? { confidence: args.stamp.confidence } : {}),
160
+ hash: `sha256:${hash}`,
161
+ ...(args.stamp.tokens !== undefined ? { tokens: args.stamp.tokens } : {}),
162
+ ...(args.stamp.costUsd !== undefined ? { costUsd: args.stamp.costUsd } : {}),
163
+ ...(args.stamp.model !== undefined ? { model: args.stamp.model } : {}),
164
+ ...(args.stamp.details !== undefined ? { details: args.stamp.details } : {}),
165
+ };
166
+ // v1.A.3 (CR-3 / ALT5 + CR-4 / OPT-1): when the caller threaded open
167
+ // ledger clients via args.ledgerClients, reuse them and skip the
168
+ // per-call open/close pair (~400ms × 2 saved on Windows file-lock).
169
+ // Otherwise fall back to opening + closing our own pair via the
170
+ // registry-routed openLedgerDb factory. The provenance + audit
171
+ // emission itself stays content-coupled (audit row carries
172
+ // provenance id_hex as target_id) — only the DB lifecycle is
173
+ // optimised.
174
+ const threaded = args.ledgerClients;
175
+ const provenanceDb = threaded !== undefined ? threaded.provenanceDb : await openLedgerDb(vaultRoot, "provenance");
176
+ const auditDb = threaded !== undefined ? threaded.auditDb : await openLedgerDb(vaultRoot, "audit");
177
+ try {
178
+ // Provenance: YON-first (recordProvenance wrapper enforces Lock 0.2).
179
+ await recordProvenance(vaultRoot, provenanceDb, {
180
+ ...provenanceArgs,
181
+ stampSrc: "lyt-runner/pre-write-hook",
182
+ });
183
+ // Audit: also YON-first per Lock 0.2 (v1.A.2d release review fold — the
184
+ // previous order ran insertAutomatorWriteAuditLog BEFORE
185
+ // appendLedgerRecord, which would orphan a row in audit.db if the YON
186
+ // append failed; rebuild-index --ledger audit walks YON and would
187
+ // never re-inject the orphan). YON failure is fatal; audit.db upsert
188
+ // failure (next step) is logged + non-fatal — symmetric with
189
+ // recordProvenance / recordAudit semantics.
190
+ const provenanceIdHex = Buffer.from(provenanceId).toString("hex");
191
+ appendLedgerRecord({
192
+ ledgerPath: pathJoin(vaultRoot, ".lyt", "ledgers", "audit.yon"),
193
+ ledgerName: "audit",
194
+ recordType: "AUDIT",
195
+ fields: [
196
+ ["ts", ts],
197
+ ["actor", args.stamp.src],
198
+ ["action", "automator.write"],
199
+ ["target_type", "provenance"],
200
+ ["target_id", provenanceIdHex],
201
+ ["result", "success"],
202
+ [
203
+ "details_json",
204
+ JSON.stringify({
205
+ target_path: targetId,
206
+ target_kind: targetKind,
207
+ run_id_hex: bytesToHex(runContext.runId),
208
+ }),
209
+ ],
210
+ ],
211
+ stampSrc: "lyt-runner/pre-write-hook",
212
+ ts,
213
+ });
214
+ const auditId = newUuidv7Bytes();
215
+ try {
216
+ await insertAutomatorWriteAuditLog(auditDb, {
217
+ id: auditId,
218
+ ts: tsMs,
219
+ actor: args.stamp.src,
220
+ provenanceId,
221
+ targetPath: targetId,
222
+ details: { target_kind: targetKind, run_id_hex: bytesToHex(runContext.runId) },
223
+ });
224
+ }
225
+ catch (err) {
226
+ // .db cache write failed but YON SoT is already on disk; log + continue
227
+ // per the recordAudit / recordProvenance contract. rebuild-index
228
+ // --ledger audit reconstructs from audit.yon.
229
+ // eslint-disable-next-line no-console
230
+ console.warn("lyt-runner pre-write hook: audit.db upsert failed (YON SoT preserved); recoverable via rebuild-index --ledger audit", err);
231
+ }
232
+ // Bump the per-run vault_writes_count so automator_runs telemetry stays
233
+ // accurate without the caller having to manage it. Uses the lyt.db
234
+ // client the caller threaded through.
235
+ await incrementVaultWritesCount(vaultDb, runContext.runId);
236
+ }
237
+ finally {
238
+ // OPT-1: only close DBs we opened ourselves. When the caller threaded
239
+ // pre-opened clients, they own the lifecycle.
240
+ if (threaded === undefined) {
241
+ await closeVaultDb(auditDb);
242
+ await closeVaultDb(provenanceDb);
243
+ }
244
+ }
245
+ }
246
+ export function formatYonStampRecord(args) {
247
+ // Mirrors yai-domain L399-402 + arc-thoughts §11.4 surface. ts is typed
248
+ // (`ts:ts=...`) per YON spec L385; confidence is float; tokens is int.
249
+ // Cost is float; model is a quoted string.
250
+ const parts = [`@STAMP ts:ts=${args.ts}`, `src="${args.src}"`];
251
+ if (args.method !== undefined)
252
+ parts.push(`method=${args.method}`);
253
+ if (args.confidence !== undefined)
254
+ parts.push(`confidence:float=${args.confidence}`);
255
+ if (args.hash !== undefined)
256
+ parts.push(`hash="${args.hash}"`);
257
+ if (args.tokens !== undefined)
258
+ parts.push(`tokens:int=${args.tokens}`);
259
+ if (args.costUsd !== undefined)
260
+ parts.push(`cost:float=${args.costUsd}`);
261
+ if (args.model !== undefined)
262
+ parts.push(`model="${args.model}"`);
263
+ return parts.join(" | ");
264
+ }
265
+ // ---------------------------------------------------------------------------
266
+ // Helpers
267
+ // ---------------------------------------------------------------------------
268
+ function sha256(content) {
269
+ return createHash("sha256").update(content, "utf8").digest("hex");
270
+ }
271
+ function ensureParentDir(absPath) {
272
+ const parent = dirname(absPath);
273
+ if (parent.length === 0)
274
+ return;
275
+ mkdirSync(parent, { recursive: true });
276
+ }
277
+ function computeTargetId(absPath, vaultRoot) {
278
+ if (vaultRoot === undefined || vaultRoot.length === 0)
279
+ return absPath;
280
+ const rel = relative(vaultRoot, absPath);
281
+ // Normalize to posix separators so the stored target_id is portable
282
+ // across OSes — registered paths grep cleanly on Linux even when written
283
+ // on Windows.
284
+ return rel.split(sep).join(posix.sep);
285
+ }
286
+ function bytesToHex(bytes) {
287
+ return Buffer.from(bytes).toString("hex");
288
+ }
289
+ //# sourceMappingURL=stamp-on-write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stamp-on-write.js","sourceRoot":"","sources":["../../src/hooks/stamp-on-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,sEAAsE;AACtE,2DAA2D;AAC3D,EAAE;AACF,2EAA2E;AAC3E,+BAA+B;AAC/B,iEAAiE;AACjE,oEAAoE;AACpE,yBAAyB;AACzB,oEAAoE;AACpE,6DAA6D;AAC7D,oBAA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AC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAChC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,eAAe,CAAC,OAAe,EAAE,SAA6B;IACrE,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACtE,MAAM,GAAG,GAAG,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACzC,oEAAoE;IACpE,yEAAyE;IACzE,cAAc;IACd,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,UAAU,CAAC,KAAiB;IACnC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type Runner, type RunnerConfig } from "@younndai/yon-runner";
2
+ import type { LytRuntime } from "./runtime.js";
3
+ export interface LytRunnerConfig extends RunnerConfig {
4
+ runtime?: LytRuntime;
5
+ }
6
+ export declare function createLytRunner(config?: LytRunnerConfig): Runner;
7
+ export { lytExpand, parseAutomator, parseDirective, automatorToAgentRecords, ExpanderError, } from "./expander/index.js";
8
+ export type { ExpandOptions, ExpandResult, AutomatorRecord, DirectiveRecord, AutomatorArchetype, AutomatorRuntime, AutomatorScope, AutomatorSource, AutomatorTransactionMode, } from "./expander/index.js";
9
+ export { LYT_OPS, LYT_OPS_NAMESPACE, LYT_OPS_VERSION, stdLeaseAcquireV1, stdLeaseReleaseV1, stdLeaseRefreshV1, stdVaultSyncV1, stdVaultCommitV1, stdMeshPullV1, stdMeshPropagateV1, createLeaseOps, createVaultOps, createLlmOps, createMeshOps, } from "./ops/index.js";
10
+ export type { OpStubResult, LeaseAcquireOpArgs, LeaseAcquireOpResult, LeaseReleaseOpArgs, LeaseRefreshOpArgs, LeaseOpResult, VaultSyncOpArgs, VaultSyncOpResult, VaultCommitOpArgs, VaultCommitOpResult, LlmGenerateOpArgs, LlmEmbedOpArgs, LlmStubResult, MeshStubResult, } from "./ops/index.js";
11
+ export { createLytRuntime } from "./runtime.js";
12
+ export type { LytRuntime, LytRuntimeConfig } from "./runtime.js";
13
+ export { runFiveStep } from "./protocol/five-step.js";
14
+ export type { FiveStepOptions, FiveStepResult } from "./protocol/five-step.js";
15
+ export { createRunContext, finalizeContext, finishStep, startStep, } from "./protocol/run-context.js";
16
+ export type { LytRunContext, LytRunStatus, LytRunStepTiming } from "./protocol/run-context.js";
17
+ export { writeMarkdownWithStamp, writeYonWithStamp, formatYonStampRecord, } from "./hooks/stamp-on-write.js";
18
+ export type { StampMeta, WriteWithStampArgs, WriteWithStampResult, YonStampRecordArgs, ProvenanceWriteTargetType, } from "./hooks/stamp-on-write.js";
19
+ export { upsertLastProvenance, formatLastProvenanceValue } from "./hooks/frontmatter.js";
20
+ export type { FrontmatterStampLine } from "./hooks/frontmatter.js";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA4CA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,eAAgB,SAAQ,YAAY;IASnD,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,MAAM,GAAE,eAAoB,GAAG,MAAM,CAiCpE;AAKD,OAAO,EACL,S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AAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACzF,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,96 @@
1
+ /*
2
+ * Copyright 2026 MARLINK TRADING SRL (YounndAI)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // @younndai/lyt-runner — public entry point.
17
+ //
18
+ // Pattern A (arc-thoughts §6.11 LOCKED 2026-05-27): a thin wrapper on
19
+ // @younndai/yon-runner. createLytRunner() composes:
20
+ // 1. yon-runner's createRunner(config) — base runtime with 39 std ops
21
+ // 2. The yai.lyt expander (Commit 1) — `lytExpand(doc)` is the public
22
+ // surface; the runner does NOT auto-apply it on every run() — callers
23
+ // invoke it explicitly when they have an @AUTOMATOR-bearing doc
24
+ // 3. (Commit 4) LytRuntime + ops registration:
25
+ // - createLeaseOps(runtime) → std:lease.acquire / .release / .refresh
26
+ // - createVaultOps(runtime) → std:vault.sync / .commit
27
+ // - createMeshOps() → std:mesh.pull / .propagate (stubs;
28
+ // block-C consumers)
29
+ // - createLlmOps(gateway) → std:llm.generate / .embed (real when
30
+ // gateway present); std:llm.stream /
31
+ // .generate_object (stubs; block-D)
32
+ //
33
+ // If `config.runtime` is omitted the runner registers the Commit-1 fallback
34
+ // stubs (`LYT_OPS`) so legacy callers + the expander-only test suite still
35
+ // build green. The 5-step protocol orchestrator (`runFiveStep`) is exported
36
+ // separately — it takes its own LytRuntime + automatorRid/vaultRid and
37
+ // orchestrates lease → sync → body → commit → release in TS.
38
+ //
39
+ // Reference: zen-runner/src/index.ts L202-294 is the canonical Pattern A
40
+ // composition template; lyt-runner mirrors its createRunner + registerPlugin
41
+ // shape, extended with conditional real-op registration when a LytRuntime
42
+ // is supplied.
43
+ import { createRunner } from "@younndai/yon-runner";
44
+ import { createLeaseOps } from "./ops/leases.js";
45
+ import { createLlmOps } from "./ops/llm.js";
46
+ import { createMeshOps } from "./ops/mesh.js";
47
+ import { createVaultOps } from "./ops/vault.js";
48
+ import { LYT_OPS, LYT_OPS_NAMESPACE, LYT_OPS_VERSION } from "./ops/index.js";
49
+ export function createLytRunner(config = {}) {
50
+ const { runtime, ...runnerConfig } = config;
51
+ // 1. Construct the base yon-runner. Per zen-runner/src/index.ts:233 the
52
+ // canonical pattern is `createRunner(config)` with no plugins yet;
53
+ // registerPlugin happens immediately after construction.
54
+ const runner = createRunner(runnerConfig);
55
+ // 2. Register the lyt op set. Per yon-runner/src/ops/registry.ts L50-56,
56
+ // registerPlugin iterates plugin.ops and registers each as
57
+ // `${namespace}:${name}@${version}` (e.g. `std:lease.acquire@v1`).
58
+ if (runtime !== undefined) {
59
+ // Commit-4 path: real ops bound to a LytRuntime + optional LlmGateway.
60
+ runner.registerPlugin({
61
+ namespace: LYT_OPS_NAMESPACE,
62
+ ops: {
63
+ ...createLeaseOps(runtime),
64
+ ...createVaultOps(runtime),
65
+ ...createMeshOps(),
66
+ ...createLlmOps(runtime.llmGateway),
67
+ },
68
+ version: LYT_OPS_VERSION,
69
+ });
70
+ }
71
+ else {
72
+ // Commit-1 fallback: stub bundle. New callers should pass a runtime.
73
+ runner.registerPlugin({
74
+ namespace: LYT_OPS_NAMESPACE,
75
+ ops: LYT_OPS,
76
+ version: LYT_OPS_VERSION,
77
+ });
78
+ }
79
+ return runner;
80
+ }
81
+ // Re-export the expander surface so external consumers (test harnesses,
82
+ // future @younndai/lyt-llm, the lyt automator CLI verb group from Commit 6)
83
+ // can reach them without deep-importing from /expander/.
84
+ export { lytExpand, parseAutomator, parseDirective, automatorToAgentRecords, ExpanderError, } from "./expander/index.js";
85
+ // Re-export the op surface — back-compat stubs plus the new real-op
86
+ // factories. Callers can compose ops manually if they need to mix
87
+ // real + stub for a particular test scenario.
88
+ export { LYT_OPS, LYT_OPS_NAMESPACE, LYT_OPS_VERSION, stdLeaseAcquireV1, stdLeaseReleaseV1, stdLeaseRefreshV1, stdVaultSyncV1, stdVaultCommitV1, stdMeshPullV1, stdMeshPropagateV1, createLeaseOps, createVaultOps, createLlmOps, createMeshOps, } from "./ops/index.js";
89
+ // Runtime + protocol surface (Commit 4 new).
90
+ export { createLytRuntime } from "./runtime.js";
91
+ export { runFiveStep } from "./protocol/five-step.js";
92
+ export { createRunContext, finalizeContext, finishStep, startStep, } from "./protocol/run-context.js";
93
+ // Block-B Commit 5: pre-write @STAMP hook surface (arc-thoughts §11.4).
94
+ export { writeMarkdownWithStamp, writeYonWithStamp, formatYonStampRecord, } from "./hooks/stamp-on-write.js";
95
+ export { upsertLastProvenance, formatLastProvenanceValue } from "./hooks/frontmatter.js";
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oDAAoD;AACpD,sEAAsE;AACtE,sEAAsE;AACtE,sEAAsE;AACtE,gEAAgE;AAChE,+CAA+C;AAC/C,sEAAsE;AACtE,uDAAuD;AACvD,yDAAyD;AACzD,qBAAqB;AACrB,iEAAiE;AACjE,qCAAqC;AACrC,oCAAoC;AACpC,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,uEAAuE;AACvE,6DAA6D;AAC7D,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,0EAA0E;AAC1E,eAAe;AAEf,OAAO,EAAE,YAAY,EAAkC,MAAM,sBAAsB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AACpE,kEAAkE;AAClE,8CAA8C;AAC9C,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,GACd,MAAM,gBAAgB,CAAC;AAmBxB,6CAA6C;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,SAAS,GACV,MAAM,2BAA2B,CAAC;AAGnC,wEAAwE;AACxE,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AASnC,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { OpHandler } from "@younndai/yon-runner";
2
+ export interface OpStubResult {
3
+ status: "stub";
4
+ op: string;
5
+ warning: string;
6
+ args: Record<string, unknown>;
7
+ }
8
+ export declare const stdLeaseAcquireV1: OpHandler;
9
+ export declare const stdLeaseReleaseV1: OpHandler;
10
+ export declare const stdLeaseRefreshV1: OpHandler;
11
+ export declare const stdVaultSyncV1: OpHandler;
12
+ export declare const stdVaultCommitV1: OpHandler;
13
+ export declare const LYT_OPS: Record<string, OpHandler>;
14
+ export declare const LYT_OPS_NAMESPACE = "std";
15
+ export declare const LYT_OPS_VERSION = "v1";
16
+ export { createLeaseOps } from "./leases.js";
17
+ export { createVaultOps } from "./vault.js";
18
+ export { createLlmOps } from "./llm.js";
19
+ export { createMeshOps, stdMeshPullV1, stdMeshPropagateV1 } from "./mesh.js";
20
+ export type { LeaseAcquireOpArgs, LeaseAcquireOpResult, LeaseReleaseOpArgs, LeaseRefreshOpArgs, LeaseOpResult, } from "./leases.js";
21
+ export type { VaultSyncOpArgs, VaultSyncOpResult, VaultCommitOpArgs, VaultCommitOpResult, } from "./vault.js";
22
+ export type { LlmGenerateOpArgs, LlmEmbedOpArgs, LlmStubResult } from "./llm.js";
23
+ export type { MeshStubResult } from "./mesh.js";
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIxE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAyBD,eAAO,MAAM,iBAAiB,WAAkE,CAAC;AACjG,eAAO,MAAM,iBAAiB,WAAkE,CAAC;AACjG,eAAO,MAAM,iBAAiB,WAAkE,CAAC;AACjG,eAAO,MAAM,cAAc,WAA+D,CAAC;AAC3F,eAAO,MAAM,gBAAgB,WAAiE,CAAC;AAE/F,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAQ7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AACvC,eAAO,MAAM,eAAe,OAAO,CAAC;AAGpC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE7E,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjF,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright 2026 MARLINK TRADING SRL (YounndAI)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { stdMeshPullV1, stdMeshPropagateV1 } from "./mesh.js";
17
+ // ---------------------------------------------------------------------------
18
+ // Commit 1 back-compat stubs. These are unchanged in shape — every entry
19
+ // here is a `(_ctx, args) => structured-no-op-with-warning` handler. They
20
+ // are kept so any test or downstream import from Commit 1 that referenced
21
+ // `LYT_OPS` keeps working; new callers should use createLytRunner() which
22
+ // invokes the real factories from leases.ts / vault.ts / llm.ts.
23
+ // ---------------------------------------------------------------------------
24
+ function makeStub(op, deferredPhase) {
25
+ const handler = async (_ctx, args) => {
26
+ return {
27
+ status: "stub",
28
+ op,
29
+ warning: `${op} is not implemented in the LYT_OPS stub bundle; use createLytRunner() with a configured LytRuntime to register the real impl (${deferredPhase})`,
30
+ args,
31
+ };
32
+ };
33
+ return handler;
34
+ }
35
+ export const stdLeaseAcquireV1 = makeStub("std:lease.acquire@v1", "via createLeaseOps(runtime)");
36
+ export const stdLeaseReleaseV1 = makeStub("std:lease.release@v1", "via createLeaseOps(runtime)");
37
+ export const stdLeaseRefreshV1 = makeStub("std:lease.refresh@v1", "via createLeaseOps(runtime)");
38
+ export const stdVaultSyncV1 = makeStub("std:vault.sync@v1", "via createVaultOps(runtime)");
39
+ export const stdVaultCommitV1 = makeStub("std:vault.commit@v1", "via createVaultOps(runtime)");
40
+ export const LYT_OPS = {
41
+ "lease.acquire": stdLeaseAcquireV1,
42
+ "lease.release": stdLeaseReleaseV1,
43
+ "lease.refresh": stdLeaseRefreshV1,
44
+ "vault.sync": stdVaultSyncV1,
45
+ "vault.commit": stdVaultCommitV1,
46
+ "mesh.pull": stdMeshPullV1,
47
+ "mesh.propagate": stdMeshPropagateV1,
48
+ };
49
+ export const LYT_OPS_NAMESPACE = "std";
50
+ export const LYT_OPS_VERSION = "v1";
51
+ // Re-export the real-op factories so createLytRunner() can compose them.
52
+ export { createLeaseOps } from "./leases.js";
53
+ export { createVaultOps } from "./vault.js";
54
+ export { createLlmOps } from "./llm.js";
55
+ export { createMeshOps, stdMeshPullV1, stdMeshPropagateV1 } from "./mesh.js";
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkCH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAS9D,8EAA8E;AAC9E,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,iEAAiE;AACjE,8EAA8E;AAE9E,SAAS,QAAQ,CAAC,EAAU,EAAE,aAAqB;IACjD,MAAM,OAAO,GAAc,KAAK,EAC9B,IAAsB,EACtB,IAA6B,EACN,EAAE;QACzB,OAAO;YACL,MAAM,EAAE,MAAM;YACd,EAAE;YACF,OAAO,EAAE,GAAG,EAAE,iIAAiI,aAAa,GAAG;YAC/J,IAAI;SACL,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,sBAAsB,EAAE,6BAA6B,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,sBAAsB,EAAE,6BAA6B,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,sBAAsB,EAAE,6BAA6B,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,qBAAqB,EAAE,6BAA6B,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,OAAO,GAA8B;IAChD,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,cAAc;IAC5B,cAAc,EAAE,gBAAgB;IAChC,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,yEAAyE;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { OpHandler } from "@younndai/yon-runner";
2
+ import type { LytRuntime } from "../runtime.js";
3
+ export interface LeaseAcquireOpArgs {
4
+ automator_rid: string;
5
+ vault_rid: string;
6
+ ttl_ms?: number;
7
+ }
8
+ export interface LeaseAcquireOpResult {
9
+ status: "acquired";
10
+ lease_id: string;
11
+ expires_at: number;
12
+ acquired_at: number;
13
+ machine_id: string;
14
+ }
15
+ export interface LeaseReleaseOpArgs {
16
+ lease_id: string;
17
+ reason?: string;
18
+ }
19
+ export interface LeaseRefreshOpArgs {
20
+ lease_id: string;
21
+ ttl_ms?: number;
22
+ }
23
+ export interface LeaseOpResult {
24
+ status: "released" | "refreshed" | "not_active";
25
+ lease_id: string;
26
+ }
27
+ export declare function createLeaseOps(runtime: LytRuntime): Record<string, OpHandler>;
28
+ //# sourceMappingURL=leases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leases.d.ts","sourceRoot":"","sources":["../../src/ops/leases.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAUxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;IAChD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAmBD,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CA0E7E"}