@aidenhq/sdk 0.5.4 → 0.5.6
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 +2 -2
- package/dist/assets/page-kit.css +142 -0
- package/dist/assets/page-kit.js +311 -0
- package/dist/src/card-words.d.ts +8 -0
- package/dist/src/card-words.js +29 -0
- package/dist/src/event-send.d.ts +4 -2
- package/dist/src/event-send.js +28 -10
- package/dist/src/face-kit.d.ts +20 -0
- package/dist/src/face-kit.js +32 -0
- package/dist/src/module-mcp.d.ts +39 -0
- package/dist/src/module-mcp.js +80 -0
- package/dist/src/number-setting.d.ts +11 -0
- package/dist/src/number-setting.js +27 -0
- package/dist/src/reason-codes.d.ts +14 -0
- package/dist/src/reason-codes.js +45 -0
- package/dist/src/requested-parent.d.ts +33 -0
- package/dist/src/requested-parent.js +56 -0
- package/dist/src/schedule.d.ts +52 -0
- package/dist/src/schedule.js +653 -0
- package/dist/src/teammate-name.d.ts +4 -0
- package/dist/src/teammate-name.js +25 -0
- package/dist/src/url-setting.d.ts +5 -0
- package/dist/src/url-setting.js +49 -0
- package/package.json +10 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// A teammate's name (its default in the module, or the owner's rename: overrides.agents.<key>.name): one rule for the
|
|
2
|
+
// compiler (scripts/modules.ts), the board's settings change and the kernel's (a synced copy, scripts/sync-shared.ts).
|
|
3
|
+
// The name must be addressable: chat's @name (services/board/src/chats.ts norm) and the task tools match every agent by
|
|
4
|
+
// name or key, so it may not collide with any other agent's, hidden ones included. A task comment's @handle is the name
|
|
5
|
+
// without its spaces (services/board/src/crew.ts mentionedAgents): letters, digits and - only, and unique too.
|
|
6
|
+
const norm = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
7
|
+
// One space between words: chat's @name parser takes a single separator.
|
|
8
|
+
const SHAPE = /^[A-Za-z][A-Za-z0-9 -]{0,23}$/;
|
|
9
|
+
const handle = (s) => s.replace(/\s+/g, "").toLowerCase();
|
|
10
|
+
/** Why `name` can't be agent `key`'s name among `agents` (every compiled agent), or undefined when it can. */
|
|
11
|
+
export function teammateNameProblem(name, key, agents) {
|
|
12
|
+
if (typeof name !== "string" || !SHAPE.test(name) || name.trim() !== name || name.includes(" ") || name.split(" ").length > 4)
|
|
13
|
+
return "a name is 1 to 24 letters, digits, spaces or -, at most 4 words";
|
|
14
|
+
const n = norm(name);
|
|
15
|
+
const h = handle(name);
|
|
16
|
+
for (const [k, a] of Object.entries(agents)) {
|
|
17
|
+
if (k === key)
|
|
18
|
+
continue;
|
|
19
|
+
if (norm(String(a.name ?? "")) === n || handle(String(a.name ?? "")) === h)
|
|
20
|
+
return `${name} is already an agent's name`;
|
|
21
|
+
if (norm(k) === n)
|
|
22
|
+
return `${n} is an agent's key`;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const URL_MAX = 500;
|
|
2
|
+
/** Whether `host` matches `pattern`: exact, or `*.example.com` for any subdomain of example.com (not example.com itself). */
|
|
3
|
+
export declare function hostMatches(host: string, pattern: string): boolean;
|
|
4
|
+
/** Why `value` can't be this setting's URL, or null when it can. An empty value means not set, and is fine. */
|
|
5
|
+
export declare function urlSettingProblem(value: unknown, host?: string): string | null;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// A URL setting (module.yaml `type: url`, optional `host:` pattern): one check for the board (the owner's feedback as he
|
|
2
|
+
// types) and the compiler (the gate: an agent writes the commit). Plain TypeScript Node runs as is (scripts/modules.ts
|
|
3
|
+
// imports this file directly); the board holds a synced copy (scripts/sync-shared.ts). docs/design/settings-changes.md.
|
|
4
|
+
/** Query parameters whose name says they carry a credential: those belong in the vault, never in a setting. */
|
|
5
|
+
const SECRET_PARAM = /token|key|secret|sig|password|passwd|auth|code|session|credential/i;
|
|
6
|
+
export const URL_MAX = 500;
|
|
7
|
+
/** Whether `host` matches `pattern`: exact, or `*.example.com` for any subdomain of example.com (not example.com itself). */
|
|
8
|
+
export function hostMatches(host, pattern) {
|
|
9
|
+
const h = host.toLowerCase();
|
|
10
|
+
const p = pattern.toLowerCase();
|
|
11
|
+
return p.startsWith("*.") ? h.endsWith(p.slice(1)) && h.length > p.length - 1 : h === p;
|
|
12
|
+
}
|
|
13
|
+
/** Why `value` can't be this setting's URL, or null when it can. An empty value means not set, and is fine. */
|
|
14
|
+
export function urlSettingProblem(value, host) {
|
|
15
|
+
if (value === "" || value == null)
|
|
16
|
+
return null;
|
|
17
|
+
if (typeof value !== "string")
|
|
18
|
+
return "a URL is text";
|
|
19
|
+
if (value.length > URL_MAX)
|
|
20
|
+
return `at most ${URL_MAX} characters`;
|
|
21
|
+
// `$` would be expanded by Docker Compose (the value lands in a compose file): `${SOME_SECRET}` would leave in a request.
|
|
22
|
+
if (/[\s\x00-\x1f\x7f$]/.test(value))
|
|
23
|
+
return "no spaces, control characters or $";
|
|
24
|
+
let u;
|
|
25
|
+
try {
|
|
26
|
+
u = new URL(value);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return "not a URL (it starts with https://)";
|
|
30
|
+
}
|
|
31
|
+
if (u.protocol !== "https:")
|
|
32
|
+
return "https:// only";
|
|
33
|
+
if (u.username || u.password)
|
|
34
|
+
return "no user name or password in the URL: sign in with Connect instead";
|
|
35
|
+
if (u.hash)
|
|
36
|
+
return "no #fragment";
|
|
37
|
+
// A trailing dot ("localhost.") names the same host: refuse it rather than let it slip past the checks below.
|
|
38
|
+
if (u.hostname.endsWith("."))
|
|
39
|
+
return "a host name without a trailing dot";
|
|
40
|
+
const name = u.hostname.toLowerCase();
|
|
41
|
+
if (!name.includes(".") || /^\[|^[\d.]+$/.test(name) || /(^|\.)(localhost|local|internal|home|lan)$/i.test(name))
|
|
42
|
+
return "a public host name (not an IP address or a local name)";
|
|
43
|
+
if (host && !hostMatches(name, host))
|
|
44
|
+
return `the host must be ${host.startsWith("*.") ? `a ${host.slice(2)} address (${host})` : host}`;
|
|
45
|
+
const secret = [...u.searchParams.keys()].find((k) => SECRET_PARAM.test(k));
|
|
46
|
+
if (secret)
|
|
47
|
+
return `no credentials in the URL (the "${secret}" parameter): connections sign in with Connect, and secrets live in the vault`;
|
|
48
|
+
return null;
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidenhq/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "The shared code of AidenHQ modules: contract types, engine IO, the caller check and fence, write executors, the reviewer side, the judges' models and call, the source writer and the vendor MCP pass-through.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -53,6 +53,15 @@
|
|
|
53
53
|
"./task-state-types": "./dist/src/task-state-types.js",
|
|
54
54
|
"./tiers": "./dist/src/tiers.js",
|
|
55
55
|
"./tools-client": "./dist/src/tools-client.js",
|
|
56
|
+
"./module-mcp": "./dist/src/module-mcp.js",
|
|
57
|
+
"./schedule": "./dist/src/schedule.js",
|
|
58
|
+
"./reason-codes": "./dist/src/reason-codes.js",
|
|
59
|
+
"./card-words": "./dist/src/card-words.js",
|
|
60
|
+
"./url-setting": "./dist/src/url-setting.js",
|
|
61
|
+
"./number-setting": "./dist/src/number-setting.js",
|
|
62
|
+
"./teammate-name": "./dist/src/teammate-name.js",
|
|
63
|
+
"./face-kit": "./dist/src/face-kit.js",
|
|
64
|
+
"./requested-parent": "./dist/src/requested-parent.js",
|
|
56
65
|
"./vendor/needs": "./dist/src/vendor/needs.js"
|
|
57
66
|
},
|
|
58
67
|
"files": ["dist", "LICENSE"],
|