@ai-ecoverse/slicc-agent 7.13.0 → 7.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -266,7 +266,7 @@ Each scoop is owned by a background durable task, its **anchor**, so Stop in its
266
266
  - `models use <provider/model> [--thinking <level>]` switches the caller's model the way the Settings picker does (`Conversation.configure`): a cone's or a scoop's own, or, in a terminal, the active cone's. An unknown id exits 1 naming the three closest ids; a model whose account isn't connected exits 1 and says to connect it in Settings.
267
267
  - `models --help` prints the usage; an unknown verb exits 2 with it.
268
268
 
269
- **Roles** are pi agent files: Markdown with a frontmatter subset (`name`, `description`, `tools`, `model`, `thinking`, `memory`, `inheritProjectContext`, `inheritGlobalContext`, …) and the role's prompt as the body, added to the scoop's instructions. The built-ins are `scout`, `worker`, `reviewer`, `oracle`, `delegate` and `gelatiere` (below). The first source with a name wins: `~/.pi/agent/agents/`, then the built-ins, then packages (see Package resources) that name a folder in `pi-subagents.agents` or `pi.subagents.agents`. A package role that loses its name is skipped with a warning in `agent list`. A project's `.pi/agents/` will count only in trusted folders, and folders can't be trusted yet. `~/.pi/agent/settings.json` can override roles (`subagents.agentOverrides`) and set the limits `subagents.maxLiveScoops` (16 live scoops per cone) and `subagents.maxPerTurn` (64 scoops started per cone turn), which the worker counts for both kinds.
269
+ **Roles** are pi agent files: Markdown with YAML frontmatter (`name`, `description`, `tools`, `model`, `thinking`, `memory`, `inheritProjectContext`, `inheritGlobalContext`, …) and the role's prompt as the body, added to the scoop's instructions. The built-ins are `scout`, `worker`, `reviewer`, `oracle`, `delegate` and `gelatiere` (below). The first source with a name wins: `~/.pi/agent/agents/`, then the built-ins, then packages (see Package resources) that name a folder in `pi-subagents.agents` or `pi.subagents.agents`. A package role that loses its name is skipped with a warning in `agent list`. A project's `.pi/agents/` will count only in trusted folders, and folders can't be trusted yet. `~/.pi/agent/settings.json` can override roles (`subagents.agentOverrides`) and set the limits `subagents.maxLiveScoops` (16 live scoops per cone) and `subagents.maxPerTurn` (64 scoops started per cone turn), which the worker counts for both kinds.
270
270
 
271
271
  **Isolation, for now.** The file tools of a scoop write only under its folder and `/tmp`, plus the cwd of a v6-form call, and read those, their cone's working folder (`/home` by default) and `--read-only` paths; paths are normalized, `..` included, before the check. bash isn't confined, and the scoop is told so: the guard is a guardrail, not a boundary. A scoop's commands share one process group (see Bash and files on slicc-kernel), and stopping the scoop signals it, together with any group recorded for the scoop on an older kernel.
272
272
 
@@ -288,7 +288,8 @@ Skills and prompt templates work as in pi's coding-agent. pi's loaders read with
288
288
  On a name collision the first skill found wins: an agent's own skills shadow the global ones, a global skill shadows a built-in, and a built-in shadows a package's. A missing root is skipped.
289
289
  - **The global folder.** On every start the worker, as root, creates `/usr/share/skills` if it's missing and sets it to 0755, so it's root's and readable by everyone; once kernel users give each cone its own user and the kernel checks file modes, only root (the worker, sudo or the human) writes there, and every cone and scoop reads it. Each skill's `source` is `user`, `global`, `package` or `builtin`, and the transcript service's `commands` carry it. A skill folder in `/usr/share/skills` whose real path lies in a package under root's global pnpm (`/usr/local/share/pnpm/`), as bios links a certified catalog package's `pi.skills`, reads `package` with that package's `name` and `version` from its nearest `package.json`; every other skill there, such as those imported from SLICC 6 or written by root, stays `global`. Only these links count: root's global pnpm isn't scanned, and loading and precedence don't change.
290
290
  - **Inside a root.** Folders with `SKILL.md` are found at any depth, and a `SKILL.md` ends its branch. A `.md` file with a description directly in a root counts too. Folders starting with `.` and `node_modules` are skipped. Symbolic links are followed, but each folder is read once by its real path, so a link back up a tree can't loop. Scoops may `read` the folders of the loaded skills, even outside their own folders.
291
- - **Problems.** A problem (a missing description, a bad name, a collision, a line the frontmatter parser can't read) becomes one lick with `severity="warn"` per distinct problem. A skill without a description is skipped; any other problem only warns.
291
+ - **YAML.** Skills, roles and prompt templates use YAML 1.2 core scalars and folding through `yaml`. Custom tags and aliases are refused; nested fields remain unsupported except the role memory mapping. Duplicate keys keep their last value. On a YAML syntax error, the reader retries once with plain top-level text quoted and its continuation lines folded, so descriptions such as `Use when: foo` still load. A ` #` in an unquoted value starts a YAML comment, and `0x`/`0o` numbers parse as numbers; these differ from the old reader.
292
+ - **Problems.** A problem (a missing description, a bad name, a collision, a YAML error with its line number) becomes one lick with `severity="warn"` per distinct problem. A skill without a description is skipped; any other problem only warns.
292
293
  - **Untrusted folders.** A project's `.pi/skills` and `.agents/skills` are read only in trusted folders, which come with PR 21.
293
294
 
294
295
  The worker watches the roots and reloads on change. A `skills` prompt section, given to cones and scoops, lists every skill's name, description and location in pi's `<available_skills>` block, and the model reads a `SKILL.md` with the `read` tool when a task matches.
@@ -1,88 +1,111 @@
1
- function unquote(value) {
2
- const quoted = /^(["'])(.*)\1$/s.exec(value);
3
- if (!quoted) return value;
4
- return quoted[1] === '"' ? quoted[2].replace(/\\(["\\])/g, "$1") : quoted[2].replace(/''/g, "'");
1
+ import { isAlias, isCollection, isScalar, LineCounter, parseDocument, visit } from "yaml";
2
+ function primitive(value) {
3
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
5
4
  }
6
- function scalar(raw) {
7
- const value = raw.trim();
8
- if (/^\[.*\]$/s.test(value))
9
- return value.slice(1, -1).split(",").map((item) => unquote(item.trim())).filter(Boolean);
10
- if (value === "true" || value === "false") return value === "true";
11
- if (/^-?\d+(\.\d+)?$/.test(value)) return Number(value);
12
- return unquote(value);
13
- }
14
- const BLOCK = /^([|>])([+-]?)$/;
15
- function blockValue(block) {
16
- const indents = block.lines.filter((line2) => line2.trim()).map((line2) => /^\s*/.exec(line2)[0].length);
17
- const indent = indents.length ? Math.min(...indents) : 0;
18
- const lines = block.lines.map((line2) => line2.slice(indent));
19
- while (lines.length && !lines.at(-1)?.trim()) lines.pop();
20
- const text = block.folded ? lines.reduce(
21
- (out, line2) => !line2.trim() ? `${out}
22
- ` : out && !out.endsWith("\n") ? `${out} ${line2}` : `${out}${line2}`,
23
- ""
24
- ) : lines.join("\n");
25
- return block.strip || !text ? text : `${text}
26
- `;
27
- }
28
- function pair(state, line2) {
29
- const found = /^([A-Za-z][\w-]*):(?:\s+(.*))?$/.exec(line2);
30
- state.list = void 0;
31
- if (!found) {
32
- state.problems.push(`can't read the line "${line2.trim()}"`);
33
- return;
5
+ function fieldsFrom(parsed, mappings, problems) {
6
+ if (parsed === null) return {};
7
+ if (!(parsed instanceof Map)) {
8
+ problems.push("frontmatter must be a mapping");
9
+ return {};
34
10
  }
35
- const key = found[1];
36
- const value = found[2]?.trim() ?? "";
37
- const style = BLOCK.exec(value);
38
- if (style) state.block = { key, folded: style[1] === ">", strip: style[2] === "-", lines: [] };
39
- else if (value === "") {
40
- state.fields[key] = [];
41
- state.list = key;
42
- } else state.fields[key] = scalar(value);
11
+ const fields = /* @__PURE__ */ new Map();
12
+ for (const [key, value] of parsed) {
13
+ if (primitive(value)) fields.set(key, value);
14
+ else if (value === null) fields.set(key, []);
15
+ else if (Array.isArray(value) && value.every((item) => typeof item === "string"))
16
+ fields.set(key, value);
17
+ else if (value instanceof Map && mappings.includes(key) && [...value].every(([name, item]) => typeof name === "string" && primitive(item)))
18
+ fields.set(key, `{ ${[...value].map(([name, item]) => `${name}: ${item}`).join(", ")} }`);
19
+ else if (value instanceof Map)
20
+ problems.push(`"${key}" has nested values, which SLICC doesn't read`);
21
+ else problems.push(`"${key}" needs a scalar or a list of strings`);
22
+ }
23
+ return Object.fromEntries(fields);
24
+ }
25
+ function retryValue(raw, source) {
26
+ const scalar = parseDocument(source, {
27
+ schema: "core",
28
+ customTags: [],
29
+ resolveKnownTags: false
30
+ });
31
+ const clean = !scalar.errors.length && !scalar.warnings.length;
32
+ if (/^[[{]/.test(raw) && clean && isCollection(scalar.contents)) return void 0;
33
+ const typed = clean && isScalar(scalar.contents) && typeof scalar.contents.value !== "string";
34
+ return typed ? raw : JSON.stringify(raw);
43
35
  }
44
- function line(state, text) {
45
- const { block, list } = state;
46
- if (block && (!text.trim() || /^\s/.test(text))) {
47
- block.lines.push(text);
48
- return;
36
+ function tolerantSource(source) {
37
+ const lines = source.split("\n");
38
+ for (let index = 0; index < lines.length; index++) {
39
+ const found = /^([A-Za-z][\w-]*):[ \t]+(.*)$/.exec(lines[index]);
40
+ if (!found) continue;
41
+ const value = found[2].replace(/[ \t]+#.*$/, "").trim();
42
+ if (!value || value.startsWith("#") || /^["']/.test(value) || /^[|>](?:[1-9][+-]?|[+-][1-9]?)?$/.test(value))
43
+ continue;
44
+ let raw = value;
45
+ let blanks = 0;
46
+ const continuation = [];
47
+ for (let next = index + 1; next < lines.length; next++) {
48
+ const line = lines[next];
49
+ if (!line.trim()) {
50
+ continuation.push(line);
51
+ blanks++;
52
+ continue;
53
+ }
54
+ if (line.trimStart().startsWith("#")) {
55
+ continuation.push(line);
56
+ continue;
57
+ }
58
+ if (!/^[ \t]/.test(line)) break;
59
+ continuation.push(line);
60
+ const continued = line.replace(/[ \t]+#.*$/, "").trim();
61
+ raw += `${blanks ? "\n".repeat(blanks) : " "}${continued}`;
62
+ blanks = 0;
63
+ }
64
+ const quoted = retryValue(raw, [found[2], ...continuation].join("\n"));
65
+ if (quoted === void 0) continue;
66
+ for (let offset = 1; offset <= continuation.length; offset++) lines[index + offset] = "";
67
+ lines[index] = `${found[1]}: ${quoted}`;
49
68
  }
50
- if (block) state.fields[block.key] = blockValue(block);
51
- state.block = void 0;
52
- if (!text.trim() || text.trimStart().startsWith("#")) return;
53
- const item = /^\s+-\s+(.*)$/.exec(text);
54
- if (item && list) state.fields[list].push(unquote(item[1].trim()));
55
- else if (/^\s/.test(text) && list)
56
- state.nested.set(list, [...state.nested.get(list) ?? [], text.trim()]);
57
- else pair(state, text);
69
+ return lines.join("\n");
58
70
  }
59
71
  function parseFrontmatter(text, mappings = []) {
60
72
  const normalized = text.replace(/\r\n/g, "\n");
61
73
  const match = /^---\n([\s\S]*?)\n---(?:\n|$)/.exec(normalized);
62
74
  if (!match)
63
75
  return { fields: {}, body: normalized.trim(), problems: ["no frontmatter between --- lines"] };
64
- const state = {
65
- fields: {},
66
- problems: [],
67
- nested: /* @__PURE__ */ new Map(),
68
- list: void 0,
69
- block: void 0
76
+ const body = normalized.slice(match[0].length).trim();
77
+ let lineCounter = new LineCounter();
78
+ const options = {
79
+ schema: "core",
80
+ customTags: [],
81
+ resolveKnownTags: false,
82
+ stringKeys: true,
83
+ uniqueKeys: false
70
84
  };
71
- for (const text2 of match[1].split("\n")) line(state, text2);
72
- if (state.block) state.fields[state.block.key] = blockValue(state.block);
73
- for (const [key, lines] of state.nested) {
74
- if (mappings.includes(key)) {
75
- state.fields[key] = `{ ${lines.join(", ")} }`;
76
- continue;
77
- }
78
- delete state.fields[key];
79
- state.problems.push(`"${key}" has nested values, which SLICC doesn't read`);
85
+ const source = `---
86
+ ${match[1]}
87
+ `;
88
+ let document = parseDocument(source, { ...options, lineCounter });
89
+ if (document.errors.length) {
90
+ lineCounter = new LineCounter();
91
+ document = parseDocument(tolerantSource(source), { ...options, lineCounter });
80
92
  }
81
- return {
82
- fields: state.fields,
83
- body: normalized.slice(match[0].length).trim(),
84
- problems: state.problems
85
- };
93
+ const problems = [...document.errors, ...document.warnings].map((error) => error.message);
94
+ if (problems.length) return { fields: {}, body, problems };
95
+ let aliasOffset = 0;
96
+ visit(document, (_, node) => {
97
+ if (!isAlias(node)) return;
98
+ aliasOffset = node.range?.[0] ?? 0;
99
+ return visit.BREAK;
100
+ });
101
+ let parsed;
102
+ try {
103
+ parsed = document.toJS({ mapAsMap: true, maxAliasCount: 0 });
104
+ } catch (error) {
105
+ const { line } = lineCounter.linePos(aliasOffset);
106
+ return { fields: {}, body, problems: [`${error.message} at line ${line}`] };
107
+ }
108
+ return { fields: fieldsFrom(parsed, mappings, problems), body, problems };
86
109
  }
87
110
  export {
88
111
  parseFrontmatter
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/roles/frontmatter.ts"],
4
- "sourcesContent": ["export type FrontmatterValue = string | number | boolean | string[];\n\nexport interface Frontmatter {\n fields: Record<string, FrontmatterValue>;\n body: string;\n problems: string[];\n}\n\nfunction unquote(value: string): string {\n const quoted = /^([\"'])(.*)\\1$/s.exec(value);\n if (!quoted) return value;\n return quoted[1] === '\"'\n ? (quoted[2] as string).replace(/\\\\([\"\\\\])/g, '$1')\n : (quoted[2] as string).replace(/''/g, \"'\");\n}\n\nfunction scalar(raw: string): FrontmatterValue {\n const value = raw.trim();\n if (/^\\[.*\\]$/s.test(value))\n return value\n .slice(1, -1)\n .split(',')\n .map((item) => unquote(item.trim()))\n .filter(Boolean);\n if (value === 'true' || value === 'false') return value === 'true';\n if (/^-?\\d+(\\.\\d+)?$/.test(value)) return Number(value);\n return unquote(value);\n}\n\ntype Block = { key: string; folded: boolean; strip: boolean; lines: string[] };\n\nconst BLOCK = /^([|>])([+-]?)$/;\n\nfunction blockValue(block: Block): string {\n const indents = block.lines\n .filter((line) => line.trim())\n .map((line) => (/^\\s*/.exec(line) as RegExpExecArray)[0].length);\n const indent = indents.length ? Math.min(...indents) : 0;\n const lines = block.lines.map((line) => line.slice(indent));\n while (lines.length && !lines.at(-1)?.trim()) lines.pop();\n const text = block.folded\n ? lines.reduce(\n (out, line) =>\n !line.trim()\n ? `${out}\\n`\n : out && !out.endsWith('\\n')\n ? `${out} ${line}`\n : `${out}${line}`,\n ''\n )\n : lines.join('\\n');\n return block.strip || !text ? text : `${text}\\n`;\n}\n\ntype State = {\n fields: Record<string, FrontmatterValue>;\n problems: string[];\n nested: Map<string, string[]>;\n list: string | undefined;\n block: Block | undefined;\n};\n\nfunction pair(state: State, line: string): void {\n const found = /^([A-Za-z][\\w-]*):(?:\\s+(.*))?$/.exec(line);\n state.list = undefined;\n if (!found) {\n state.problems.push(`can't read the line \"${line.trim()}\"`);\n return;\n }\n const key = found[1] as string;\n const value = found[2]?.trim() ?? '';\n const style = BLOCK.exec(value);\n if (style) state.block = { key, folded: style[1] === '>', strip: style[2] === '-', lines: [] };\n else if (value === '') {\n state.fields[key] = [];\n state.list = key;\n } else state.fields[key] = scalar(value);\n}\n\nfunction line(state: State, text: string): void {\n const { block, list } = state;\n if (block && (!text.trim() || /^\\s/.test(text))) {\n block.lines.push(text);\n return;\n }\n if (block) state.fields[block.key] = blockValue(block);\n state.block = undefined;\n if (!text.trim() || text.trimStart().startsWith('#')) return;\n const item = /^\\s+-\\s+(.*)$/.exec(text);\n if (item && list) (state.fields[list] as string[]).push(unquote((item[1] as string).trim()));\n else if (/^\\s/.test(text) && list)\n state.nested.set(list, [...(state.nested.get(list) ?? []), text.trim()]);\n else pair(state, text);\n}\n\nexport function parseFrontmatter(text: string, mappings: readonly string[] = []): Frontmatter {\n const normalized = text.replace(/\\r\\n/g, '\\n');\n const match = /^---\\n([\\s\\S]*?)\\n---(?:\\n|$)/.exec(normalized);\n if (!match)\n return { fields: {}, body: normalized.trim(), problems: ['no frontmatter between --- lines'] };\n const state: State = {\n fields: {},\n problems: [],\n nested: new Map(),\n list: undefined,\n block: undefined,\n };\n for (const text of (match[1] as string).split('\\n')) line(state, text);\n if (state.block) state.fields[state.block.key] = blockValue(state.block);\n for (const [key, lines] of state.nested) {\n if (mappings.includes(key)) {\n state.fields[key] = `{ ${lines.join(', ')} }`;\n continue;\n }\n delete state.fields[key];\n state.problems.push(`\"${key}\" has nested values, which SLICC doesn't read`);\n }\n return {\n fields: state.fields,\n body: normalized.slice(match[0].length).trim(),\n problems: state.problems,\n };\n}\n"],
5
- "mappings": "AAQA,SAAS,QAAQ,OAAuB;AACtC,QAAM,SAAS,kBAAkB,KAAK,KAAK;AAC3C,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,OAAO,CAAC,MAAM,MAChB,OAAO,CAAC,EAAa,QAAQ,cAAc,IAAI,IAC/C,OAAO,CAAC,EAAa,QAAQ,OAAO,GAAG;AAC9C;AAEA,SAAS,OAAO,KAA+B;AAC7C,QAAM,QAAQ,IAAI,KAAK;AACvB,MAAI,YAAY,KAAK,KAAK;AACxB,WAAO,MACJ,MAAM,GAAG,EAAE,EACX,MAAM,GAAG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Q,oBAAI,IAAI;AAAA,IAChB,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACA,aAAWC,SAAS,MAAM,CAAC,EAAa,MAAM,IAAI,EAAG,MAAK,OAAOA,KAAI;AACrE,MAAI,MAAM,MAAO,OAAM,OAAO,MAAM,MAAM,GAAG,IAAI,WAAW,MAAM,KAAK;AACvE,aAAW,CAAC,KAAK,KAAK,KAAK,MAAM,QAAQ;AACvC,QAAI,SAAS,SAAS,GAAG,GAAG;AAC1B,YAAM,OAAO,GAAG,IAAI,KAAK,MAAM,KAAK,IAAI,CAAC;AACzC;AAAA,IACF;AACA,WAAO,MAAM,OAAO,GAAG;AACvB,UAAM,SAAS,KAAK,IAAI,GAAG,+CAA+C;AAAA,EAC5E;AACA,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,MAAM,WAAW,MAAM,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK;AAAA,IAC7C,UAAU,MAAM;AAAA,EAClB;AACF;",
6
- "names": ["line", "text"]
4
+ "sourcesContent": ["import { isAlias, isCollection, isScalar, LineCounter, parseDocument, visit } from 'yaml';\n\nexport type FrontmatterValue = string | number | boolean | string[];\n\nexport interface Frontmatter {\n fields: Record<string, FrontmatterValue>;\n body: string;\n problems: string[];\n}\n\nfunction primitive(value: unknown): value is string | number | boolean {\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';\n}\n\nfunction fieldsFrom(\n parsed: unknown,\n mappings: readonly string[],\n problems: string[]\n): Record<string, FrontmatterValue> {\n if (parsed === null) return {};\n if (!(parsed instanceof Map)) {\n problems.push('frontmatter must be a mapping');\n return {};\n }\n const fields = new Map<string, FrontmatterValue>();\n for (const [key, value] of parsed) {\n if (primitive(value)) fields.set(key, value);\n else if (value === null) fields.set(key, []);\n else if (Array.isArray(value) && value.every((item) => typeof item === 'string'))\n fields.set(key, value);\n else if (\n value instanceof Map &&\n mappings.includes(key) &&\n [...value].every(([name, item]) => typeof name === 'string' && primitive(item))\n )\n fields.set(key, `{ ${[...value].map(([name, item]) => `${name}: ${item}`).join(', ')} }`);\n else if (value instanceof Map)\n problems.push(`\"${key}\" has nested values, which SLICC doesn't read`);\n else problems.push(`\"${key}\" needs a scalar or a list of strings`);\n }\n return Object.fromEntries(fields);\n}\n\nfunction retryValue(raw: string, source: string): string | undefined {\n const scalar = parseDocument(source, {\n schema: 'core',\n customTags: [],\n resolveKnownTags: false,\n });\n const clean = !scalar.errors.length && !scalar.warnings.length;\n if (/^[[{]/.test(raw) && clean && isCollection(scalar.contents)) return undefined;\n const typed = clean && isScalar(scalar.contents) && typeof scalar.contents.value !== 'string';\n return typed ? raw : JSON.stringify(raw);\n}\n\nfunction tolerantSource(source: string): string {\n const lines = source.split('\\n');\n for (let index = 0; index < lines.length; index++) {\n const found = /^([A-Za-z][\\w-]*):[ \\t]+(.*)$/.exec(lines[index] as string);\n if (!found) continue;\n const value = (found[2] as string).replace(/[ \\t]+#.*$/, '').trim();\n if (\n !value ||\n value.startsWith('#') ||\n /^[\"']/.test(value) ||\n /^[|>](?:[1-9][+-]?|[+-][1-9]?)?$/.test(value)\n )\n continue;\n let raw = value;\n let blanks = 0;\n const continuation: string[] = [];\n for (let next = index + 1; next < lines.length; next++) {\n const line = lines[next] as string;\n if (!line.trim()) {\n continuation.push(line);\n blanks++;\n continue;\n }\n if (line.trimStart().startsWith('#')) {\n continuation.push(line);\n continue;\n }\n if (!/^[ \\t]/.test(line)) break;\n continuation.push(line);\n const continued = line.replace(/[ \\t]+#.*$/, '').trim();\n raw += `${blanks ? '\\n'.repeat(blanks) : ' '}${continued}`;\n blanks = 0;\n }\n const quoted = retryValue(raw, [found[2], ...continuation].join('\\n'));\n if (quoted === undefined) continue;\n for (let offset = 1; offset <= continuation.length; offset++) lines[index + offset] = '';\n lines[index] = `${found[1]}: ${quoted}`;\n }\n return lines.join('\\n');\n}\n\nexport function parseFrontmatter(text: string, mappings: readonly string[] = []): Frontmatter {\n const normalized = text.replace(/\\r\\n/g, '\\n');\n const match = /^---\\n([\\s\\S]*?)\\n---(?:\\n|$)/.exec(normalized);\n if (!match)\n return { fields: {}, body: normalized.trim(), problems: ['no frontmatter between --- lines'] };\n const body = normalized.slice(match[0].length).trim();\n let lineCounter = new LineCounter();\n const options = {\n schema: 'core',\n customTags: [],\n resolveKnownTags: false,\n stringKeys: true,\n uniqueKeys: false,\n };\n const source = `---\\n${match[1]}\\n`;\n let document = parseDocument(source, { ...options, lineCounter });\n if (document.errors.length) {\n lineCounter = new LineCounter();\n document = parseDocument(tolerantSource(source), { ...options, lineCounter });\n }\n const problems = [...document.errors, ...document.warnings].map((error) => error.message);\n if (problems.length) return { fields: {}, body, problems };\n let aliasOffset = 0;\n visit(document, (_, node) => {\n if (!isAlias(node)) return;\n aliasOffset = node.range?.[0] ?? 0;\n return visit.BREAK;\n });\n let parsed: unknown;\n try {\n parsed = document.toJS({ mapAsMap: true, maxAliasCount: 0 });\n } catch (error) {\n const { line } = lineCounter.linePos(aliasOffset);\n return { fields: {}, body, problems: [`${(error as Error).message} at line ${line}`] };\n }\n return { fields: fieldsFrom(parsed, mappings, problems), body, problems };\n}\n"],
5
+ "mappings": "AAAA,SAAS,SAAS,cAAc,UAAU,aAAa,eAAe,aAAa;AAUnF,SAAS,UAAU,OAAoD;AACrE,SAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU;AACpF;AAEA,SAAS,WACP,QACA,UACA,UACkC;AAClC,MAAI,WAAW,KAAM,QAAO,CAAC;AAC7B,MAAI,EAAE,kBAAkB,MAAM;AAC5B,aAAS,KAAK,+BAA+B;AAC7C,WAAO,CAAC;AAAA,EACV;AACA,QAAM,SAAS,oBAAI,IAA8B;AACjD,aAAW,CAAC,KAAK,KAAK,KAAK,QAAQ;AACjC,QAAI,UAAU,KAAK,EAAG,QAAO,IAAI,KAAK,KAAK;AAAA,aAClC,UAAU,KAAM,QAAO,IAAI,KAAK,CAAC,CAAC;AAAA,aAClC,MAAM,QAAQ,KAAK,KAAK,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AA,IACd,QAAQ;AAAA,IACR,YAAY,CAAC;AAAA,IACb,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ,YAAY;AAAA,EACd;AACA,QAAM,SAAS;AAAA,EAAQ,MAAM,CAAC,CAAC;AAAA;AAC/B,MAAI,WAAW,cAAc,QAAQ,EAAE,GAAG,SAAS,YAAY,CAAC;AAChE,MAAI,SAAS,OAAO,QAAQ;AAC1B,kBAAc,IAAI,YAAY;AAC9B,eAAW,cAAc,eAAe,MAAM,GAAG,EAAE,GAAG,SAAS,YAAY,CAAC;AAAA,EAC9E;AACA,QAAM,WAAW,CAAC,GAAG,SAAS,QAAQ,GAAG,SAAS,QAAQ,EAAE,IAAI,CAAC,UAAU,MAAM,OAAO;AACxF,MAAI,SAAS,OAAQ,QAAO,EAAE,QAAQ,CAAC,GAAG,MAAM,SAAS;AACzD,MAAI,cAAc;AAClB,QAAM,UAAU,CAAC,GAAG,SAAS;AAC3B,QAAI,CAAC,QAAQ,IAAI,EAAG;AACpB,kBAAc,KAAK,QAAQ,CAAC,KAAK;AACjC,WAAO,MAAM;AAAA,EACf,CAAC;AACD,MAAI;AACJ,MAAI;AACF,aAAS,SAAS,KAAK,EAAE,UAAU,MAAM,eAAe,EAAE,CAAC;AAAA,EAC7D,SAAS,OAAO;AACd,UAAM,EAAE,KAAK,IAAI,YAAY,QAAQ,WAAW;AAChD,WAAO,EAAE,QAAQ,CAAC,GAAG,MAAM,UAAU,CAAC,GAAI,MAAgB,OAAO,YAAY,IAAI,EAAE,EAAE;AAAA,EACvF;AACA,SAAO,EAAE,QAAQ,WAAW,QAAQ,UAAU,QAAQ,GAAG,MAAM,SAAS;AAC1E;",
6
+ "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-agent",
3
- "version": "7.13.0",
3
+ "version": "7.13.1",
4
4
  "description": "SLICC's agent core on pi durable: an agent worker, session storage, remoting and pi extensions",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -102,7 +102,8 @@
102
102
  "@earendil-works/pi-mcp": "1.5.0",
103
103
  "@earendil-works/pi-schema": "1.5.0",
104
104
  "@earendil-works/pi-telemetry": "1.5.0",
105
- "@sqlite.org/sqlite-wasm": "3.53.4-build2"
105
+ "@sqlite.org/sqlite-wasm": "3.53.4-build2",
106
+ "yaml": "2.9.1"
106
107
  },
107
108
  "peerDependencies": {
108
109
  "@ai-ecoverse/slicc-kernel": ">=1.171.0 <2",