librebot-tools 0.4.4 → 0.4.5
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 +7 -0
- package/package.json +6 -2
- package/src/contract.d.ts +25 -0
- package/src/contract.js +23 -0
- package/src/index.d.ts +4 -8
- package/src/index.js +8 -1
- package/src/parse.js +1 -1
- package/src/validate.js +4 -20
- package/test/gitlab-triggers.test.mjs +1 -1
package/README.md
CHANGED
|
@@ -122,6 +122,13 @@ import {
|
|
|
122
122
|
throws for invalid source (filesystem failures throw natively).
|
|
123
123
|
`parseBotSource(dir)` throws `BotSourceError` (with `.errors[]` /
|
|
124
124
|
`.warnings[]`) instead. Same contract for `validateFiles` / `parseBotFiles`.
|
|
125
|
+
- `librebot-tools/contract` exports the portable vocabulary with no Node
|
|
126
|
+
dependencies, so browsers can import it too: `FORMAT_VERSION`,
|
|
127
|
+
`MODEL_ROLES`, `REPO_CAPABILITIES`, `GITREPO_TRIGGER_EVENT_TYPES`,
|
|
128
|
+
`WHATSAPP_CAPABILITIES`, `WHATSAPP_TRIGGER_EVENT_TYPES` (frozen arrays), and
|
|
129
|
+
the derived `ModelRoleId`, `RepoCapability`, `WhatsAppCapability`,
|
|
130
|
+
`GitrepoTriggerEventType`, and `WhatsAppTriggerEventType` types. The root
|
|
131
|
+
entry re-exports the same values.
|
|
125
132
|
- No author-configured shell commands are executed. Standard skill
|
|
126
133
|
installation uses fixed CLI arguments only after explicit local
|
|
127
134
|
`--network --vendor` consent; source locators are passed as arguments,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "librebot-tools",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Public source-format tooling for Librebot bots: parse, validate, preview, scaffold, and skill-lock resolution.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -14,11 +14,15 @@
|
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./src/index.d.ts",
|
|
16
16
|
"default": "./src/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./contract": {
|
|
19
|
+
"types": "./src/contract.d.ts",
|
|
20
|
+
"default": "./src/contract.js"
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"types": "./src/index.d.ts",
|
|
20
24
|
"bin": {
|
|
21
|
-
"librebot": "
|
|
25
|
+
"librebot": "bin/librebot.js"
|
|
22
26
|
},
|
|
23
27
|
"files": [
|
|
24
28
|
"src/",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const FORMAT_VERSION: 1;
|
|
2
|
+
export const MODEL_ROLES: readonly ["default", "smol", "slow", "plan"];
|
|
3
|
+
export const REPO_CAPABILITIES: readonly [
|
|
4
|
+
"read_issue", "push_branch", "propose_change", "comment_issue",
|
|
5
|
+
"search_issues", "read_change_request", "read_repository",
|
|
6
|
+
"update_issue_labels", "react_issue", "update_issue_body", "update_issue_title",
|
|
7
|
+
"publish_attachments", "merge_change_request",
|
|
8
|
+
];
|
|
9
|
+
export const GITREPO_TRIGGER_EVENT_TYPES: readonly [
|
|
10
|
+
"issue.opened", "issue.updated", "issue.closed", "issue.reopened",
|
|
11
|
+
"issue.comment.created", "issue.comment.updated",
|
|
12
|
+
"change_request.opened", "change_request.updated", "change_request.closed",
|
|
13
|
+
"change_request.reopened", "change_request.merged", "change_request.commits_updated",
|
|
14
|
+
"change_request.checks_updated",
|
|
15
|
+
"change_request.comment.created", "change_request.comment.updated",
|
|
16
|
+
"change_request.approval_changed", "repository.pushed",
|
|
17
|
+
];
|
|
18
|
+
export const WHATSAPP_CAPABILITIES: readonly ["read_messages", "send_text", "set_reaction", "remove_reaction"];
|
|
19
|
+
export const WHATSAPP_TRIGGER_EVENT_TYPES: readonly ["message.created", "reaction.changed"];
|
|
20
|
+
|
|
21
|
+
export type ModelRoleId = typeof MODEL_ROLES[number];
|
|
22
|
+
export type RepoCapability = typeof REPO_CAPABILITIES[number];
|
|
23
|
+
export type GitrepoTriggerEventType = typeof GITREPO_TRIGGER_EVENT_TYPES[number];
|
|
24
|
+
export type WhatsAppCapability = typeof WHATSAPP_CAPABILITIES[number];
|
|
25
|
+
export type WhatsAppTriggerEventType = typeof WHATSAPP_TRIGGER_EVENT_TYPES[number];
|
package/src/contract.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Portable source-contract vocabulary. Dependency-free and browser-safe so
|
|
2
|
+
// platform UIs and servers can import it (`librebot-tools/contract`) instead
|
|
3
|
+
// of keeping their own copies of these lists.
|
|
4
|
+
|
|
5
|
+
export const FORMAT_VERSION = 1;
|
|
6
|
+
export const MODEL_ROLES = Object.freeze(["default", "smol", "slow", "plan"]);
|
|
7
|
+
export const REPO_CAPABILITIES = Object.freeze([
|
|
8
|
+
"read_issue", "push_branch", "propose_change", "comment_issue",
|
|
9
|
+
"search_issues", "read_change_request", "read_repository",
|
|
10
|
+
"update_issue_labels", "react_issue", "update_issue_body", "update_issue_title",
|
|
11
|
+
"publish_attachments", "merge_change_request",
|
|
12
|
+
]);
|
|
13
|
+
export const GITREPO_TRIGGER_EVENT_TYPES = Object.freeze([
|
|
14
|
+
"issue.opened", "issue.updated", "issue.closed", "issue.reopened",
|
|
15
|
+
"issue.comment.created", "issue.comment.updated",
|
|
16
|
+
"change_request.opened", "change_request.updated", "change_request.closed",
|
|
17
|
+
"change_request.reopened", "change_request.merged", "change_request.commits_updated",
|
|
18
|
+
"change_request.checks_updated",
|
|
19
|
+
"change_request.comment.created", "change_request.comment.updated",
|
|
20
|
+
"change_request.approval_changed", "repository.pushed",
|
|
21
|
+
]);
|
|
22
|
+
export const WHATSAPP_CAPABILITIES = Object.freeze(["read_messages", "send_text", "set_reaction", "remove_reaction"]);
|
|
23
|
+
export const WHATSAPP_TRIGGER_EVENT_TYPES = Object.freeze(["message.created", "reaction.changed"]);
|
package/src/index.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
export type RepoCapability = "read_issue" | "push_branch" | "propose_change" | "comment_issue" | "search_issues" | "read_change_request" | "read_repository" | "update_issue_labels" | "react_issue" | "update_issue_body" | "update_issue_title" | "publish_attachments" | "merge_change_request";
|
|
2
|
-
export type WhatsAppCapability = "read_messages" | "send_text" | "set_reaction" | "remove_reaction";
|
|
3
|
-
export const FORMAT_VERSION: 1;
|
|
4
|
-
export const MODEL_ROLES: string[];
|
|
5
|
-
export const REPO_CAPABILITIES: RepoCapability[];
|
|
6
|
-
export const GITREPO_TRIGGER_EVENT_TYPES: string[];
|
|
7
1
|
// Type definitions for librebot-tools (hand-written; no build step).
|
|
2
|
+
import type { ModelRoleId, RepoCapability, WhatsAppCapability } from "./contract.js";
|
|
3
|
+
export * from "./contract.js";
|
|
8
4
|
|
|
9
5
|
export interface SourceIssue {
|
|
10
6
|
file: string;
|
|
@@ -20,7 +16,7 @@ export interface ModelRequirements {
|
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
export interface BotModelRole {
|
|
23
|
-
role:
|
|
19
|
+
role: ModelRoleId;
|
|
24
20
|
label: string;
|
|
25
21
|
requirements: ModelRequirements;
|
|
26
22
|
}
|
|
@@ -62,7 +58,7 @@ export interface BotDraft {
|
|
|
62
58
|
knowledge: BotKnowledge[];
|
|
63
59
|
skills: BotSkill[];
|
|
64
60
|
connectors: BotConnector[];
|
|
65
|
-
triggers: Array<{ key: string; label: string; kind: "gitrepo" | "whatsapp"; eventTypes: string[]; description?: string; inputs?: Array<{ key: string; label?: string; type: "string" | "number" | "boolean" | "select"; required?: boolean; options?: string[]; help?: string }>; deciderRole?:
|
|
61
|
+
triggers: Array<{ key: string; label: string; kind: "gitrepo" | "whatsapp"; eventTypes: string[]; description?: string; inputs?: Array<{ key: string; label?: string; type: "string" | "number" | "boolean" | "select"; required?: boolean; options?: string[]; help?: string }>; deciderRole?: ModelRoleId; deciderInstructions: string; enabledByDefault?: boolean }>;
|
|
66
62
|
workspace: Array<{ key: string; label?: string; path: string }>;
|
|
67
63
|
actions: Array<{ key: string; kind: "gitrepo"; label?: string; capabilities: RepoCapability[] } | { key: string; kind: "whatsapp"; label?: string; capabilities: WhatsAppCapability[] }>;
|
|
68
64
|
icon?: string;
|
package/src/index.js
CHANGED
|
@@ -46,5 +46,12 @@ export {
|
|
|
46
46
|
} from "./scaffold.js";
|
|
47
47
|
export { SCHEMA_VERSIONS, loadSchema } from "./schema.js";
|
|
48
48
|
export { canonicalJson, sha256Hex, toBytes } from "./util.js";
|
|
49
|
-
export {
|
|
49
|
+
export {
|
|
50
|
+
FORMAT_VERSION,
|
|
51
|
+
MODEL_ROLES,
|
|
52
|
+
REPO_CAPABILITIES,
|
|
53
|
+
GITREPO_TRIGGER_EVENT_TYPES,
|
|
54
|
+
WHATSAPP_CAPABILITIES,
|
|
55
|
+
WHATSAPP_TRIGGER_EVENT_TYPES,
|
|
56
|
+
} from "./contract.js";
|
|
50
57
|
export { validateKnowledgeSources, validateRequirements } from "./validate.js";
|
package/src/parse.js
CHANGED
|
@@ -11,8 +11,8 @@ import { checkSourcesLock, parseSourcesYaml } from "./skills-lock.js";
|
|
|
11
11
|
import { sha256Hex, toBytes } from "./util.js";
|
|
12
12
|
import { vendorContentHash } from "./skills-import.js";
|
|
13
13
|
import { iconPath, validateIcon } from "./icon.js";
|
|
14
|
+
import { FORMAT_VERSION } from "./contract.js";
|
|
14
15
|
import {
|
|
15
|
-
FORMAT_VERSION,
|
|
16
16
|
entryId,
|
|
17
17
|
requiredString,
|
|
18
18
|
validateConnectors,
|
package/src/validate.js
CHANGED
|
@@ -7,24 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import { isRecord } from "./errors.js";
|
|
9
9
|
import { sha256Hex } from "./util.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"read_issue", "push_branch", "propose_change", "comment_issue",
|
|
15
|
-
"search_issues", "read_change_request", "read_repository",
|
|
16
|
-
"update_issue_labels", "react_issue", "update_issue_body", "update_issue_title",
|
|
17
|
-
"publish_attachments", "merge_change_request",
|
|
18
|
-
];
|
|
19
|
-
export const GITREPO_TRIGGER_EVENT_TYPES = [
|
|
20
|
-
"issue.opened", "issue.updated", "issue.closed", "issue.reopened",
|
|
21
|
-
"issue.comment.created", "issue.comment.updated",
|
|
22
|
-
"change_request.opened", "change_request.updated", "change_request.closed",
|
|
23
|
-
"change_request.reopened", "change_request.merged", "change_request.commits_updated",
|
|
24
|
-
"change_request.checks_updated",
|
|
25
|
-
"change_request.comment.created", "change_request.comment.updated",
|
|
26
|
-
"change_request.approval_changed", "repository.pushed",
|
|
27
|
-
];
|
|
10
|
+
import {
|
|
11
|
+
MODEL_ROLES, REPO_CAPABILITIES, GITREPO_TRIGGER_EVENT_TYPES,
|
|
12
|
+
WHATSAPP_CAPABILITIES, WHATSAPP_TRIGGER_EVENT_TYPES,
|
|
13
|
+
} from "./contract.js";
|
|
28
14
|
|
|
29
15
|
const ENTRY_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
30
16
|
const INPUT_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
@@ -549,8 +535,6 @@ export function validateWorkspaceMounts(input, sink, file) {
|
|
|
549
535
|
return mounts;
|
|
550
536
|
}
|
|
551
537
|
|
|
552
|
-
export const WHATSAPP_CAPABILITIES = ["read_messages", "send_text", "set_reaction", "remove_reaction"];
|
|
553
|
-
export const WHATSAPP_TRIGGER_EVENT_TYPES = ["message.created", "reaction.changed"];
|
|
554
538
|
export function validateActions(input, sink, file) {
|
|
555
539
|
if (input === undefined) return [];
|
|
556
540
|
if (!Array.isArray(input) || input.length > 20) {
|
|
@@ -6,7 +6,7 @@ import { join } from "node:path";
|
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
7
|
import { execFile } from "node:child_process";
|
|
8
8
|
import { parseBotFiles, scaffoldBotFiles, exportBotFiles } from "../src/index.js";
|
|
9
|
-
import { GITREPO_TRIGGER_EVENT_TYPES } from "../src/
|
|
9
|
+
import { GITREPO_TRIGGER_EVENT_TYPES } from "../src/contract.js";
|
|
10
10
|
|
|
11
11
|
const trigger = (overrides = {}) => ({ key: "project-events", label: "Project events", kind: "gitrepo", eventTypes: ["change_request.opened"], deciderInstructions: "Decide whether to act", ...overrides });
|
|
12
12
|
const source = (triggers) => ({ ...scaffoldBotFiles({ name: "Triggers" }), "bot.yaml": `formatVersion: 1\nname: Triggers\ndescription: D\nmodelRoles: [{role: default, label: Main}]\ntriggers: ${JSON.stringify(triggers)}\n` });
|