@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.
- package/LICENSE +200 -0
- package/NOTICE +23 -0
- package/README.md +110 -0
- package/dist/expander/automator-to-agent.d.ts +4 -0
- package/dist/expander/automator-to-agent.d.ts.map +1 -0
- package/dist/expander/automator-to-agent.js +129 -0
- package/dist/expander/automator-to-agent.js.map +1 -0
- package/dist/expander/index.d.ts +17 -0
- package/dist/expander/index.d.ts.map +1 -0
- package/dist/expander/index.js +62 -0
- package/dist/expander/index.js.map +1 -0
- package/dist/expander/parse-record.d.ts +10 -0
- package/dist/expander/parse-record.d.ts.map +1 -0
- package/dist/expander/parse-record.js +162 -0
- package/dist/expander/parse-record.js.map +1 -0
- package/dist/expander/types.d.ts +39 -0
- package/dist/expander/types.d.ts.map +1 -0
- package/dist/expander/types.js +17 -0
- package/dist/expander/types.js.map +1 -0
- package/dist/hooks/frontmatter.d.ts +10 -0
- package/dist/hooks/frontmatter.d.ts.map +1 -0
- package/dist/hooks/frontmatter.js +90 -0
- package/dist/hooks/frontmatter.js.map +1 -0
- package/dist/hooks/stamp-on-write.d.ts +43 -0
- package/dist/hooks/stamp-on-write.d.ts.map +1 -0
- package/dist/hooks/stamp-on-write.js +289 -0
- package/dist/hooks/stamp-on-write.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/ops/index.d.ts +24 -0
- package/dist/ops/index.d.ts.map +1 -0
- package/dist/ops/index.js +56 -0
- package/dist/ops/index.js.map +1 -0
- package/dist/ops/leases.d.ts +28 -0
- package/dist/ops/leases.d.ts.map +1 -0
- package/dist/ops/leases.js +93 -0
- package/dist/ops/leases.js.map +1 -0
- package/dist/ops/llm.d.ts +28 -0
- package/dist/ops/llm.d.ts.map +1 -0
- package/dist/ops/llm.js +132 -0
- package/dist/ops/llm.js.map +1 -0
- package/dist/ops/mesh.d.ts +11 -0
- package/dist/ops/mesh.d.ts.map +1 -0
- package/dist/ops/mesh.js +35 -0
- package/dist/ops/mesh.js.map +1 -0
- package/dist/ops/vault.d.ts +26 -0
- package/dist/ops/vault.d.ts.map +1 -0
- package/dist/ops/vault.js +153 -0
- package/dist/ops/vault.js.map +1 -0
- package/dist/protocol/five-step.d.ts +22 -0
- package/dist/protocol/five-step.d.ts.map +1 -0
- package/dist/protocol/five-step.js +312 -0
- package/dist/protocol/five-step.js.map +1 -0
- package/dist/protocol/run-context.d.ts +35 -0
- package/dist/protocol/run-context.d.ts.map +1 -0
- package/dist/protocol/run-context.js +56 -0
- package/dist/protocol/run-context.js.map +1 -0
- package/dist/runtime.d.ts +18 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +28 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,93 @@
|
|
|
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 { acquireLease, refreshLease, releaseLease, hexToUuid7Bytes, uuid7BytesToHex, } from "@younndai/lyt-vault";
|
|
17
|
+
function requireString(args, key) {
|
|
18
|
+
const v = args[key];
|
|
19
|
+
if (typeof v !== "string" || v.length === 0) {
|
|
20
|
+
throw new Error(`lease op: missing required string arg \`${key}\``);
|
|
21
|
+
}
|
|
22
|
+
return v;
|
|
23
|
+
}
|
|
24
|
+
function optionalNumber(args, key) {
|
|
25
|
+
const v = args[key];
|
|
26
|
+
if (v === undefined)
|
|
27
|
+
return undefined;
|
|
28
|
+
if (typeof v !== "number" || !Number.isFinite(v)) {
|
|
29
|
+
throw new Error(`lease op: arg \`${key}\` must be a finite number, got ${typeof v}`);
|
|
30
|
+
}
|
|
31
|
+
return v;
|
|
32
|
+
}
|
|
33
|
+
export function createLeaseOps(runtime) {
|
|
34
|
+
return {
|
|
35
|
+
"lease.acquire": async (_ctx, args) => {
|
|
36
|
+
if (runtime.db === undefined) {
|
|
37
|
+
throw new Error("std:lease.acquire@v1: no libSQL client wired in LytRuntime; pass config.db to createLytRunner()");
|
|
38
|
+
}
|
|
39
|
+
const automatorRid = hexToUuid7Bytes(requireString(args, "automator_rid"));
|
|
40
|
+
const vaultRid = hexToUuid7Bytes(requireString(args, "vault_rid"));
|
|
41
|
+
const ttlMs = optionalNumber(args, "ttl_ms");
|
|
42
|
+
const row = await acquireLease(runtime.db, {
|
|
43
|
+
automatorRid,
|
|
44
|
+
vaultRid,
|
|
45
|
+
machineId: runtime.machineId,
|
|
46
|
+
...(ttlMs !== undefined ? { ttlMs } : {}),
|
|
47
|
+
now: runtime.getNow(),
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
status: "acquired",
|
|
51
|
+
lease_id: uuid7BytesToHex(row.leaseId),
|
|
52
|
+
expires_at: row.expiresAt,
|
|
53
|
+
acquired_at: row.acquiredAt,
|
|
54
|
+
machine_id: row.machineId,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
"lease.release": async (_ctx, args) => {
|
|
58
|
+
if (runtime.db === undefined) {
|
|
59
|
+
throw new Error("std:lease.release@v1: no libSQL client wired in LytRuntime; pass config.db to createLytRunner()");
|
|
60
|
+
}
|
|
61
|
+
const leaseIdHex = requireString(args, "lease_id");
|
|
62
|
+
const leaseId = hexToUuid7Bytes(leaseIdHex);
|
|
63
|
+
const reasonRaw = args["reason"];
|
|
64
|
+
const released = await releaseLease(runtime.db, {
|
|
65
|
+
leaseId,
|
|
66
|
+
...(typeof reasonRaw === "string" ? { reason: reasonRaw } : {}),
|
|
67
|
+
now: runtime.getNow(),
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
status: released ? "released" : "not_active",
|
|
71
|
+
lease_id: leaseIdHex,
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
"lease.refresh": async (_ctx, args) => {
|
|
75
|
+
if (runtime.db === undefined) {
|
|
76
|
+
throw new Error("std:lease.refresh@v1: no libSQL client wired in LytRuntime; pass config.db to createLytRunner()");
|
|
77
|
+
}
|
|
78
|
+
const leaseIdHex = requireString(args, "lease_id");
|
|
79
|
+
const leaseId = hexToUuid7Bytes(leaseIdHex);
|
|
80
|
+
const ttlMs = optionalNumber(args, "ttl_ms");
|
|
81
|
+
const refreshed = await refreshLease(runtime.db, {
|
|
82
|
+
leaseId,
|
|
83
|
+
...(ttlMs !== undefined ? { ttlMs } : {}),
|
|
84
|
+
now: runtime.getNow(),
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
status: refreshed ? "refreshed" : "not_active",
|
|
88
|
+
lease_id: leaseIdHex,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=leases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leases.js","sourceRoot":"","sources":["../../src/ops/leases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAuBH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,GAEhB,MAAM,qBAAqB,CAAC;AAiC7B,SAAS,aAAa,CAAC,IAA6B,EAAE,GAAW;IAC/D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,IAAI,OAAO,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AAC;YACJ,CAAC;YACD,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YACnD,MAAM,OAAO,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;YAC5C,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC7C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE;gBAC/C,OAAO;gBACP,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzC,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE;aACtB,CAAC,CAAC;YACH,OAAO;gBACL,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY;gBAC9C,QAAQ,EAAE,UAAU;aACrB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OpHandler } from "@younndai/yon-runner";
|
|
2
|
+
import type { HardConstraint, LlmCapability, LlmGateway, LlmSource, MemscopeContext } from "@younndai/lyt-llm";
|
|
3
|
+
export interface LlmGenerateOpArgs {
|
|
4
|
+
prompt: string;
|
|
5
|
+
system?: string;
|
|
6
|
+
capability?: LlmCapability;
|
|
7
|
+
source_preference?: LlmSource[];
|
|
8
|
+
hard_constraints?: HardConstraint[];
|
|
9
|
+
memscope?: MemscopeContext;
|
|
10
|
+
model?: string;
|
|
11
|
+
max_tokens?: number;
|
|
12
|
+
temperature?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface LlmEmbedOpArgs {
|
|
15
|
+
texts: string[];
|
|
16
|
+
source_preference?: LlmSource[];
|
|
17
|
+
hard_constraints?: HardConstraint[];
|
|
18
|
+
memscope?: MemscopeContext;
|
|
19
|
+
model?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface LlmStubResult {
|
|
22
|
+
status: "stub";
|
|
23
|
+
op: string;
|
|
24
|
+
warning: string;
|
|
25
|
+
args: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createLlmOps(gateway: LlmGateway | undefined): Record<string, OpHandler>;
|
|
28
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/ops/llm.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAKV,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC;IAChC,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC;IAChC,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,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;AA4ED,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAyDvF"}
|
package/dist/ops/llm.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
function requireString(args, key, op) {
|
|
17
|
+
const v = args[key];
|
|
18
|
+
if (typeof v !== "string" || v.length === 0) {
|
|
19
|
+
throw new Error(`${op}: missing required string arg \`${key}\``);
|
|
20
|
+
}
|
|
21
|
+
return v;
|
|
22
|
+
}
|
|
23
|
+
function requireStringArray(args, key, op) {
|
|
24
|
+
const v = args[key];
|
|
25
|
+
if (!Array.isArray(v) || v.length === 0) {
|
|
26
|
+
throw new Error(`${op}: required arg \`${key}\` must be a non-empty array of strings`);
|
|
27
|
+
}
|
|
28
|
+
for (const x of v) {
|
|
29
|
+
if (typeof x !== "string") {
|
|
30
|
+
throw new Error(`${op}: arg \`${key}\` entries must be strings`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return v;
|
|
34
|
+
}
|
|
35
|
+
function optionalNumber(args, key, op) {
|
|
36
|
+
const v = args[key];
|
|
37
|
+
if (v === undefined)
|
|
38
|
+
return undefined;
|
|
39
|
+
if (typeof v !== "number" || !Number.isFinite(v)) {
|
|
40
|
+
throw new Error(`${op}: arg \`${key}\` must be a finite number, got ${typeof v}`);
|
|
41
|
+
}
|
|
42
|
+
return v;
|
|
43
|
+
}
|
|
44
|
+
function buildGenerateRequest(args, op) {
|
|
45
|
+
const prompt = requireString(args, "prompt", op);
|
|
46
|
+
const req = { prompt };
|
|
47
|
+
const system = args["system"];
|
|
48
|
+
if (typeof system === "string")
|
|
49
|
+
req.system = system;
|
|
50
|
+
const capability = args["capability"];
|
|
51
|
+
if (typeof capability === "string")
|
|
52
|
+
req.capability = capability;
|
|
53
|
+
const sourcePreference = args["source_preference"];
|
|
54
|
+
if (Array.isArray(sourcePreference))
|
|
55
|
+
req.sourcePreference = sourcePreference;
|
|
56
|
+
const hardConstraints = args["hard_constraints"];
|
|
57
|
+
if (Array.isArray(hardConstraints)) {
|
|
58
|
+
req.hardConstraints = hardConstraints;
|
|
59
|
+
}
|
|
60
|
+
const memscope = args["memscope"];
|
|
61
|
+
if (memscope && typeof memscope === "object")
|
|
62
|
+
req.memscope = memscope;
|
|
63
|
+
const model = args["model"];
|
|
64
|
+
if (typeof model === "string")
|
|
65
|
+
req.model = model;
|
|
66
|
+
const maxTokens = optionalNumber(args, "max_tokens", op);
|
|
67
|
+
if (maxTokens !== undefined)
|
|
68
|
+
req.maxTokens = maxTokens;
|
|
69
|
+
const temperature = optionalNumber(args, "temperature", op);
|
|
70
|
+
if (temperature !== undefined)
|
|
71
|
+
req.temperature = temperature;
|
|
72
|
+
return req;
|
|
73
|
+
}
|
|
74
|
+
function buildEmbedRequest(args, op) {
|
|
75
|
+
const texts = requireStringArray(args, "texts", op);
|
|
76
|
+
const req = { texts };
|
|
77
|
+
const sourcePreference = args["source_preference"];
|
|
78
|
+
if (Array.isArray(sourcePreference))
|
|
79
|
+
req.sourcePreference = sourcePreference;
|
|
80
|
+
const hardConstraints = args["hard_constraints"];
|
|
81
|
+
if (Array.isArray(hardConstraints)) {
|
|
82
|
+
req.hardConstraints = hardConstraints;
|
|
83
|
+
}
|
|
84
|
+
const memscope = args["memscope"];
|
|
85
|
+
if (memscope && typeof memscope === "object")
|
|
86
|
+
req.memscope = memscope;
|
|
87
|
+
const model = args["model"];
|
|
88
|
+
if (typeof model === "string")
|
|
89
|
+
req.model = model;
|
|
90
|
+
return req;
|
|
91
|
+
}
|
|
92
|
+
export function createLlmOps(gateway) {
|
|
93
|
+
return {
|
|
94
|
+
"llm.generate": async (_ctx, args) => {
|
|
95
|
+
if (gateway === undefined) {
|
|
96
|
+
throw new Error("std:llm.generate@v1: no LlmGateway wired in LytRuntime; pass config.llmGateway to createLytRunner()");
|
|
97
|
+
}
|
|
98
|
+
const req = buildGenerateRequest(args, "std:llm.generate@v1");
|
|
99
|
+
return gateway.generate(req);
|
|
100
|
+
},
|
|
101
|
+
"llm.embed": async (_ctx, args) => {
|
|
102
|
+
if (gateway === undefined) {
|
|
103
|
+
throw new Error("std:llm.embed@v1: no LlmGateway wired in LytRuntime; pass config.llmGateway to createLytRunner()");
|
|
104
|
+
}
|
|
105
|
+
const req = buildEmbedRequest(args, "std:llm.embed@v1");
|
|
106
|
+
return gateway.embed(req);
|
|
107
|
+
},
|
|
108
|
+
"llm.stream": async (_ctx, args) => {
|
|
109
|
+
// Per lyt-llm/src/index.ts:9 the gateway has no `stream` method in
|
|
110
|
+
// Commit 2 — streaming surface lands at block-D. The op exists so
|
|
111
|
+
// @AUTOMATOR authors can register the intent now; the stub surfaces a
|
|
112
|
+
// structured warning rather than failing the runner.
|
|
113
|
+
return {
|
|
114
|
+
status: "stub",
|
|
115
|
+
op: "std:llm.stream@v1",
|
|
116
|
+
warning: "std:llm.stream@v1 is stubbed in block-B Commit 4; streaming surface lands at block-D when the lyt-llm gateway gains a stream() method",
|
|
117
|
+
args,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
"llm.generate_object": async (_ctx, args) => {
|
|
121
|
+
// Per lyt-llm/src/index.ts:9 zod-schema structured output is deferred
|
|
122
|
+
// to block-D. Same stub-with-warning shape as llm.stream.
|
|
123
|
+
return {
|
|
124
|
+
status: "stub",
|
|
125
|
+
op: "std:llm.generate_object@v1",
|
|
126
|
+
warning: "std:llm.generate_object@v1 is stubbed in block-B Commit 4; zod-schema structured output lands at block-D when the lyt-llm gateway gains a generateObject() method",
|
|
127
|
+
args,
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=llm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/ops/llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA4DH,SAAS,aAAa,CAAC,IAA6B,EAAE,GAAW,EAAE,EAAU;IAC3E,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,mCAAmC,GAAG,IAAI,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA6B,EAAE,GAAW,EAAE,EAAU;IAChF,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,oBAAoB,GAAG,yCAAyC,CAAC,CAAC;IACzF,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,WAAW,GAAG,4BAA4B,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;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ACd,EAAE,EAAE,4BAA4B;gBAChC,OAAO,EACL,mKAAmK;gBACrK,IAAI;aACL,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OpHandler } from "@younndai/yon-runner";
|
|
2
|
+
export interface MeshStubResult {
|
|
3
|
+
status: "stub";
|
|
4
|
+
op: string;
|
|
5
|
+
warning: string;
|
|
6
|
+
args: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare const stdMeshPullV1: OpHandler;
|
|
9
|
+
export declare const stdMeshPropagateV1: OpHandler;
|
|
10
|
+
export declare function createMeshOps(): Record<string, OpHandler>;
|
|
11
|
+
//# sourceMappingURL=mesh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../src/ops/mesh.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAExE,MAAM,WAAW,cAAc;IAC7B,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;AAiBD,eAAO,MAAM,aAAa,WAAmC,CAAC;AAC9D,eAAO,MAAM,kBAAkB,WAAwC,CAAC;AAExE,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAKzD"}
|
package/dist/ops/mesh.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
function makeMeshStub(op) {
|
|
17
|
+
const handler = async (_ctx, args) => {
|
|
18
|
+
return {
|
|
19
|
+
status: "stub",
|
|
20
|
+
op,
|
|
21
|
+
warning: `${op} is stubbed in block-B; real handler ships at block-C (mesh automator core)`,
|
|
22
|
+
args,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
return handler;
|
|
26
|
+
}
|
|
27
|
+
export const stdMeshPullV1 = makeMeshStub("std:mesh.pull@v1");
|
|
28
|
+
export const stdMeshPropagateV1 = makeMeshStub("std:mesh.propagate@v1");
|
|
29
|
+
export function createMeshOps() {
|
|
30
|
+
return {
|
|
31
|
+
"mesh.pull": stdMeshPullV1,
|
|
32
|
+
"mesh.propagate": stdMeshPropagateV1,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=mesh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh.js","sourceRoot":"","sources":["../../src/ops/mesh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAsBH,SAAS,YAAY,CAAC,EAAU;IAC9B,MAAM,OAAO,GAAc,KAAK,EAC9B,IAAsB,EACtB,IAA6B,EACJ,EAAE;QAC3B,OAAO;YACL,MAAM,EAAE,MAAM;YACd,EAAE;YACF,OAAO,EAAE,GAAG,EAAE,6EAA6E;YAC3F,IAAI;SACL,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAExE,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,WAAW,EAAE,aAAa;QAC1B,gBAAgB,EAAE,kBAAkB;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { OpHandler } from "@younndai/yon-runner";
|
|
2
|
+
import type { LytRuntime } from "../runtime.js";
|
|
3
|
+
export interface VaultSyncOpArgs {
|
|
4
|
+
vault_path?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface VaultSyncOpResult {
|
|
7
|
+
status: "synced" | "noop";
|
|
8
|
+
vault_path: string;
|
|
9
|
+
ahead: number;
|
|
10
|
+
behind: number;
|
|
11
|
+
stdout: string;
|
|
12
|
+
}
|
|
13
|
+
export interface VaultCommitOpArgs {
|
|
14
|
+
vault_path?: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
no_push?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface VaultCommitOpResult {
|
|
19
|
+
status: "committed" | "nothing_to_commit" | "committed_no_push";
|
|
20
|
+
vault_path: string;
|
|
21
|
+
commit_sha: string | null;
|
|
22
|
+
pushed: boolean;
|
|
23
|
+
stdout: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function createVaultOps(runtime: LytRuntime): Record<string, OpHandler>;
|
|
26
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../../src/ops/vault.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAaD,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAoJ7E"}
|
|
@@ -0,0 +1,153 @@
|
|
|
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 { gitStatusPorcelain, hasUpstream, isGitRepo, runGit } from "@younndai/lyt-vault";
|
|
17
|
+
function resolveVaultPath(runtime, args, op) {
|
|
18
|
+
const argVal = args["vault_path"];
|
|
19
|
+
if (typeof argVal === "string" && argVal.length > 0)
|
|
20
|
+
return argVal;
|
|
21
|
+
if (typeof runtime.vaultPath === "string" && runtime.vaultPath.length > 0) {
|
|
22
|
+
return runtime.vaultPath;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`${op}: no vault_path supplied — pass via @STEP args.vault_path or set LytRuntime.vaultPath at runner construction`);
|
|
25
|
+
}
|
|
26
|
+
export function createVaultOps(runtime) {
|
|
27
|
+
return {
|
|
28
|
+
"vault.sync": async (_ctx, args) => {
|
|
29
|
+
const vaultPath = resolveVaultPath(runtime, args, "std:vault.sync@v1");
|
|
30
|
+
if (!(await isGitRepo(vaultPath))) {
|
|
31
|
+
throw new Error(`std:vault.sync@v1: ${vaultPath} is not a git repository (git rev-parse --git-dir failed)`);
|
|
32
|
+
}
|
|
33
|
+
if (!(await hasUpstream(vaultPath))) {
|
|
34
|
+
// No upstream → there is nothing to pull from. Treat as a non-error
|
|
35
|
+
// noop so a freshly-init'd local vault (still --no-push) doesn't fail
|
|
36
|
+
// the protocol mid-run. Surfaces ahead/behind=0 + stdout=informational.
|
|
37
|
+
return {
|
|
38
|
+
status: "noop",
|
|
39
|
+
vault_path: vaultPath,
|
|
40
|
+
ahead: 0,
|
|
41
|
+
behind: 0,
|
|
42
|
+
stdout: "vault has no upstream; nothing to pull",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const pullResult = await runGit(["pull", "--ff-only"], {
|
|
46
|
+
cwd: vaultPath,
|
|
47
|
+
allowFailure: true,
|
|
48
|
+
});
|
|
49
|
+
if (pullResult.code !== 0) {
|
|
50
|
+
throw new Error(`std:vault.sync@v1: git pull --ff-only exited ${pullResult.code}: ${pullResult.stderr.trim() || pullResult.stdout.trim()}`);
|
|
51
|
+
}
|
|
52
|
+
// Surface ahead/behind so callers can see whether the pull was a no-op
|
|
53
|
+
// (already up to date) or actually advanced.
|
|
54
|
+
const rev = await runGit(["rev-list", "--left-right", "--count", "HEAD...@{u}"], {
|
|
55
|
+
cwd: vaultPath,
|
|
56
|
+
allowFailure: true,
|
|
57
|
+
});
|
|
58
|
+
let ahead = 0;
|
|
59
|
+
let behind = 0;
|
|
60
|
+
if (rev.code === 0) {
|
|
61
|
+
const parts = rev.stdout.trim().split(/\s+/);
|
|
62
|
+
ahead = Number(parts[0]) || 0;
|
|
63
|
+
behind = Number(parts[1]) || 0;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
status: "synced",
|
|
67
|
+
vault_path: vaultPath,
|
|
68
|
+
ahead,
|
|
69
|
+
behind,
|
|
70
|
+
stdout: pullResult.stdout.trim(),
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
"vault.commit": async (_ctx, args) => {
|
|
74
|
+
const vaultPath = resolveVaultPath(runtime, args, "std:vault.commit@v1");
|
|
75
|
+
if (!(await isGitRepo(vaultPath))) {
|
|
76
|
+
throw new Error(`std:vault.commit@v1: ${vaultPath} is not a git repository`);
|
|
77
|
+
}
|
|
78
|
+
const messageArg = args["message"];
|
|
79
|
+
const message = typeof messageArg === "string" && messageArg.length > 0
|
|
80
|
+
? messageArg
|
|
81
|
+
: "lyt-runner: vault.commit";
|
|
82
|
+
const noPushArg = args["no_push"];
|
|
83
|
+
const noPush = noPushArg === true;
|
|
84
|
+
// Stage everything under the vault path, including new files. Vault
|
|
85
|
+
// automators are vault-scoped (arc §6.5 reads_scope=[vault]), so
|
|
86
|
+
// `git add .` is the right surface — the vault IS the unit of work.
|
|
87
|
+
const addResult = await runGit(["add", "."], { cwd: vaultPath, allowFailure: true });
|
|
88
|
+
if (addResult.code !== 0) {
|
|
89
|
+
throw new Error(`std:vault.commit@v1: git add . exited ${addResult.code}: ${addResult.stderr.trim() || addResult.stdout.trim()}`);
|
|
90
|
+
}
|
|
91
|
+
// If nothing was staged, there's nothing to commit — return a clean
|
|
92
|
+
// noop result rather than letting `git commit` error with "nothing to
|
|
93
|
+
// commit, working tree clean".
|
|
94
|
+
const status = await gitStatusPorcelain(vaultPath);
|
|
95
|
+
if (status.clean) {
|
|
96
|
+
return {
|
|
97
|
+
status: "nothing_to_commit",
|
|
98
|
+
vault_path: vaultPath,
|
|
99
|
+
commit_sha: null,
|
|
100
|
+
pushed: false,
|
|
101
|
+
stdout: "working tree clean; nothing to commit",
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const commitResult = await runGit(["commit", "-m", message], {
|
|
105
|
+
cwd: vaultPath,
|
|
106
|
+
allowFailure: true,
|
|
107
|
+
});
|
|
108
|
+
if (commitResult.code !== 0) {
|
|
109
|
+
throw new Error(`std:vault.commit@v1: git commit exited ${commitResult.code}: ${commitResult.stderr.trim() || commitResult.stdout.trim()}`);
|
|
110
|
+
}
|
|
111
|
+
// Capture commit SHA (full, not abbreviated) for the run trace +
|
|
112
|
+
// automator_runs row that block-B Commit 5 will write.
|
|
113
|
+
const shaResult = await runGit(["rev-parse", "HEAD"], {
|
|
114
|
+
cwd: vaultPath,
|
|
115
|
+
allowFailure: true,
|
|
116
|
+
});
|
|
117
|
+
const commitSha = shaResult.code === 0 ? shaResult.stdout.trim() : null;
|
|
118
|
+
if (noPush) {
|
|
119
|
+
return {
|
|
120
|
+
status: "committed_no_push",
|
|
121
|
+
vault_path: vaultPath,
|
|
122
|
+
commit_sha: commitSha,
|
|
123
|
+
pushed: false,
|
|
124
|
+
stdout: commitResult.stdout.trim(),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (!(await hasUpstream(vaultPath))) {
|
|
128
|
+
// No upstream → can't push. Mirror vault.sync's noop posture: report,
|
|
129
|
+
// don't fail. Same rationale (a freshly-init'd local vault before
|
|
130
|
+
// remote setup should still let the protocol's commit step succeed).
|
|
131
|
+
return {
|
|
132
|
+
status: "committed_no_push",
|
|
133
|
+
vault_path: vaultPath,
|
|
134
|
+
commit_sha: commitSha,
|
|
135
|
+
pushed: false,
|
|
136
|
+
stdout: `${commitResult.stdout.trim()}\n(no upstream; skipped push)`,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const pushResult = await runGit(["push"], { cwd: vaultPath, allowFailure: true });
|
|
140
|
+
if (pushResult.code !== 0) {
|
|
141
|
+
throw new Error(`std:vault.commit@v1: git push exited ${pushResult.code}: ${pushResult.stderr.trim() || pushResult.stdout.trim()}`);
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
status: "committed",
|
|
145
|
+
vault_path: vaultPath,
|
|
146
|
+
commit_sha: commitSha,
|
|
147
|
+
pushed: true,
|
|
148
|
+
stdout: `${commitResult.stdout.trim()}\n${pushResult.stdout.trim()}`,
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../../src/ops/vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAwBH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA8BzF,SAAS,gBAAgB,CAAC,OAAmB,EAAE,IAA6B,EAAE,EAAU;IACtF,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IACnE,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1E,OAAO,OAAO,CAAC,SAAS,CAAC;IAC3B,CAAC;IACD,MAAM,IAAI,KAAK,CACb,GAAG,EAAE,8GAA8G,CACpH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAmB;IAChD,OAAO;QACL,YAAY,EAAE,KAAK,EACjB,IAAsB,EACtB,IAA6B,EACD,EAAE;YAC9B,MAAM,SAAS,G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{ type LytRunContext } from "./run-context.js";
|
|
4
|
+
export interface FiveStepOptions {
|
|
5
|
+
automatorRid: Uint8Array;
|
|
6
|
+
vaultRid: Uint8Array;
|
|
7
|
+
vaultPath: string;
|
|
8
|
+
vaultDb?: Client;
|
|
9
|
+
automatorName?: string;
|
|
10
|
+
runBody: (ctx: LytRunContext) => Promise<unknown>;
|
|
11
|
+
ttlMs?: number;
|
|
12
|
+
commitMessage?: string;
|
|
13
|
+
noPush?: boolean;
|
|
14
|
+
dryRun?: boolean;
|
|
15
|
+
runIdOverride?: Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
export interface FiveStepResult {
|
|
18
|
+
context: LytRunContext;
|
|
19
|
+
ok: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function runFiveStep(runtime: LytRuntime, opts: FiveStepOptions): Promise<FiveStepResult>;
|
|
22
|
+
//# sourceMappingURL=five-step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"five-step.d.ts","sourceRoot":"","sources":["../../src/protocol/five-step.ts"],"names":[],"mappings":"AAoDA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAKL,KAAK,aAAa,EAEnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,UAAU,CAAC;IACzB,QAAQ,EAAE,UAAU,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAOlB,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,aAAa,CAAC,EAAE,MAAM,CAAC;IAMvB,OAAO,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IAIjB,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,aAAa,CAAC;IACvB,EAAE,EAAE,OAAO,CAAC;CACb;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,cAAc,CAAC,CA8NzB"}
|