@maiaos/agent 0.1.0-canary.7 → 0.1.0-canary.70

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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -13
  3. package/dist/config/config.d.ts +28 -0
  4. package/dist/config/config.d.ts.map +1 -0
  5. package/dist/config/config.js +69 -0
  6. package/dist/config/config.js.map +1 -0
  7. package/dist/config/index.d.ts +6 -0
  8. package/dist/config/index.d.ts.map +1 -0
  9. package/dist/config/index.js +6 -0
  10. package/dist/config/index.js.map +1 -0
  11. package/dist/config/load.d.ts +11 -0
  12. package/dist/config/load.d.ts.map +1 -0
  13. package/dist/config/load.js +37 -0
  14. package/dist/config/load.js.map +1 -0
  15. package/dist/config/log-level.d.ts +8 -0
  16. package/dist/config/log-level.d.ts.map +1 -0
  17. package/dist/config/log-level.js +12 -0
  18. package/dist/config/log-level.js.map +1 -0
  19. package/dist/config/panel-origin.d.ts +17 -0
  20. package/dist/config/panel-origin.d.ts.map +1 -0
  21. package/dist/config/panel-origin.js +31 -0
  22. package/dist/config/panel-origin.js.map +1 -0
  23. package/dist/config/schema.d.ts +101 -0
  24. package/dist/config/schema.d.ts.map +1 -0
  25. package/dist/config/schema.js +213 -0
  26. package/dist/config/schema.js.map +1 -0
  27. package/dist/config/toml.d.ts +25 -0
  28. package/dist/config/toml.d.ts.map +1 -0
  29. package/dist/config/toml.js +114 -0
  30. package/dist/config/toml.js.map +1 -0
  31. package/dist/extensions/question/extension.d.ts +4 -0
  32. package/dist/extensions/question/extension.d.ts.map +1 -0
  33. package/dist/extensions/question/extension.js +32 -0
  34. package/dist/extensions/question/extension.js.map +1 -0
  35. package/dist/extensions/question/index.d.ts +3 -0
  36. package/dist/extensions/question/index.d.ts.map +1 -0
  37. package/dist/extensions/question/index.js +3 -0
  38. package/dist/extensions/question/index.js.map +1 -0
  39. package/dist/extensions/question/rpc-extension.d.ts +10 -0
  40. package/dist/extensions/question/rpc-extension.d.ts.map +1 -0
  41. package/dist/extensions/question/rpc-extension.js +15 -0
  42. package/dist/extensions/question/rpc-extension.js.map +1 -0
  43. package/dist/extensions/question/worktree-guard.d.ts +8 -0
  44. package/dist/extensions/question/worktree-guard.d.ts.map +1 -0
  45. package/dist/extensions/question/worktree-guard.js +41 -0
  46. package/dist/extensions/question/worktree-guard.js.map +1 -0
  47. package/dist/home/index.d.ts +1 -1
  48. package/dist/home/index.d.ts.map +1 -1
  49. package/dist/home/index.js +1 -1
  50. package/dist/home/index.js.map +1 -1
  51. package/dist/home/maia-home.d.ts +1 -12
  52. package/dist/home/maia-home.d.ts.map +1 -1
  53. package/dist/home/maia-home.js +2 -78
  54. package/dist/home/maia-home.js.map +1 -1
  55. package/dist/index.d.ts +2 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/managed-worker/main.js +3657 -3126
  60. package/dist/managed-worker/main.meta.json +1 -1
  61. package/dist/resources/agents-files.d.ts +32 -0
  62. package/dist/resources/agents-files.d.ts.map +1 -0
  63. package/dist/resources/agents-files.js +74 -0
  64. package/dist/resources/agents-files.js.map +1 -0
  65. package/dist/resources/resources.d.ts +14 -10
  66. package/dist/resources/resources.d.ts.map +1 -1
  67. package/dist/resources/resources.js +36 -69
  68. package/dist/resources/resources.js.map +1 -1
  69. package/dist/runner/runner.d.ts +3 -0
  70. package/dist/runner/runner.d.ts.map +1 -1
  71. package/dist/runner/runner.js +42 -19
  72. package/dist/runner/runner.js.map +1 -1
  73. package/dist/runtime/kernel.d.ts +4 -0
  74. package/dist/runtime/kernel.d.ts.map +1 -1
  75. package/dist/runtime/kernel.js +4 -0
  76. package/dist/runtime/kernel.js.map +1 -1
  77. package/dist/runtime/runtime.d.ts +3 -1
  78. package/dist/runtime/runtime.d.ts.map +1 -1
  79. package/dist/runtime/runtime.js +4 -7
  80. package/dist/runtime/runtime.js.map +1 -1
  81. package/package.json +8 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VLLNT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -5,9 +5,10 @@ runs, both built on the official
5
5
  [`@earendil-works/pi-coding-agent`](https://www.npmjs.com/package/@earendil-works/pi-coding-agent)
6
6
  SDK.
7
7
 
8
- > **Pre-release.** npm carries only `nightly` and `canary` builds, which are
9
- > not release-qualified. No stable release exists
10
- > ([D-132](https://github.com/vllnt/maia/blob/main/docs/decisions.md#d-132)).
8
+ > **Pre-release.** Maia publishes `canary` builds to npm only, and `latest` follows the newest
9
+ > one (earlier nightly builds are historical). They are not release-qualified,
10
+ > and Maia has no stable release
11
+ > ([D-202](https://maia-os.vllnt.com/en/docs/decisions#d-202)).
11
12
 
12
13
  ## Requirements
13
14
 
@@ -18,11 +19,11 @@ Node.js 24.22.1.
18
19
  `maia agent` ships with the `maia` CLI:
19
20
 
20
21
  ```sh
21
- pnpm add -g @maiaos/cli@nightly
22
+ pnpm add -g @maiaos/cli@canary
22
23
  ```
23
24
 
24
25
  To embed the library in your own process, use
25
- `pnpm add @maiaos/agent@nightly`.
26
+ `pnpm add @maiaos/agent@canary`.
26
27
 
27
28
  ## Usage
28
29
 
@@ -33,13 +34,18 @@ maia agent --json-events --no-session -- "Review the current diff"
33
34
  ```
34
35
 
35
36
  Pi supplies the agent loop, models, providers, TUI, sessions and extensions.
36
- Maia adds Maia-owned paths and credentials, digest-pinned project extensions
37
- and Skills, a few reviewed built-ins, and the boundary to Maia Node. It never
38
- runs an installed `pi` executable or reads `~/.pi`.
37
+ Maia adds Maia-owned paths and credentials, digest-pinned project Skills, a
38
+ few reviewed built-ins, and the boundary to Maia Node. It never runs an
39
+ installed `pi` executable or reads `~/.pi`.
39
40
 
40
- Every entry sets `PI_OFFLINE=1` and `PI_SKIP_VERSION_CHECK=1`. Project
41
- extension code runs with your operating-system permissions, so review it
42
- before you pin its digest.
41
+ `maia agent` loads an extension only when you name its path with
42
+ `--extension <path>`. A repository's own configuration cannot name one:
43
+ extension keys in `.maia/maia.json` are ignored. `--no-extensions` is accepted
44
+ and changes nothing, because Maia discovers no extensions. An extension you
45
+ name runs with your operating-system permissions, so review it before you
46
+ load it.
47
+
48
+ Every entry sets `PI_OFFLINE=1` and `PI_SKIP_VERSION_CHECK=1`.
43
49
 
44
50
  ## Status
45
51
 
@@ -48,7 +54,7 @@ Maia Agent as a general Node worker for swarms is planned.
48
54
 
49
55
  ## Links
50
56
 
51
- - [Agent architecture](https://github.com/vllnt/maia/blob/main/docs/maia-agent/architecture.md)
52
- - [CLI reference](https://github.com/vllnt/maia/blob/main/docs/reference/cli.md)
57
+ - [Agent architecture](https://maia-os.vllnt.com/en/docs/maia-agent/architecture)
58
+ - [CLI reference](https://maia-os.vllnt.com/en/docs/reference/cli)
53
59
  - [Security policy](https://github.com/vllnt/maia/blob/main/SECURITY.md)
54
60
  - [Repository](https://github.com/vllnt/maia)
@@ -0,0 +1,28 @@
1
+ import { type MaiaConfig } from "./schema.js";
2
+ import { type LineProblem } from "./toml.js";
3
+ declare const MaiaConfigError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
4
+ readonly _tag: "MaiaConfigError";
5
+ } & Readonly<A>;
6
+ /**
7
+ * A `config.toml` the schema refuses. Each problem names the key as
8
+ * `table.key`, what it expected and its line; `message` lists them as
9
+ * `file:line: table.key: expected ...`, one per line. Values are never quoted.
10
+ */
11
+ export declare class MaiaConfigError extends MaiaConfigError_base<{
12
+ readonly file: string;
13
+ readonly message: string;
14
+ readonly problems: readonly LineProblem[];
15
+ }> {
16
+ }
17
+ /**
18
+ * Decodes the text of a `config.toml` with `maiaConfigSchema`, defaults
19
+ * filled in. An empty text is a valid file. It throws `MaiaConfigError`,
20
+ * listing every syntax problem, unknown table or key, wrong type and value out
21
+ * of range. `file` names the file in each message.
22
+ */
23
+ export declare const parseMaiaConfig: (input: {
24
+ readonly file: string;
25
+ readonly text: string;
26
+ }) => MaiaConfig;
27
+ export {};
28
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,UAAU,EAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,WAAW,EAA+B,MAAM,WAAW,CAAC;;;;AAE1E;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,qBAAoC;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C,CAAC;CAAG;AAiDL;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,KAAG,UAeH,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { Data } from "effect";
2
+ import * as Result from "effect/Result";
3
+ import * as Schema from "effect/Schema";
4
+ import * as SchemaIssue from "effect/SchemaIssue";
5
+ import { maiaConfigSchema, STRICT_DECODING, } from "./schema.js";
6
+ import { readToml } from "./toml.js";
7
+ /**
8
+ * A `config.toml` the schema refuses. Each problem names the key as
9
+ * `table.key`, what it expected and its line; `message` lists them as
10
+ * `file:line: table.key: expected ...`, one per line. Values are never quoted.
11
+ */
12
+ export class MaiaConfigError extends Data.TaggedError("MaiaConfigError") {
13
+ }
14
+ const decodeConfig = Schema.decodeUnknownResult(maiaConfigSchema, STRICT_DECODING);
15
+ const formatIssue = SchemaIssue.makeFormatterStandardSchemaV1({
16
+ leafHook: (issue) => issue._tag === "UnexpectedKey"
17
+ ? "unknown setting"
18
+ : SchemaIssue.defaultLeafHook(issue),
19
+ });
20
+ /** Every problem the decoder lists, the first of each key: a value that breaks two checks of one key is one problem. */
21
+ const keyProblems = (issue) => {
22
+ const seen = new Set();
23
+ return formatIssue(issue).issues.flatMap(({ message, path = [] }) => {
24
+ const dotted = path
25
+ .map((segment) => String(typeof segment === "object" ? segment.key : segment))
26
+ .join(".");
27
+ if (seen.has(dotted))
28
+ return [];
29
+ seen.add(dotted);
30
+ return [{ dotted, message }];
31
+ });
32
+ };
33
+ const schemaProblems = (document, issue) => keyProblems(issue).map(({ dotted, message }) => ({
34
+ line: document.entries.get(dotted)?.line ?? 1,
35
+ message: `${dotted}: ${message}`,
36
+ }));
37
+ const fail = (file, problems) => {
38
+ const sorted = problems.toSorted((left, right) => left.line - right.line);
39
+ return new MaiaConfigError({
40
+ file,
41
+ message: sorted
42
+ .map(({ line, message }) => `${file}:${String(line)}: ${message}`)
43
+ .join("\n"),
44
+ problems: sorted,
45
+ });
46
+ };
47
+ /**
48
+ * Decodes the text of a `config.toml` with `maiaConfigSchema`, defaults
49
+ * filled in. An empty text is a valid file. It throws `MaiaConfigError`,
50
+ * listing every syntax problem, unknown table or key, wrong type and value out
51
+ * of range. `file` names the file in each message.
52
+ */
53
+ export const parseMaiaConfig = (input) => {
54
+ const document = readToml(input.text);
55
+ // A line the reader skipped leaves its key to a default, so the decoding of
56
+ // what it did read adds no false problem.
57
+ const decoded = decodeConfig(document.value);
58
+ const problems = [
59
+ ...document.problems,
60
+ ...(Result.isFailure(decoded)
61
+ ? schemaProblems(document, decoded.failure.issue)
62
+ : []),
63
+ ];
64
+ if (Result.isSuccess(decoded) && problems.length === 0) {
65
+ return decoded.success;
66
+ }
67
+ throw fail(input.file, problems);
68
+ };
69
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ export { MaiaConfigError, parseMaiaConfig } from "./config.js";
2
+ export { readMaiaConfig } from "./load.js";
3
+ export { minimumLogLevel } from "./log-level.js";
4
+ export { normalizePanelOrigin } from "./panel-origin.js";
5
+ export { type MaiaConfig, maiaConfigJsonSchema, type NodeSettings, } from "./schema.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,KAAK,UAAU,EACf,oBAAoB,EACpB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { MaiaConfigError, parseMaiaConfig } from "./config.js";
2
+ export { readMaiaConfig } from "./load.js";
3
+ export { minimumLogLevel } from "./log-level.js";
4
+ export { normalizePanelOrigin } from "./panel-origin.js";
5
+ export { maiaConfigJsonSchema, } from "./schema.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAEL,oBAAoB,GAErB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Effect } from "effect";
2
+ import * as FileSystem from "effect/FileSystem";
3
+ import { MaiaConfigError } from "./config.js";
4
+ import type { MaiaConfig } from "./schema.js";
5
+ /**
6
+ * The `config.toml` in the Maia home, decoded with defaults filled in. No
7
+ * file means the defaults; a file the process cannot open, or one the schema
8
+ * refuses, fails as `MaiaConfigError`.
9
+ */
10
+ export declare const readMaiaConfig: Effect.Effect<MaiaConfig, MaiaConfigError, FileSystem.FileSystem>;
11
+ //# sourceMappingURL=load.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/config/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAU,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkB9C;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,CACxC,UAAU,EACV,eAAe,EACf,UAAU,CAAC,UAAU,CAwBrB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { Config, Effect, Option } from "effect";
2
+ import * as FileSystem from "effect/FileSystem";
3
+ import { resolveMaiaConfigPath } from "../home/index.js";
4
+ import { MaiaConfigError, parseMaiaConfig } from "./config.js";
5
+ const mayBeMissing = Effect.orElseSucceed(Config.option(Config.String("MAIA_HOME")), Option.none);
6
+ const decode = (file, text) => Effect.suspend(() => {
7
+ try {
8
+ return Effect.succeed(parseMaiaConfig({ file, text }));
9
+ }
10
+ catch (error) {
11
+ return error instanceof MaiaConfigError
12
+ ? Effect.fail(error)
13
+ : Effect.die(error);
14
+ }
15
+ });
16
+ /**
17
+ * The `config.toml` in the Maia home, decoded with defaults filled in. No
18
+ * file means the defaults; a file the process cannot open, or one the schema
19
+ * refuses, fails as `MaiaConfigError`.
20
+ */
21
+ export const readMaiaConfig = Effect.gen(function* () {
22
+ const home = yield* mayBeMissing;
23
+ const file = resolveMaiaConfigPath(Option.match(home, {
24
+ onNone: () => ({}),
25
+ onSome: (maiaHome) => ({ ["MAIA_HOME"]: maiaHome }),
26
+ }));
27
+ const fileSystem = yield* FileSystem.FileSystem;
28
+ const text = yield* fileSystem.readFileString(file).pipe(Effect.catch((error) => error.reason._tag === "NotFound"
29
+ ? Effect.succeed("")
30
+ : Effect.fail(new MaiaConfigError({
31
+ file,
32
+ message: `${file}: the file could not be read.`,
33
+ problems: [],
34
+ }))));
35
+ return yield* decode(file, text);
36
+ });
37
+ //# sourceMappingURL=load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/config/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG/D,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CACvC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EACzC,MAAM,CAAC,IAAI,CACZ,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAC5C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;IAClB,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,YAAY,eAAe;YACrC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YACpB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAIvB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACtB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC;IACjC,MAAM,IAAI,GAAG,qBAAqB,CAChC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;QACjB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;QAClB,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAC;KACpD,CAAC,CACH,CAAC;IACF,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CACtD,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CACrB,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU;QAC9B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACpB,CAAC,CAAC,MAAM,CAAC,IAAI,CACT,IAAI,eAAe,CAAC;YAClB,IAAI;YACJ,OAAO,EAAE,GAAG,IAAI,+BAA+B;YAC/C,QAAQ,EAAE,EAAE;SACb,CAAC,CACH,CACN,CACF,CAAC;IACF,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { LogLevel } from "effect/LogLevel";
2
+ import type { MaiaConfig } from "./schema.js";
3
+ /**
4
+ * The Effect log level that `log.level` names: the least severe record that a
5
+ * log writes. The Node and the CLI both provide it as `MinimumLogLevel`.
6
+ */
7
+ export declare const minimumLogLevel: (config: MaiaConfig) => LogLevel;
8
+ //# sourceMappingURL=log-level.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-level.d.ts","sourceRoot":"","sources":["../../src/config/log-level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAS9C;;;GAGG;AACH,eAAO,MAAM,eAAe,WAAY,UAAU,KAAG,QAChB,CAAC"}
@@ -0,0 +1,12 @@
1
+ const MINIMUM_LOG_LEVEL = {
2
+ debug: "Debug",
3
+ error: "Error",
4
+ info: "Info",
5
+ warn: "Warn",
6
+ };
7
+ /**
8
+ * The Effect log level that `log.level` names: the least severe record that a
9
+ * log writes. The Node and the CLI both provide it as `MinimumLogLevel`.
10
+ */
11
+ export const minimumLogLevel = (config) => MINIMUM_LOG_LEVEL[config.log.level];
12
+ //# sourceMappingURL=log-level.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-level.js","sourceRoot":"","sources":["../../src/config/log-level.ts"],"names":[],"mappings":"AAIA,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACmD,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAkB,EAAY,EAAE,CAC9D,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The shape of the one extra origin the local web panel admits: `https://`, a
3
+ * host with an optional port, an optional single `/`, and no user, path, query
4
+ * or fragment. The published JSON Schema of `config.toml` carries this pattern;
5
+ * `normalizePanelOrigin` adds what a pattern cannot say (a host and port the
6
+ * URL parser accepts, and no control character).
7
+ */
8
+ export declare const PANEL_ORIGIN_PATTERN: RegExp;
9
+ /**
10
+ * The origin a browser sends for that address, as `https://host[:port]`: the
11
+ * host in lower case, the default port dropped. `undefined` when the text is
12
+ * not one HTTPS origin. The Node and `maia panel open --origin` both decide
13
+ * with this one function, and the Node compares what it returns, byte for byte,
14
+ * with the Host and Origin of a request.
15
+ */
16
+ export declare const normalizePanelOrigin: (text: string) => string | undefined;
17
+ //# sourceMappingURL=panel-origin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-origin.d.ts","sourceRoot":"","sources":["../../src/config/panel-origin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAAiC,CAAC;AAiBnE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,SAAU,MAAM,KAAG,MAAM,GAAG,SAG9C,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The shape of the one extra origin the local web panel admits: `https://`, a
3
+ * host with an optional port, an optional single `/`, and no user, path, query
4
+ * or fragment. The published JSON Schema of `config.toml` carries this pattern;
5
+ * `normalizePanelOrigin` adds what a pattern cannot say (a host and port the
6
+ * URL parser accepts, and no control character).
7
+ */
8
+ export const PANEL_ORIGIN_PATTERN = /^https:\/\/[^/\\?#@\s]+\/?$/u;
9
+ const encoder = new TextEncoder();
10
+ const SPACE = 32;
11
+ const DELETE = 127;
12
+ /**
13
+ * A C0 control or DEL. The URL parser strips a trailing one, so a text that
14
+ * ends in one would read as another origin than the one it spells. This is a
15
+ * check of the text, not of the pattern, which would need control characters
16
+ * in a regular expression, and the lint rules refuse those. Every byte of a
17
+ * multi-byte UTF-8 character is 128 or above, so a byte below 32, or 127, is
18
+ * always a control.
19
+ */
20
+ const hasControl = (text) => encoder.encode(text).some((byte) => byte < SPACE || byte === DELETE);
21
+ /**
22
+ * The origin a browser sends for that address, as `https://host[:port]`: the
23
+ * host in lower case, the default port dropped. `undefined` when the text is
24
+ * not one HTTPS origin. The Node and `maia panel open --origin` both decide
25
+ * with this one function, and the Node compares what it returns, byte for byte,
26
+ * with the Host and Origin of a request.
27
+ */
28
+ export const normalizePanelOrigin = (text) => PANEL_ORIGIN_PATTERN.test(text) && !hasControl(text) && URL.canParse(text)
29
+ ? new URL(text).origin
30
+ : undefined;
31
+ //# sourceMappingURL=panel-origin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-origin.js","sourceRoot":"","sources":["../../src/config/panel-origin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;AAEnE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,KAAK,GAAG,EAAE,CAAC;AACjB,MAAM,MAAM,GAAG,GAAG,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAClC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAsB,EAAE,CACvE,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM;IACtB,CAAC,CAAC,SAAS,CAAC"}
@@ -0,0 +1,101 @@
1
+ import * as Schema from "effect/Schema";
2
+ /**
3
+ * The one definition of `config.toml`: its decoder, its types and its JSON
4
+ * Schema all come from `maiaConfigSchema`. Every key has a type and a range,
5
+ * and a default unless an absent key means "the agent chooses". A new table
6
+ * is one more field here, with the key that reads it.
7
+ */
8
+ /** Strict: an unknown key or table fails, and the decoder lists every problem. */
9
+ export declare const STRICT_DECODING: {
10
+ readonly errors: "all";
11
+ readonly onExcessProperty: "error";
12
+ };
13
+ declare const nodeTable: Schema.Struct<{
14
+ autoResumeLimit: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
15
+ compileCache: Schema.withDecodingDefaultTypeKey<Schema.Boolean, never>;
16
+ defaultAccountSessions: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
17
+ headlessApprovals: Schema.withDecodingDefaultTypeKey<Schema.Literals<readonly ["on", "off"]>, never>;
18
+ headroomEnabled: Schema.withDecodingDefaultTypeKey<Schema.Boolean, never>;
19
+ hostAuthority: Schema.withDecodingDefaultTypeKey<Schema.Literals<readonly ["disabled", "enabled"]>, never>;
20
+ maxActiveSessions: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
21
+ maxLoadPerCpu: Schema.withDecodingDefaultTypeKey<Schema.Finite, never>;
22
+ minDiskFreeGib: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
23
+ minDiskFreePercent: Schema.withDecodingDefaultTypeKey<Schema.Finite, never>;
24
+ minMemoryAvailablePercent: Schema.withDecodingDefaultTypeKey<Schema.Finite, never>;
25
+ panelOrigin: Schema.optionalKey<Schema.String>;
26
+ portRange: Schema.withDecodingDefaultTypeKey<Schema.String, never>;
27
+ secretStore: Schema.optionalKey<Schema.Literals<readonly ["local", "managed"]>>;
28
+ turnAttachmentMaxBytes: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
29
+ turnAttachmentTypes: Schema.withDecodingDefaultTypeKey<Schema.String, never>;
30
+ warnMemoryAvailablePercent: Schema.withDecodingDefaultTypeKey<Schema.Finite, never>;
31
+ }>;
32
+ /** The `[node]` table as decoded, defaults filled in. */
33
+ export type NodeSettings = typeof nodeTable.Type;
34
+ export declare const maiaConfigSchema: Schema.encodeKeys<Schema.Struct<{
35
+ readonly agent: Schema.withDecodingDefaultKey<Schema.Struct<{
36
+ readonly model: Schema.optionalKey<Schema.String>;
37
+ readonly thinking: Schema.optionalKey<Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh"]>>;
38
+ }>, never>;
39
+ readonly log: Schema.withDecodingDefaultKey<Schema.Struct<{
40
+ readonly level: Schema.withDecodingDefaultTypeKey<Schema.Literals<readonly ["error", "warn", "info", "debug"]>, never>;
41
+ }>, never>;
42
+ readonly network: Schema.withDecodingDefaultKey<Schema.decodeTo<Schema.Struct<{
43
+ readonly caFile: Schema.optionalKey<Schema.String>;
44
+ readonly httpsProxy: Schema.optionalKey<Schema.String>;
45
+ }>, Schema.Struct<{
46
+ readonly ca_file: Schema.toEncoded<Schema.optionalKey<Schema.String>>;
47
+ readonly https_proxy: Schema.toEncoded<Schema.optionalKey<Schema.String>>;
48
+ }>, never, never>, never>;
49
+ readonly node: Schema.withDecodingDefaultKey<Schema.decodeTo<Schema.Struct<{
50
+ autoResumeLimit: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
51
+ compileCache: Schema.withDecodingDefaultTypeKey<Schema.Boolean, never>;
52
+ defaultAccountSessions: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
53
+ headlessApprovals: Schema.withDecodingDefaultTypeKey<Schema.Literals<readonly ["on", "off"]>, never>;
54
+ headroomEnabled: Schema.withDecodingDefaultTypeKey<Schema.Boolean, never>;
55
+ hostAuthority: Schema.withDecodingDefaultTypeKey<Schema.Literals<readonly ["disabled", "enabled"]>, never>;
56
+ maxActiveSessions: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
57
+ maxLoadPerCpu: Schema.withDecodingDefaultTypeKey<Schema.Finite, never>;
58
+ minDiskFreeGib: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
59
+ minDiskFreePercent: Schema.withDecodingDefaultTypeKey<Schema.Finite, never>;
60
+ minMemoryAvailablePercent: Schema.withDecodingDefaultTypeKey<Schema.Finite, never>;
61
+ panelOrigin: Schema.optionalKey<Schema.String>;
62
+ portRange: Schema.withDecodingDefaultTypeKey<Schema.String, never>;
63
+ secretStore: Schema.optionalKey<Schema.Literals<readonly ["local", "managed"]>>;
64
+ turnAttachmentMaxBytes: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
65
+ turnAttachmentTypes: Schema.withDecodingDefaultTypeKey<Schema.String, never>;
66
+ warnMemoryAvailablePercent: Schema.withDecodingDefaultTypeKey<Schema.Finite, never>;
67
+ }>, Schema.Struct<{
68
+ auto_resume_limit: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Int, never>>;
69
+ compile_cache: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Boolean, never>>;
70
+ default_account_sessions: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Int, never>>;
71
+ headless_approvals: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Literals<readonly ["on", "off"]>, never>>;
72
+ headroom_enabled: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Boolean, never>>;
73
+ host_authority: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Literals<readonly ["disabled", "enabled"]>, never>>;
74
+ max_active_sessions: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Int, never>>;
75
+ max_load_per_cpu: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Finite, never>>;
76
+ min_disk_free_gib: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Int, never>>;
77
+ min_disk_free_percent: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Finite, never>>;
78
+ min_memory_available_percent: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Finite, never>>;
79
+ panel_origin: Schema.toEncoded<Schema.optionalKey<Schema.String>>;
80
+ port_range: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.String, never>>;
81
+ secret_store: Schema.toEncoded<Schema.optionalKey<Schema.Literals<readonly ["local", "managed"]>>>;
82
+ turn_attachment_max_bytes: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Int, never>>;
83
+ turn_attachment_types: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.String, never>>;
84
+ warn_memory_available_percent: Schema.toEncoded<Schema.withDecodingDefaultTypeKey<Schema.Finite, never>>;
85
+ }>, never, never>, never>;
86
+ readonly runtime: Schema.withDecodingDefaultKey<Schema.Struct<{
87
+ readonly profile: Schema.withDecodingDefaultTypeKey<Schema.String, never>;
88
+ }>, never>;
89
+ readonly schemaVersion: Schema.withDecodingDefaultTypeKey<Schema.Int, never>;
90
+ readonly telemetry: Schema.withDecodingDefaultKey<Schema.Struct<{
91
+ readonly enabled: Schema.withDecodingDefaultTypeKey<Schema.Boolean, never>;
92
+ }>, never>;
93
+ }>, {
94
+ readonly schemaVersion: "schema_version";
95
+ }>;
96
+ /** A decoded `config.toml`, defaults filled in. */
97
+ export type MaiaConfig = typeof maiaConfigSchema.Type;
98
+ /** The draft-07 JSON Schema of `config.toml`, generated from `maiaConfigSchema`. */
99
+ export declare const maiaConfigJsonSchema: () => Readonly<Record<string, unknown>>;
100
+ export {};
101
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC;;;;;GAKG;AAEH,kFAAkF;AAClF,eAAO,MAAM,eAAe;aAC1B,MAAM,EAAE,KAAK;aACb,gBAAgB,EAAE,OAAO;CACjB,CAAC;AA4QX,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;EAA4B,CAAC;AAE5C,yDAAyD;AACzD,MAAM,MAAM,YAAY,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAEjD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6FkC,CAAC;AAEhE,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;AAEtD,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,QAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYvE,CAAC"}