@frockbot/plugin-flock 0.0.0 → 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.
- package/README.md +8 -1
- package/assets/amber-glasses.webp +0 -0
- package/assets/background-bright-orange.webp +0 -0
- package/assets/background-canary-yellow.webp +0 -0
- package/assets/background-electric-blue.webp +0 -0
- package/assets/background-hot-pink.webp +0 -0
- package/assets/background-lime-green.webp +0 -0
- package/assets/background-vivid-purple.webp +0 -0
- package/assets/blue-sailor-cap.webp +0 -0
- package/assets/bronze-aviator-goggles.webp +0 -0
- package/assets/burgundy-beret.webp +0 -0
- package/assets/canary-party-hat.webp +0 -0
- package/assets/canary-rain-cap.webp +0 -0
- package/assets/canonical.webp +0 -0
- package/assets/chef-toque.webp +0 -0
- package/assets/cobalt-round-glasses.webp +0 -0
- package/assets/coral-bucket-hat.webp +0 -0
- package/assets/emerald-necktie.webp +0 -0
- package/assets/forest-ranger-fedora.webp +0 -0
- package/assets/gold-royal-crown.webp +0 -0
- package/assets/gold-sun-medallion.webp +0 -0
- package/assets/graduation-cap.webp +0 -0
- package/assets/green-square-glasses.webp +0 -0
- package/assets/layers.css +159 -0
- package/assets/leather-bell.webp +0 -0
- package/assets/lilac-flower-crown.webp +0 -0
- package/assets/manifest.json +769 -0
- package/assets/matte-black-top-hat.webp +0 -0
- package/assets/navy-wizard-hat.webp +0 -0
- package/assets/orange-hard-hat.webp +0 -0
- package/assets/plum-glasses.webp +0 -0
- package/assets/purple-scarf.webp +0 -0
- package/assets/purple-witch-hat.webp +0 -0
- package/assets/rainbow-propeller-cap.webp +0 -0
- package/assets/rainbow-visor.webp +0 -0
- package/assets/ranger-fedora-feather.webp +0 -0
- package/assets/red-polka-bowtie.webp +0 -0
- package/assets/retro-3d-glasses.webp +0 -0
- package/assets/rose-heart-sunglasses.webp +0 -0
- package/assets/royal-crown-rubies.webp +0 -0
- package/assets/sailor-cap-anchor.webp +0 -0
- package/assets/silver-space-helmet.webp +0 -0
- package/assets/straw-boater.webp +0 -0
- package/assets/teal-bowtie.webp +0 -0
- package/assets/teal-glasses.webp +0 -0
- package/assets/terracotta-beanie.webp +0 -0
- package/assets/tortoiseshell-readers.webp +0 -0
- package/assets/turquoise-bandana.webp +0 -0
- package/assets/violet-masquerade-mask.webp +0 -0
- package/assets/white-snow-goggles.webp +0 -0
- package/assets/white-tennis-visor.webp +0 -0
- package/assets/witch-hat-moon.webp +0 -0
- package/assets/yellow-star-glasses.webp +0 -0
- package/frockbot.json +38 -0
- package/package.json +47 -6
- package/src/agent.test.ts +401 -0
- package/src/agent.ts +571 -0
- package/src/assets.test.ts +31 -0
- package/src/backend.test.ts +205 -0
- package/src/backend.ts +283 -0
- package/src/bot.test.ts +190 -0
- package/src/bot.ts +255 -0
- package/src/client/BotAvatar.vue +20 -0
- package/src/client/FlockAvatar.vue +33 -0
- package/src/client/FlockAvatarEditor.vue +44 -0
- package/src/client/FlockCreateButton.vue +18 -0
- package/src/client/FlockIdentity.vue +31 -0
- package/src/client/FlockOverlay.vue +209 -0
- package/src/client/FlockSidebar.vue +254 -0
- package/src/client/SheepAvatar.vue +28 -0
- package/src/client/dialog-focus.test.ts +15 -0
- package/src/client/dialog-focus.ts +13 -0
- package/src/client/index.test.ts +502 -0
- package/src/client/index.ts +619 -0
- package/src/client/mobile-dialog-layout.test.ts +50 -0
- package/src/client/pending-create.test.ts +71 -0
- package/src/client/pending-create.ts +93 -0
- package/src/client/sidebar.test.ts +77 -0
- package/src/client/sidebar.ts +77 -0
- package/src/client/state.ts +53 -0
- package/src/client/styles.css +611 -0
- package/src/env.d.ts +9 -0
- package/src/index.ts +4 -0
- package/src/manifest.ts +3 -0
- package/src/package.test.ts +12 -0
- package/src/shared.test.ts +197 -0
- package/src/shared.ts +735 -0
- package/src/user.test.ts +455 -0
- package/src/user.ts +465 -0
- package/tsconfig.json +15 -0
- package/validate_readability.py +64 -0
- package/vite.config.ts +30 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
decodeBotIdentityDirectoryViewV1,
|
|
4
|
+
decodeBotIdentityViewV1,
|
|
5
|
+
decodeBotLifecycleCommandV1,
|
|
6
|
+
decodeBotLifecycleReceiptV1,
|
|
7
|
+
decodeBotMembershipViewV1,
|
|
8
|
+
decodeBotRegistrationV1,
|
|
9
|
+
decodeCreateBotCommandV1,
|
|
10
|
+
decodeDirectoryViewV1,
|
|
11
|
+
decodeSheepRecipeV1,
|
|
12
|
+
randomSheepRecipeV1,
|
|
13
|
+
sheepCatalog,
|
|
14
|
+
sheepLayerIds,
|
|
15
|
+
} from "./shared.js";
|
|
16
|
+
|
|
17
|
+
describe("Flock v1 contracts", () => {
|
|
18
|
+
test("rejects unknown fields and catalog IDs", () => {
|
|
19
|
+
const sheep = randomSheepRecipeV1(() => 0);
|
|
20
|
+
expect(() => decodeSheepRecipeV1({ ...sheep, surprise: true })).toThrow(
|
|
21
|
+
"unknown or missing field",
|
|
22
|
+
);
|
|
23
|
+
expect(() => decodeSheepRecipeV1({ ...sheep, upper: "not-a-hat" })).toThrow(
|
|
24
|
+
"unknown catalog item",
|
|
25
|
+
);
|
|
26
|
+
expect(() =>
|
|
27
|
+
decodeCreateBotCommandV1({
|
|
28
|
+
schemaVersion: 1,
|
|
29
|
+
type: "bot/create",
|
|
30
|
+
commandId: "create-1",
|
|
31
|
+
expectedRevision: 0,
|
|
32
|
+
botId: "alpha",
|
|
33
|
+
name: "Alpha",
|
|
34
|
+
sheep,
|
|
35
|
+
extra: true,
|
|
36
|
+
}),
|
|
37
|
+
).toThrow("unknown or missing field");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("strictly decodes archive and restore DTOs", () => {
|
|
41
|
+
const command = {
|
|
42
|
+
schemaVersion: 1 as const,
|
|
43
|
+
type: "bot/archive" as const,
|
|
44
|
+
commandId: "archive-1",
|
|
45
|
+
botId: "alpha",
|
|
46
|
+
};
|
|
47
|
+
expect(decodeBotLifecycleCommandV1(command)).toEqual(command);
|
|
48
|
+
expect(
|
|
49
|
+
decodeBotLifecycleReceiptV1({
|
|
50
|
+
schemaVersion: 1,
|
|
51
|
+
commandId: "archive-1",
|
|
52
|
+
botId: "alpha",
|
|
53
|
+
status: "applied",
|
|
54
|
+
lifecycle: {
|
|
55
|
+
schemaVersion: 1,
|
|
56
|
+
botId: "alpha",
|
|
57
|
+
status: "archived",
|
|
58
|
+
revision: 1,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
).toMatchObject({ lifecycle: { status: "archived" } });
|
|
62
|
+
const hidden = { ...command };
|
|
63
|
+
Object.defineProperty(hidden, "hidden", { value: true });
|
|
64
|
+
expect(() => decodeBotLifecycleCommandV1(hidden)).toThrow(
|
|
65
|
+
"unknown or missing field",
|
|
66
|
+
);
|
|
67
|
+
expect(() =>
|
|
68
|
+
decodeBotLifecycleCommandV1({ ...command, [Symbol("extra")]: true }),
|
|
69
|
+
).toThrow("unknown or missing field");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("round-trips configuration-valid provider model text", () => {
|
|
73
|
+
const sheep = randomSheepRecipeV1(() => 0);
|
|
74
|
+
const providerModelId = "m".repeat(256);
|
|
75
|
+
expect(
|
|
76
|
+
decodeDirectoryViewV1({
|
|
77
|
+
schemaVersion: 1,
|
|
78
|
+
revision: 1,
|
|
79
|
+
bots: [
|
|
80
|
+
{
|
|
81
|
+
schemaVersion: 1,
|
|
82
|
+
botId: "alpha",
|
|
83
|
+
registeredAt: new Date(0).toISOString(),
|
|
84
|
+
initialName: "Alpha",
|
|
85
|
+
initialModel: {
|
|
86
|
+
connectionId: "connection-1",
|
|
87
|
+
providerModelId,
|
|
88
|
+
},
|
|
89
|
+
initialModelBinding: {
|
|
90
|
+
assignment: {
|
|
91
|
+
assignmentId: "create-alpha",
|
|
92
|
+
packageId: "provider-ollama-cloud",
|
|
93
|
+
capabilityId: "ollama-cloud-models",
|
|
94
|
+
connectionId: "connection-1",
|
|
95
|
+
state: "enabled",
|
|
96
|
+
},
|
|
97
|
+
generation: "create-alpha",
|
|
98
|
+
},
|
|
99
|
+
sheep,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
}).bots[0]?.initialModel?.providerModelId,
|
|
103
|
+
).toBe(providerModelId);
|
|
104
|
+
expect(() =>
|
|
105
|
+
decodeCreateBotCommandV1({
|
|
106
|
+
schemaVersion: 1,
|
|
107
|
+
type: "bot/create",
|
|
108
|
+
commandId: "create-2",
|
|
109
|
+
expectedRevision: 1,
|
|
110
|
+
botId: "invalid@desktop",
|
|
111
|
+
name: "Invalid",
|
|
112
|
+
}),
|
|
113
|
+
).toThrow("botId is invalid");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("exactly decodes versioned registration and membership DTOs", () => {
|
|
117
|
+
const sheep = randomSheepRecipeV1(() => 0);
|
|
118
|
+
const registration = {
|
|
119
|
+
schemaVersion: 1 as const,
|
|
120
|
+
botId: "alpha",
|
|
121
|
+
registeredAt: new Date(0).toISOString(),
|
|
122
|
+
initialName: "Alpha",
|
|
123
|
+
sheep,
|
|
124
|
+
};
|
|
125
|
+
expect(decodeBotRegistrationV1(registration)).toEqual(registration);
|
|
126
|
+
expect(
|
|
127
|
+
decodeBotMembershipViewV1({
|
|
128
|
+
schemaVersion: 1,
|
|
129
|
+
botId: "alpha",
|
|
130
|
+
registered: true,
|
|
131
|
+
}),
|
|
132
|
+
).toEqual({ schemaVersion: 1, botId: "alpha", registered: true });
|
|
133
|
+
for (const invalid of [
|
|
134
|
+
{ ...registration, schemaVersion: 2 },
|
|
135
|
+
{ ...registration, botId: "bad:bot" },
|
|
136
|
+
{ ...registration, extra: true },
|
|
137
|
+
])
|
|
138
|
+
expect(() => decodeBotRegistrationV1(invalid)).toThrow();
|
|
139
|
+
expect(() =>
|
|
140
|
+
decodeBotMembershipViewV1({
|
|
141
|
+
schemaVersion: 1,
|
|
142
|
+
botId: "bad:bot",
|
|
143
|
+
registered: true,
|
|
144
|
+
}),
|
|
145
|
+
).toThrow("botId is invalid");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test("random recipes are legal and compose complete ancestor paths", () => {
|
|
149
|
+
for (let index = 0; index < 100; index += 1) {
|
|
150
|
+
const recipe = randomSheepRecipeV1(() => index / 100);
|
|
151
|
+
expect(decodeSheepRecipeV1(recipe)).toEqual(recipe);
|
|
152
|
+
const layers = sheepLayerIds(recipe);
|
|
153
|
+
expect(layers[0]).toBe(`background-${recipe.background}`);
|
|
154
|
+
expect(layers[1]).toBe("canonical");
|
|
155
|
+
}
|
|
156
|
+
expect(sheepCatalog.trees.upper).toHaveLength(24);
|
|
157
|
+
expect(sheepCatalog.trees.middle).toHaveLength(14);
|
|
158
|
+
expect(sheepCatalog.trees.lower).toHaveLength(8);
|
|
159
|
+
expect(sheepCatalog.assets).toHaveLength(50);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("decodes the live Bot identity directory exactly", () => {
|
|
163
|
+
const identity = {
|
|
164
|
+
schemaVersion: 1 as const,
|
|
165
|
+
botId: "alpha",
|
|
166
|
+
name: "Atlas",
|
|
167
|
+
namedBy: "bot" as const,
|
|
168
|
+
hiddenFromSidebar: true,
|
|
169
|
+
label: "Personal",
|
|
170
|
+
title: "Chief of staff",
|
|
171
|
+
};
|
|
172
|
+
expect(decodeBotIdentityViewV1(structuredClone(identity))).toEqual(
|
|
173
|
+
identity,
|
|
174
|
+
);
|
|
175
|
+
expect(
|
|
176
|
+
decodeBotIdentityDirectoryViewV1({
|
|
177
|
+
schemaVersion: 1,
|
|
178
|
+
identities: [identity],
|
|
179
|
+
}).identities,
|
|
180
|
+
).toHaveLength(1);
|
|
181
|
+
expect(() =>
|
|
182
|
+
decodeBotIdentityViewV1({ ...identity, namedBy: "admin" }),
|
|
183
|
+
).toThrow("namedBy is invalid");
|
|
184
|
+
expect(() => decodeBotIdentityViewV1({ ...identity, extra: true })).toThrow(
|
|
185
|
+
"unknown or missing field",
|
|
186
|
+
);
|
|
187
|
+
expect(() =>
|
|
188
|
+
decodeBotIdentityViewV1({ ...identity, avatar: { kind: "image" } }),
|
|
189
|
+
).toThrow("unknown or missing field");
|
|
190
|
+
expect(() =>
|
|
191
|
+
decodeBotIdentityDirectoryViewV1({
|
|
192
|
+
schemaVersion: 1,
|
|
193
|
+
identities: [identity, identity],
|
|
194
|
+
}),
|
|
195
|
+
).toThrow("duplicate IDs");
|
|
196
|
+
});
|
|
197
|
+
});
|