@maiaos/agent 0.1.0-canary.64 → 0.1.0-canary.65

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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -7
  3. package/dist/config/config.d.ts +44 -0
  4. package/dist/config/config.d.ts.map +1 -0
  5. package/dist/config/config.js +86 -0
  6. package/dist/config/config.js.map +1 -0
  7. package/dist/config/deprecated-variables.d.ts +38 -0
  8. package/dist/config/deprecated-variables.d.ts.map +1 -0
  9. package/dist/config/deprecated-variables.js +109 -0
  10. package/dist/config/deprecated-variables.js.map +1 -0
  11. package/dist/config/index.d.ts +7 -0
  12. package/dist/config/index.d.ts.map +1 -0
  13. package/dist/config/index.js +7 -0
  14. package/dist/config/index.js.map +1 -0
  15. package/dist/config/load.d.ts +11 -0
  16. package/dist/config/load.d.ts.map +1 -0
  17. package/dist/config/load.js +37 -0
  18. package/dist/config/load.js.map +1 -0
  19. package/dist/config/log-level.d.ts +8 -0
  20. package/dist/config/log-level.d.ts.map +1 -0
  21. package/dist/config/log-level.js +12 -0
  22. package/dist/config/log-level.js.map +1 -0
  23. package/dist/config/panel-origin.d.ts +17 -0
  24. package/dist/config/panel-origin.d.ts.map +1 -0
  25. package/dist/config/panel-origin.js +31 -0
  26. package/dist/config/panel-origin.js.map +1 -0
  27. package/dist/config/schema.d.ts +121 -0
  28. package/dist/config/schema.d.ts.map +1 -0
  29. package/dist/config/schema.js +215 -0
  30. package/dist/config/schema.js.map +1 -0
  31. package/dist/config/toml.d.ts +25 -0
  32. package/dist/config/toml.d.ts.map +1 -0
  33. package/dist/config/toml.js +114 -0
  34. package/dist/config/toml.js.map +1 -0
  35. package/dist/extensions/question/extension.d.ts +4 -0
  36. package/dist/extensions/question/extension.d.ts.map +1 -0
  37. package/dist/extensions/question/extension.js +32 -0
  38. package/dist/extensions/question/extension.js.map +1 -0
  39. package/dist/extensions/question/index.d.ts +3 -0
  40. package/dist/extensions/question/index.d.ts.map +1 -0
  41. package/dist/extensions/question/index.js +3 -0
  42. package/dist/extensions/question/index.js.map +1 -0
  43. package/dist/extensions/question/rpc-extension.d.ts +10 -0
  44. package/dist/extensions/question/rpc-extension.d.ts.map +1 -0
  45. package/dist/extensions/question/rpc-extension.js +15 -0
  46. package/dist/extensions/question/rpc-extension.js.map +1 -0
  47. package/dist/extensions/question/worktree-guard.d.ts +8 -0
  48. package/dist/extensions/question/worktree-guard.d.ts.map +1 -0
  49. package/dist/extensions/question/worktree-guard.js +41 -0
  50. package/dist/extensions/question/worktree-guard.js.map +1 -0
  51. package/dist/home/index.d.ts +1 -1
  52. package/dist/home/index.d.ts.map +1 -1
  53. package/dist/home/index.js +1 -1
  54. package/dist/home/index.js.map +1 -1
  55. package/dist/home/maia-home.d.ts +1 -12
  56. package/dist/home/maia-home.d.ts.map +1 -1
  57. package/dist/home/maia-home.js +2 -78
  58. package/dist/home/maia-home.js.map +1 -1
  59. package/dist/index.d.ts +2 -1
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +2 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/managed-worker/main.js +3657 -3126
  64. package/dist/managed-worker/main.meta.json +1 -1
  65. package/dist/resources/agents-files.d.ts +32 -0
  66. package/dist/resources/agents-files.d.ts.map +1 -0
  67. package/dist/resources/agents-files.js +74 -0
  68. package/dist/resources/agents-files.js.map +1 -0
  69. package/dist/resources/resources.d.ts +14 -10
  70. package/dist/resources/resources.d.ts.map +1 -1
  71. package/dist/resources/resources.js +36 -69
  72. package/dist/resources/resources.js.map +1 -1
  73. package/dist/runner/runner.d.ts +3 -0
  74. package/dist/runner/runner.d.ts.map +1 -1
  75. package/dist/runner/runner.js +38 -17
  76. package/dist/runner/runner.js.map +1 -1
  77. package/dist/runtime/kernel.d.ts +4 -0
  78. package/dist/runtime/kernel.d.ts.map +1 -1
  79. package/dist/runtime/kernel.js +4 -0
  80. package/dist/runtime/kernel.js.map +1 -1
  81. package/dist/runtime/runtime.d.ts +3 -1
  82. package/dist/runtime/runtime.d.ts.map +1 -1
  83. package/dist/runtime/runtime.js +4 -7
  84. package/dist/runtime/runtime.js.map +1 -1
  85. 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
@@ -34,13 +34,18 @@ maia agent --json-events --no-session -- "Review the current diff"
34
34
  ```
35
35
 
36
36
  Pi supplies the agent loop, models, providers, TUI, sessions and extensions.
37
- Maia adds Maia-owned paths and credentials, digest-pinned project extensions
38
- and Skills, a few reviewed built-ins, and the boundary to Maia Node. It never
39
- runs an installed `pi` executable or reads `~/.pi`.
40
-
41
- Every entry sets `PI_OFFLINE=1` and `PI_SKIP_VERSION_CHECK=1`. Project
42
- extension code runs with your operating-system permissions, so review it
43
- before you pin its digest.
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`.
40
+
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`.
44
49
 
45
50
  ## Status
46
51
 
@@ -0,0 +1,44 @@
1
+ import { type MaiaConfig, type NodeSettings } 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 type NodeSettingsCheck = {
28
+ readonly problems: readonly {
29
+ readonly key: keyof NodeSettings;
30
+ readonly message: string;
31
+ }[];
32
+ readonly settings?: undefined;
33
+ } | {
34
+ readonly problems?: undefined;
35
+ readonly settings: NodeSettings;
36
+ };
37
+ /**
38
+ * Checks a `[node]` value that did not come from the file, such as a
39
+ * deprecated variable's reading, against the same schema. A refusal lists one
40
+ * entry per key, in the schema's wording, and never the value.
41
+ */
42
+ export declare const checkNodeSettings: (candidate: unknown) => NodeSettingsCheck;
43
+ export {};
44
+ //# 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,EAEf,KAAK,YAAY,EAGlB,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;AAOF,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,CAAC,QAAQ,EAAE,SAAS;QAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,YAAY,CAAC;QACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;IACJ,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B,GACD;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,cAAe,OAAO,KAAG,iBAYtD,CAAC"}
@@ -0,0 +1,86 @@
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, nodeSettingsSchema, 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
+ const decodeNodeSettings = Schema.decodeUnknownResult(nodeSettingsSchema, STRICT_DECODING);
70
+ /**
71
+ * Checks a `[node]` value that did not come from the file, such as a
72
+ * deprecated variable's reading, against the same schema. A refusal lists one
73
+ * entry per key, in the schema's wording, and never the value.
74
+ */
75
+ export const checkNodeSettings = (candidate) => {
76
+ const decoded = decodeNodeSettings(candidate);
77
+ return Result.isSuccess(decoded)
78
+ ? { settings: decoded.success }
79
+ : {
80
+ problems: keyProblems(decoded.failure.issue).map(({ dotted, message }) => ({
81
+ key: dotted,
82
+ message,
83
+ })),
84
+ };
85
+ };
86
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAEL,gBAAgB,EAEhB,kBAAkB,EAClB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAoB,QAAQ,EAAqB,MAAM,WAAW,CAAC;AAE1E;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,IAAI,CAAC,WAAW,CAAC,iB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AAC;IACzB,CAAC;IACD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,MAAM,CAAC,mBAAmB,CACnD,kBAAkB,EAClB,eAAe,CAChB,CAAC;AAYF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,SAAkB,EAAqB,EAAE;IACzE,MAAM,OAAO,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;QAC9B,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE;QAC/B,CAAC,CAAC;YACE,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAC9C,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;gBACxB,GAAG,EAAE,MAA4B;gBACjC,OAAO;aACR,CAAC,CACH;SACF,CAAC;AACR,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { NodeSettings } from "./schema.js";
2
+ /**
3
+ * The canary line whose numbered builds carry the deprecated variables below.
4
+ * A build of any other line, such as `0.2.0-canary.1`, ignores them all.
5
+ */
6
+ export declare const DEPRECATED_VARIABLES_CANARY_LINE = "0.1.0";
7
+ /**
8
+ * An environment variable that a `config.toml` key replaced. It stays a
9
+ * deprecated alias up to `lastCanary`, the last canary of
10
+ * `DEPRECATED_VARIABLES_CANARY_LINE` that reads it; a build after that canary
11
+ * ignores it, and a tooling test names an entry that is still listed then. A
12
+ * build with the version `0.0.0`, one made from source, always reads it.
13
+ */
14
+ export type DeprecatedAlias = {
15
+ readonly lastCanary: number;
16
+ readonly variable: string;
17
+ };
18
+ /**
19
+ * The environment variables that moved into `[node]` of `config.toml` (CFG-1b).
20
+ * While a build reads one, a variable that the environment holds wins over the
21
+ * file, and the Node logs one warning that names it. The `kind` says how the
22
+ * Node reads the variable's text: an integer or a number; a boolean (`true`,
23
+ * `false`, `yes`, `no`, `on`, `off`, `1`, `0`); text as given; or one of the
24
+ * two fail-closed switches, where the exact word (`enabled`, `on`) turns the
25
+ * mode on and anything else, empty included, turns it off.
26
+ */
27
+ export type DeprecatedVariable = DeprecatedAlias & {
28
+ readonly key: keyof NodeSettings;
29
+ readonly kind: "boolean" | "enabled" | "integer" | "number" | "on" | "text";
30
+ };
31
+ export declare const DEPRECATED_VARIABLES: readonly DeprecatedVariable[];
32
+ /**
33
+ * The launcher reads the compile cache switch before the bundle loads, so it
34
+ * reads this alias, `MAIA_NODE_COMPILE_CACHE=0`, in plain code. It records its
35
+ * last canary here, and a test keeps the launcher's copy equal.
36
+ */
37
+ export declare const COMPILE_CACHE_ALIAS: DeprecatedAlias;
38
+ //# sourceMappingURL=deprecated-variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated-variables.d.ts","sourceRoot":"","sources":["../../src/config/deprecated-variables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,gCAAgC,UAAU,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,YAAY,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;CAC7E,CAAC;AAWF,eAAO,MAAM,oBAAoB,EAAE,SAAS,kBAAkB,EAqF7D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,eAGjC,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * The canary line whose numbered builds carry the deprecated variables below.
3
+ * A build of any other line, such as `0.2.0-canary.1`, ignores them all.
4
+ */
5
+ export const DEPRECATED_VARIABLES_CANARY_LINE = "0.1.0";
6
+ /**
7
+ * The first canary that carries these aliases, so the one canary that still
8
+ * reads them. The newest published canary was 64 when this change landed on
9
+ * its branch, and the next is 65. A build after it ignores the aliases. If
10
+ * another canary ships first, move this number, and the launcher's copy, to
11
+ * the first canary that ships the aliases.
12
+ */
13
+ const LAST_CANARY = 65;
14
+ export const DEPRECATED_VARIABLES = [
15
+ {
16
+ key: "autoResumeLimit",
17
+ kind: "integer",
18
+ lastCanary: LAST_CANARY,
19
+ variable: "MAIA_NODE_AUTO_RESUME_LIMIT",
20
+ },
21
+ {
22
+ key: "defaultAccountSessions",
23
+ kind: "integer",
24
+ lastCanary: LAST_CANARY,
25
+ variable: "MAIA_NODE_DEFAULT_ACCOUNT_SESSIONS",
26
+ },
27
+ {
28
+ key: "headlessApprovals",
29
+ kind: "on",
30
+ lastCanary: LAST_CANARY,
31
+ variable: "MAIA_NODE_HEADLESS_APPROVALS",
32
+ },
33
+ {
34
+ key: "headroomEnabled",
35
+ kind: "boolean",
36
+ lastCanary: LAST_CANARY,
37
+ variable: "MAIA_NODE_HEADROOM_ENABLED",
38
+ },
39
+ {
40
+ key: "hostAuthority",
41
+ kind: "enabled",
42
+ lastCanary: LAST_CANARY,
43
+ variable: "MAIA_HOST_AUTHORITY",
44
+ },
45
+ {
46
+ key: "maxActiveSessions",
47
+ kind: "integer",
48
+ lastCanary: LAST_CANARY,
49
+ variable: "MAIA_NODE_MAX_ACTIVE_SESSIONS",
50
+ },
51
+ {
52
+ key: "maxLoadPerCpu",
53
+ kind: "number",
54
+ lastCanary: LAST_CANARY,
55
+ variable: "MAIA_NODE_MAX_LOAD_PER_CPU",
56
+ },
57
+ {
58
+ key: "minDiskFreePercent",
59
+ kind: "number",
60
+ lastCanary: LAST_CANARY,
61
+ variable: "MAIA_NODE_MIN_DISK_FREE_PERCENT",
62
+ },
63
+ {
64
+ key: "minMemoryAvailablePercent",
65
+ kind: "number",
66
+ lastCanary: LAST_CANARY,
67
+ variable: "MAIA_NODE_MIN_MEMORY_AVAILABLE_PERCENT",
68
+ },
69
+ {
70
+ key: "portRange",
71
+ kind: "text",
72
+ lastCanary: LAST_CANARY,
73
+ variable: "MAIA_PORT_RANGE",
74
+ },
75
+ {
76
+ key: "secretStore",
77
+ kind: "text",
78
+ lastCanary: LAST_CANARY,
79
+ variable: "MAIA_SECRET_STORE",
80
+ },
81
+ {
82
+ key: "turnAttachmentMaxBytes",
83
+ kind: "integer",
84
+ lastCanary: LAST_CANARY,
85
+ variable: "MAIA_NODE_TURN_ATTACHMENT_MAX_BYTES",
86
+ },
87
+ {
88
+ key: "turnAttachmentTypes",
89
+ kind: "text",
90
+ lastCanary: LAST_CANARY,
91
+ variable: "MAIA_NODE_TURN_ATTACHMENT_TYPES",
92
+ },
93
+ {
94
+ key: "warnMemoryAvailablePercent",
95
+ kind: "number",
96
+ lastCanary: LAST_CANARY,
97
+ variable: "MAIA_NODE_WARN_MEMORY_AVAILABLE_PERCENT",
98
+ },
99
+ ];
100
+ /**
101
+ * The launcher reads the compile cache switch before the bundle loads, so it
102
+ * reads this alias, `MAIA_NODE_COMPILE_CACHE=0`, in plain code. It records its
103
+ * last canary here, and a test keeps the launcher's copy equal.
104
+ */
105
+ export const COMPILE_CACHE_ALIAS = {
106
+ lastCanary: LAST_CANARY,
107
+ variable: "MAIA_NODE_COMPILE_CACHE",
108
+ };
109
+ //# sourceMappingURL=deprecated-variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated-variables.js","sourceRoot":"","sources":["../../src/config/deprecated-variables.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,OAAO,CAAC;AA4BxD;;;;;;GAMG;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,MAAM;QACZ,UAAU,EAAE,WAAW;QACvB,QAAQ,EAAE,mBAAmB;KAC9B;IACD;QACE,GAAG,EAAE,wBAAwB;QAC7B,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,WAAW;QACvB,QAAQ,EAAE,qCAAqC;KAChD;IACD;QACE,GAAG,EAAE,qBAAqB;QAC1B,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,WAAW;QACvB,QAAQ,EAAE,iCAAiC;KAC5C;IACD;QACE,GAAG,EAAE,4BAA4B;QACjC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,WAAW;QACvB,QAAQ,EAAE,yCAAyC;KACpD;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAoB;IAClD,UAAU,EAAE,WAAW;IACvB,QAAQ,EAAE,yBAAyB;CACpC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { checkNodeSettings, MaiaConfigError, parseMaiaConfig, } from "./config.js";
2
+ export { COMPILE_CACHE_ALIAS, DEPRECATED_VARIABLES, DEPRECATED_VARIABLES_CANARY_LINE, type DeprecatedAlias, type DeprecatedVariable, } from "./deprecated-variables.js";
3
+ export { readMaiaConfig } from "./load.js";
4
+ export { minimumLogLevel } from "./log-level.js";
5
+ export { normalizePanelOrigin } from "./panel-origin.js";
6
+ export { type MaiaConfig, maiaConfigJsonSchema, type NodeSettings, } from "./schema.js";
7
+ //# 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,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,gCAAgC,EAChC,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,2BAA2B,CAAC;AACnC,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,7 @@
1
+ export { checkNodeSettings, MaiaConfigError, parseMaiaConfig, } from "./config.js";
2
+ export { COMPILE_CACHE_ALIAS, DEPRECATED_VARIABLES, DEPRECATED_VARIABLES_CANARY_LINE, } from "./deprecated-variables.js";
3
+ export { readMaiaConfig } from "./load.js";
4
+ export { minimumLogLevel } from "./log-level.js";
5
+ export { normalizePanelOrigin } from "./panel-origin.js";
6
+ export { maiaConfigJsonSchema, } from "./schema.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,gCAAgC,GAGjC,MAAM,2BAA2B,CAAC;AACnC,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"}