@wizardingcode/shibaox-schemas 0.1.0

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.
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod';
2
+ import { Id } from './common.js';
3
+ export const TaskNodeSchema = z.object({
4
+ type: z.literal('task'),
5
+ role: Id,
6
+ instruction: z.string().optional(),
7
+ next: Id.optional(),
8
+ });
9
+ export const CodeNodeSchema = z.object({
10
+ type: z.literal('code'),
11
+ command: z.string().min(1),
12
+ timeout_ms: z.number().int().positive().default(300_000),
13
+ next: Id.optional(),
14
+ });
15
+ export const HumanNodeSchema = z.object({
16
+ type: z.literal('human'),
17
+ action: Id,
18
+ prompt: z.string().optional(),
19
+ next: Id.optional(),
20
+ });
21
+ export const DecideNodeSchema = z.object({
22
+ type: z.literal('decide'),
23
+ by: Id,
24
+ question: z.string().optional(),
25
+ options: z.array(Id).min(2),
26
+ next: z.record(z.string(), Id),
27
+ });
28
+ export const GateNodeSchema = z.object({
29
+ type: z.literal('gate'),
30
+ gates: z.array(Id).min(1),
31
+ on_pass: Id,
32
+ on_fail: Id,
33
+ max_retries: z.number().int().min(0).default(3),
34
+ });
35
+ /**
36
+ * A git step the daemon runs itself (trusted org config, like `code`): `commit` the workspace,
37
+ * open a `pr` (push + `gh pr create`), or `merge` the run branch on the base through the
38
+ * project's merge queue (rebase, tests, fast-forward, push when there is a remote).
39
+ */
40
+ export const GitNodeSchema = z.object({
41
+ type: z.literal('git'),
42
+ action: z.enum(['commit', 'pr', 'merge']),
43
+ /** Commit message / PR body; generated from the request and the run when absent. */
44
+ message: z.string().optional(),
45
+ /** Base branch for `pr` and `merge` (default: the repository's default branch, else main). */
46
+ base: z.string().optional(),
47
+ /** Test command run before a merge (default: detected from the workspace; none skips). */
48
+ tests: z.string().optional(),
49
+ timeout_ms: z.number().int().positive().default(600_000),
50
+ next: Id.optional(),
51
+ });
52
+ export const ParallelNodeSchema = z.object({
53
+ type: z.literal('parallel'),
54
+ branches: z.array(Id).min(1),
55
+ join: Id,
56
+ });
57
+ export const WorkflowNodeSchema = z.discriminatedUnion('type', [
58
+ TaskNodeSchema,
59
+ CodeNodeSchema,
60
+ HumanNodeSchema,
61
+ DecideNodeSchema,
62
+ GateNodeSchema,
63
+ GitNodeSchema,
64
+ ParallelNodeSchema,
65
+ ]);
66
+ export function transitionsOf(node) {
67
+ switch (node.type) {
68
+ case 'task':
69
+ case 'code':
70
+ case 'human':
71
+ case 'git':
72
+ return node.next ? [node.next] : [];
73
+ case 'decide':
74
+ return Object.values(node.next);
75
+ case 'gate':
76
+ return [node.on_pass, node.on_fail];
77
+ case 'parallel':
78
+ return [...node.branches, node.join];
79
+ }
80
+ }
81
+ export const WorkflowSchema = z
82
+ .object({
83
+ workflow: Id,
84
+ team: Id.optional(),
85
+ description: z.string().optional(),
86
+ /** A conversation with the orchestrator: runs in place and reads as messages in the dashboard. */
87
+ conversation: z.boolean().optional(),
88
+ start: Id,
89
+ nodes: z.record(z.string(), WorkflowNodeSchema),
90
+ })
91
+ .superRefine((wf, ctx) => {
92
+ const ids = new Set(Object.keys(wf.nodes));
93
+ if (!ids.has(wf.start)) {
94
+ ctx.addIssue({
95
+ code: 'custom',
96
+ path: ['start'],
97
+ message: `start node "${wf.start}" does not exist`,
98
+ });
99
+ }
100
+ for (const [id, node] of Object.entries(wf.nodes)) {
101
+ for (const target of transitionsOf(node)) {
102
+ if (!ids.has(target)) {
103
+ ctx.addIssue({
104
+ code: 'custom',
105
+ path: ['nodes', id],
106
+ message: `node "${id}" points to unknown node "${target}"`,
107
+ });
108
+ }
109
+ }
110
+ if (node.type === 'decide') {
111
+ for (const opt of node.options) {
112
+ if (!(opt in node.next)) {
113
+ ctx.addIssue({
114
+ code: 'custom',
115
+ path: ['nodes', id, 'next'],
116
+ message: `decide "${id}" has no transition for option "${opt}"`,
117
+ });
118
+ }
119
+ }
120
+ for (const key of Object.keys(node.next)) {
121
+ if (!node.options.includes(key)) {
122
+ ctx.addIssue({
123
+ code: 'custom',
124
+ path: ['nodes', id, 'next'],
125
+ message: `decide "${id}" transition "${key}" is not an option`,
126
+ });
127
+ }
128
+ }
129
+ }
130
+ }
131
+ });
132
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,IAAI,EAAE,EAAE;IACR,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,IAAI,EAAE,EAAE,CAAC,QAAQ,EAAE;CACpB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;IACxD,IAAI,EAAE,EAAE,CAAC,QAAQ,EAAE;CACpB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,IAAI,EAAE,EAAE,CAAC,QAAQ,EAAE;CACpB,CAAC,CAAC;AACH,MAAM,CAAC,M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I,CAAC,OAAO,EAAE,CAAC;gBAC/B,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxB,GAAG,CAAC,QAAQ,CAAC;wBACX,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC;wBAC3B,OAAO,EAAE,WAAW,EAAE,mCAAmC,GAAG,GAAG;qBAChE,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChC,GAAG,CAAC,QAAQ,CAAC;wBACX,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC;wBAC3B,OAAO,EAAE,WAAW,EAAE,iBAAiB,GAAG,oBAAoB;qBAC/D,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@wizardingcode/shibaox-schemas",
3
+ "version": "0.1.0",
4
+ "license": "UNLICENSED",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "dependencies": {
16
+ "yaml": "^2.9.1",
17
+ "zod": "^4.6.5"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^26.6.2"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/WizardingCode-io/shibaox.git"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc -p tsconfig.json",
31
+ "test": "vitest run",
32
+ "typecheck": "tsc -p tsconfig.json --noEmit"
33
+ }
34
+ }