openvibers/openvibe.actor Commits
Actor: an agent's page offers to wake it when something happens (through OpenVibe.Watch) (#52)
Changes
@@@ -112,6 +112,8 @@ ${a.state === 'pending' ? html`<form method="post" action="/me/approvals/${a.id}${a.last_skip_reason ? html`<p class="notice" role="status">The last scheduled run was skipped: ${a.last_skip_reason}</p>` : ''}<div class="pa-grid"><section class="pa-panel"><h2>Run now</h2><form method="post" action="/me/agents/${a.id}/run"><label>Input (optional) <span class="pa-hint">Anything this run should also consider.</span><textarea name="input" maxlength="8000" rows="3"></textarea></label><button type="submit" class="pa-btn pa-primary">Run now</button></form></section>++<section class="pa-panel"><h2>Wake it when something happens</h2><p>Besides its schedule, this agent can run the moment something happens: a channel goes live, a new blog post, a page changes, a price drops, a webhook arrives. <a href="https://openvibe.watch">OpenVibe.Watch</a> watches for it and runs this agent with what it saw.</p>++<p class="pa-actions"><a class="pa-btn" href="https://openvibe.watch/watches/new?template=event&agent_id=${a.id}">When something happens on OpenVibe</a> <a class="pa-btn" href="https://openvibe.watch/watches/new?template=page&agent_id=${a.id}">When a page changes</a></p></section><section class="pa-panel"><h2>Recent runs</h2>${runs.length ? html`<ul class="pa-runs">${runs.map((t) => html`<li><a href="/tasks/${t.id}">${time(t.created_at)}</a> <span class="pill ${pill(t.state)}">${t.state}</span></li>`)}</ul>` : html`<p class="muted">No run yet.</p>`}</section></div><section class="pa-panel"><h2>Memory</h2><p class="pa-hint">What this agent remembers, newest first. Notes you write are never dropped; when memory is full (50 notes) the oldest note the agent wrote goes first. An agent adds at most one note per run, and only when its answer passed the check.</p>@@@ -22,6 +22,7 @@ const SAME = { 'sec-fetch-site': 'same-origin' };const id = create.headers.get('location').split('/').pop();const own = await t.get(`/me/agents/${id}`, { as: a });assert.match(own.text, /Run now/);++ assert.ok(own.text.includes(`https://openvibe.watch/watches/new?template=event&agent_id=${id}`), 'a link to wake it from Watch');assert.match(own.text, /Forget everything/);assert.strictEqual((await t.get(`/me/agents/${id}/memory`, { as: a, form: { text: 'Remember this.' }, headers: SAME })).status, 303);const withNote = await t.get(`/me/agents/${id}`, { as: a });
@@ -112,6 +112,8 @@ ${a.state === 'pending' ? html`<form method="post" action="/me/approvals/${a.id}
@@ -112,6 +112,8 @@ ${a.state === 'pending' ? html`<form method="post" action="/me/approvals/${a.id}
${a.last_skip_reason ? html`<p class="notice" role="status">The last scheduled run was skipped: ${a.last_skip_reason}</p>` : ''}
${a.last_skip_reason ? html`<p class="notice" role="status">The last scheduled run was skipped: ${a.last_skip_reason}</p>` : ''}
<div class="pa-grid">
<div class="pa-grid">
<section class="pa-panel"><h2>Run now</h2><form method="post" action="/me/agents/${a.id}/run"><label>Input (optional) <span class="pa-hint">Anything this run should also consider.</span><textarea name="input" maxlength="8000" rows="3"></textarea></label><button type="submit" class="pa-btn pa-primary">Run now</button></form></section>
<section class="pa-panel"><h2>Run now</h2><form method="post" action="/me/agents/${a.id}/run"><label>Input (optional) <span class="pa-hint">Anything this run should also consider.</span><textarea name="input" maxlength="8000" rows="3"></textarea></label><button type="submit" class="pa-btn pa-primary">Run now</button></form></section>
+<section class="pa-panel"><h2>Wake it when something happens</h2><p>Besides its schedule, this agent can run the moment something happens: a channel goes live, a new blog post, a page changes, a price drops, a webhook arrives. <a href="https://openvibe.watch">OpenVibe.Watch</a> watches for it and runs this agent with what it saw.</p>
+<p class="pa-actions"><a class="pa-btn" href="https://openvibe.watch/watches/new?template=event&agent_id=${a.id}">When something happens on OpenVibe</a> <a class="pa-btn" href="https://openvibe.watch/watches/new?template=page&agent_id=${a.id}">When a page changes</a></p></section>
<section class="pa-panel"><h2>Recent runs</h2>${runs.length ? html`<ul class="pa-runs">${runs.map((t) => html`<li><a href="/tasks/${t.id}">${time(t.created_at)}</a> <span class="pill ${pill(t.state)}">${t.state}</span></li>`)}</ul>` : html`<p class="muted">No run yet.</p>`}</section>
<section class="pa-panel"><h2>Recent runs</h2>${runs.length ? html`<ul class="pa-runs">${runs.map((t) => html`<li><a href="/tasks/${t.id}">${time(t.created_at)}</a> <span class="pill ${pill(t.state)}">${t.state}</span></li>`)}</ul>` : html`<p class="muted">No run yet.</p>`}</section>
</div>
</div>
<section class="pa-panel"><h2>Memory</h2><p class="pa-hint">What this agent remembers, newest first. Notes you write are never dropped; when memory is full (50 notes) the oldest note the agent wrote goes first. An agent adds at most one note per run, and only when its answer passed the check.</p>
<section class="pa-panel"><h2>Memory</h2><p class="pa-hint">What this agent remembers, newest first. Notes you write are never dropped; when memory is full (50 notes) the oldest note the agent wrote goes first. An agent adds at most one note per run, and only when its answer passed the check.</p>
@@ -22,6 +22,7 @@ const SAME = { 'sec-fetch-site': 'same-origin' };
@@ -22,6 +22,7 @@ const SAME = { 'sec-fetch-site': 'same-origin' };
const id = create.headers.get('location').split('/').pop();
const id = create.headers.get('location').split('/').pop();
const own = await t.get(`/me/agents/${id}`, { as: a });
const own = await t.get(`/me/agents/${id}`, { as: a });
assert.match(own.text, /Run now/);
assert.match(own.text, /Run now/);
+ assert.ok(own.text.includes(`https://openvibe.watch/watches/new?template=event&agent_id=${id}`), 'a link to wake it from Watch');
assert.match(own.text, /Forget everything/);
assert.match(own.text, /Forget everything/);
assert.strictEqual((await t.get(`/me/agents/${id}/memory`, { as: a, form: { text: 'Remember this.' }, headers: SAME })).status, 303);
assert.strictEqual((await t.get(`/me/agents/${id}/memory`, { as: a, form: { text: 'Remember this.' }, headers: SAME })).status, 303);
const withNote = await t.get(`/me/agents/${id}`, { as: a });
const withNote = await t.get(`/me/agents/${id}`, { as: a });