openvibers/openvibe.actor Commits
A-1: Vibe first on a person's first write (#318)
Changes
@@@ -139,6 +139,8 @@ async function create(s, config, owner, input) {if (invalid) return { error: invalid };const instructions = body.instructions != null ? body.instructions : (base.instructions || `You are ${next.name}, one of this person's agents.`);if (typeof instructions !== 'string' || !instructions.trim() || instructions.length > 4000) return { error: 'instructions must be 1–4000 characters.' };++ // Vibe comes first even when the first thing a person does is create another contact.++ await ensureVibe(s, config, owner);const count = Number(await s.db.value('SELECT count(*) FROM actor_agents WHERE owner = $1', [owner]));if (count >= config.agents.maxPerOwner) return { limit: true, error: 'Agent limit reached.' };const now = s.iso();@@@ -118,6 +118,15 @@ const PRESET_NAMES = ['Researcher', 'Inbox', 'Studio editor', 'Party host'];assert.strictEqual((await t.get('/api/v1/agents', { json: { name: 'Nope' } })).status, 401);});++ await check('a person\'s first write still creates Vibe first', async () => {++ const carol = t.network.addUser('contacts-carol');++ const made = await t.get('/api/v1/agents', { as: carol, json: { name: 'First' }, headers: SAME });++ assert.strictEqual(made.status, 201, made.text);++ const roster = (await t.get('/api/v1/agents', { as: carol })).json().agents;++ assert.deepStrictEqual(roster.map((a) => a.name), ['Vibe', 'First']);++ assert.strictEqual(Number(await t.ctx.s.db.value('SELECT count(*) FROM actor_agents WHERE owner = $1 AND is_vibe', [`user:${carol.subject}`])), 1);++ });++await check('the OpenAPI document lists every new contact route', async () => {const doc = (await t.get('/openapi.json')).json();for (const [path, method] of [
@@ -139,6 +139,8 @@ async function create(s, config, owner, input) {
@@ -139,6 +139,8 @@ async function create(s, config, owner, input) {
if (invalid) return { error: invalid };
if (invalid) return { error: invalid };
const instructions = body.instructions != null ? body.instructions : (base.instructions || `You are ${next.name}, one of this person's agents.`);
const instructions = body.instructions != null ? body.instructions : (base.instructions || `You are ${next.name}, one of this person's agents.`);
if (typeof instructions !== 'string' || !instructions.trim() || instructions.length > 4000) return { error: 'instructions must be 1–4000 characters.' };
if (typeof instructions !== 'string' || !instructions.trim() || instructions.length > 4000) return { error: 'instructions must be 1–4000 characters.' };
+ // Vibe comes first even when the first thing a person does is create another contact.
+ await ensureVibe(s, config, owner);
const count = Number(await s.db.value('SELECT count(*) FROM actor_agents WHERE owner = $1', [owner]));
const count = Number(await s.db.value('SELECT count(*) FROM actor_agents WHERE owner = $1', [owner]));
if (count >= config.agents.maxPerOwner) return { limit: true, error: 'Agent limit reached.' };
if (count >= config.agents.maxPerOwner) return { limit: true, error: 'Agent limit reached.' };
const now = s.iso();
const now = s.iso();
@@ -118,6 +118,15 @@ const PRESET_NAMES = ['Researcher', 'Inbox', 'Studio editor', 'Party host'];
@@ -118,6 +118,15 @@ const PRESET_NAMES = ['Researcher', 'Inbox', 'Studio editor', 'Party host'];
assert.strictEqual((await t.get('/api/v1/agents', { json: { name: 'Nope' } })).status, 401);
assert.strictEqual((await t.get('/api/v1/agents', { json: { name: 'Nope' } })).status, 401);
});
});
+ await check('a person\'s first write still creates Vibe first', async () => {
+ const carol = t.network.addUser('contacts-carol');
+ const made = await t.get('/api/v1/agents', { as: carol, json: { name: 'First' }, headers: SAME });
+ assert.strictEqual(made.status, 201, made.text);
+ const roster = (await t.get('/api/v1/agents', { as: carol })).json().agents;
+ assert.deepStrictEqual(roster.map((a) => a.name), ['Vibe', 'First']);
+ assert.strictEqual(Number(await t.ctx.s.db.value('SELECT count(*) FROM actor_agents WHERE owner = $1 AND is_vibe', [`user:${carol.subject}`])), 1);
+ });
+
await check('the OpenAPI document lists every new contact route', async () => {
await check('the OpenAPI document lists every new contact route', async () => {
const doc = (await t.get('/openapi.json')).json();
const doc = (await t.get('/openapi.json')).json();
for (const [path, method] of [
for (const [path, method] of [