loopengine 0.5.9 → 0.5.11

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.
@@ -148,9 +148,10 @@ export declare function getVersion(key: {
148
148
  }, number: number, database?: DatabaseSync | undefined): Version | undefined;
149
149
  /** What a workflow version holds, as text people can read and compare
150
150
  * line by line: which workflow it is, its name and description, its input
151
- * schema, model, the tools it uses with each one's permission, its
152
- * triggers, its success criteria, its output schema, its instructions and
153
- * its result format. */
151
+ * schema, model, the tools it uses with each one's permission, its success
152
+ * criteria, its output schema, its instructions and its result format.
153
+ * What starts it (schedules, webhooks) and where its messages go aren't
154
+ * part of it: they change straight away, recorded in the change log. */
154
155
  export interface WorkflowSnapshot {
155
156
  agent: string;
156
157
  workflowId: string;
@@ -173,8 +174,6 @@ export interface WorkflowSnapshot {
173
174
  name: string;
174
175
  permission: string;
175
176
  }[];
176
- /** Each schedule and webhook that starts it, in a line. */
177
- triggers: string[];
178
177
  criteria: {
179
178
  text: string;
180
179
  kind: string;
@@ -189,10 +188,16 @@ export interface WorkflowSnapshot {
189
188
  inputSchema?: Record<string, unknown>;
190
189
  }
191
190
  export declare function workflowContent(w: WorkflowSnapshot): string;
191
+ /** A version's text without the schedules and webhooks that started the
192
+ * workflow, which versions held until they became settings that change
193
+ * straight away: the same workflow with only that dropped is the same
194
+ * version, not a new one. */
195
+ export declare function withoutTriggers(content: string): string;
192
196
  /** What a version holds. Older versions hold less: one from when only
193
197
  * the brief was numbered has just the instructions and result format;
194
- * one from before tools, triggers and criteria were part of it has no
195
- * such sections, and none comes back. */
198
+ * one from before tools and criteria were part of it has no such
199
+ * sections, and none comes back. The schedules and webhooks older
200
+ * versions held are left out. */
196
201
  export declare function workflowFromContent(content: string): Partial<WorkflowSnapshot> & {
197
202
  instructions: string;
198
203
  };
@@ -515,11 +515,20 @@ export function workflowContent(w) {
515
515
  `\n\n## Input schema\n\n${json(inputSchemaOf(w.parameters))}` +
516
516
  `\n\n## Model\n\n${w.model ? `${w.model.provider}/${w.model.model}` : "The agent's"}` +
517
517
  `\n\n## Tools\n\n${list(w.tools.map((t) => `- ${t.name}: ${t.permission}`))}` +
518
- `\n\n## Triggers\n\n${list(w.triggers.map((t) => `- ${line(t)}`))}` +
519
518
  `\n\n## Success criteria\n\n${list(criteria)}` +
520
519
  `\n\n## Output schema\n\n${w.outputSchema ? json(w.outputSchema) : 'None'}\n`;
521
520
  return head + INSTRUCTIONS_HEADING + w.instructions + (w.output?.trim() ? RESULT_HEADING + w.output.trim() : '');
522
521
  }
522
+ /** A version's text without the schedules and webhooks that started the
523
+ * workflow, which versions held until they became settings that change
524
+ * straight away: the same workflow with only that dropped is the same
525
+ * version, not a new one. */
526
+ export function withoutTriggers(content) {
527
+ const at = content.indexOf(INSTRUCTIONS_HEADING);
528
+ if (at < 0)
529
+ return content;
530
+ return content.slice(0, at).replace(/\n\n## Triggers\n\n[\s\S]*?(?=\n\n## )/, '') + content.slice(at);
531
+ }
523
532
  /** A section's ```json block, parsed. */
524
533
  function jsonBlock(text) {
525
534
  const json = text?.match(/^```json\n([\s\S]*)\n```$/)?.[1];
@@ -545,8 +554,9 @@ function parametersFromSchema(schema) {
545
554
  }
546
555
  /** What a version holds. Older versions hold less: one from when only
547
556
  * the brief was numbered has just the instructions and result format;
548
- * one from before tools, triggers and criteria were part of it has no
549
- * such sections, and none comes back. */
557
+ * one from before tools and criteria were part of it has no such
558
+ * sections, and none comes back. The schedules and webhooks older
559
+ * versions held are left out. */
550
560
  export function workflowFromContent(content) {
551
561
  const split = (body) => {
552
562
  const at = body.lastIndexOf(RESULT_HEADING);
@@ -584,7 +594,6 @@ export function workflowFromContent(content) {
584
594
  ...(inputSchema ? { inputSchema } : {}),
585
595
  ...(model ? { model: { provider: model[1], model: model[2] } } : {}),
586
596
  ...(section('Tools') !== undefined ? { tools: lines('Tools').flatMap((l) => { const m = l.match(/^(.+): (\S+)$/); return m ? [{ name: m[1], permission: m[2] }] : []; }) } : {}),
587
- ...(section('Triggers') !== undefined ? { triggers: lines('Triggers') } : {}),
588
597
  ...(criteria ? { criteria } : {}),
589
598
  ...(outputSchema ? { outputSchema } : {}),
590
599
  ...split(content.slice(at + INSTRUCTIONS_HEADING.length)),
package/dist/index.d.ts CHANGED
@@ -98,7 +98,7 @@ export { WORKFLOW_EXAMPLES, workflowExample, type WorkflowExample } from './core
98
98
  export { WORKFLOW_EXAMPLE_MESSAGES, type WorkflowExampleMessage } from './core/system-agents/workflow-example-messages.js';
99
99
  export { createTrigger, updateTrigger, rotateTrigger, listTriggers, findTriggerByToken, publicTrigger, checkTriggerSettings, verifySenderSignature, parsePayload, valueAt, deliveryId, passesFilter, paramsFromPayload, checkRunDelivery, fillChatNotice, resultToChat, recordDelivery as recordTriggerDelivery, FileTriggerStore, getTriggerStore, setTriggerStore, TriggerError, type WorkflowTrigger, type PublicTrigger, type TriggerSettings, type TriggerVerify, type TriggerFilter, type TriggerSender, type SignatureAlgorithm, type TriggerDelivery, type TriggerOutcome, type TriggerStore } from './core/workflow-triggers.js';
100
100
  export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError, type CallbackDelivery, type CallbackPending, type RunCallbackEvent } from './core/run-callbacks.js';
101
- export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash, type ChainCheck, readMeta, writeMeta, type EventFilter, noteVersion, listVersions, getVersion, workflowContent, workflowFromContent, type WorkflowSnapshot, recordTraceSpan, recordTracePrompt, listTraceSpans, pruneTraces, type TraceSpan, retentionDays, type Version, type VersionKind, type AuditEvent, type AuditEventKind } from './core/audit-store.js';
101
+ export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash, type ChainCheck, readMeta, writeMeta, type EventFilter, noteVersion, listVersions, getVersion, workflowContent, workflowFromContent, withoutTriggers, type WorkflowSnapshot, recordTraceSpan, recordTracePrompt, listTraceSpans, pruneTraces, type TraceSpan, retentionDays, type Version, type VersionKind, type AuditEvent, type AuditEventKind } from './core/audit-store.js';
102
102
  export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, runsSince, searchRuns, type RunSearch, getRun, isUnderWay, RunError, type WorkflowRun, type WorkflowRunStatus, type RunVersions, workflowVersionOf, FEEDBACK_SOURCES, type FeedbackSource, type RunFeedback, type RunDecision, type RunStore, type ExecuteRun, type RunOutcome, type StartRunInput } from './core/workflow-runs.js';
103
103
  export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies, type Workflow, type WorkflowFields, type WorkflowParameter, type WorkflowModel, type WorkflowDelivery, type RunMessageExtras } from './core/workflows.js';
104
104
  export { EvidenceError, evalCandidates, suggestedCriteria, type EvalCandidate, workflowScores, runFeedbackFrom, feedbackSourceOf, readEvals, addEvalCase, updateEvalCase, removeEvalCase, setEvalCriteria, effectiveCriteria, codeCheck, judgeCriteria, checkCase, roundSummary, draftCriteria, startEvalRound, EVAL_CRITERIA_PROMPT, DRAFT_CRITERIA_PROMPT, REFERENCE_CRITERION, type WorkflowScores, type EvalCase, type EvalCaseResult, type EvalCheck, type EvalCriterion, type CriterionKind, type EvalRound, type WorkflowEvals, type EvalRunDeps, type StandIn } from './web/workflow-evidence.js';
package/dist/index.js CHANGED
@@ -91,7 +91,7 @@ export { WORKFLOW_EXAMPLES, workflowExample } from './core/system-agents/workflo
91
91
  export { WORKFLOW_EXAMPLE_MESSAGES } from './core/system-agents/workflow-example-messages.js';
92
92
  export { createTrigger, updateTrigger, rotateTrigger, listTriggers, findTriggerByToken, publicTrigger, checkTriggerSettings, verifySenderSignature, parsePayload, valueAt, deliveryId, passesFilter, paramsFromPayload, checkRunDelivery, fillChatNotice, resultToChat, recordDelivery as recordTriggerDelivery, FileTriggerStore, getTriggerStore, setTriggerStore, TriggerError } from './core/workflow-triggers.js';
93
93
  export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError } from './core/run-callbacks.js';
94
- export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash, readMeta, writeMeta, noteVersion, listVersions, getVersion, workflowContent, workflowFromContent, recordTraceSpan, recordTracePrompt, listTraceSpans, pruneTraces, retentionDays } from './core/audit-store.js';
94
+ export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash, readMeta, writeMeta, noteVersion, listVersions, getVersion, workflowContent, workflowFromContent, withoutTriggers, recordTraceSpan, recordTracePrompt, listTraceSpans, pruneTraces, retentionDays } from './core/audit-store.js';
95
95
  export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, runsSince, searchRuns, getRun, isUnderWay, RunError, workflowVersionOf, FEEDBACK_SOURCES } from './core/workflow-runs.js';
96
96
  export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies } from './core/workflows.js';
97
97
  export { EvidenceError, evalCandidates, suggestedCriteria, workflowScores, runFeedbackFrom, feedbackSourceOf, readEvals, addEvalCase, updateEvalCase, removeEvalCase, setEvalCriteria, effectiveCriteria, codeCheck, judgeCriteria, checkCase, roundSummary, draftCriteria, startEvalRound, EVAL_CRITERIA_PROMPT, DRAFT_CRITERIA_PROMPT, REFERENCE_CRITERION } from './web/workflow-evidence.js';
@@ -2159,7 +2159,7 @@ ${renderMarkdownScript}
2159
2159
  '</header>' +
2160
2160
  workflowDraftBannerHtml(w) +
2161
2161
  '<div class="wf-row-body wf-page-body">' +
2162
- '<div class="wf-tabs" role="tablist">' + tabBtn('activity', 'Activity') + tabBtn('feedback', 'Feedback') + tabBtn('brief', 'Prompt') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messaging') + tabBtn('evaluation', 'Evaluation') + tabBtn('contract', 'Contract') + tabBtn('versions', 'Versions') + '</div>' +
2162
+ '<div class="wf-tabs" role="tablist">' + tabBtn('activity', 'Activity') + tabBtn('brief', 'Prompt') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messaging') + tabBtn('feedback', 'Feedback') + tabBtn('evaluation', 'Evaluation') + tabBtn('contract', 'Contract') + tabBtn('versions', 'Versions') + '</div>' +
2163
2163
  panel('brief', workflowBriefHtml(w)) +
2164
2164
  panel('activity', workflowActivityHtml(w, runs, name)) +
2165
2165
  panel('evaluation', workflowEvaluationHtml(w)) +
@@ -2186,7 +2186,7 @@ ${renderMarkdownScript}
2186
2186
  '<div class="wf-row-body"' + (open ? '' : ' hidden') + '>' +
2187
2187
  // What it does, in full, once it's open (the row shows just its name).
2188
2188
  (w.description && w.description !== w.title ? '<p class="wf-desc">' + escapeHtml(w.description) + '</p>' : '') +
2189
- '<div class="wf-tabs" role="tablist">' + tabBtn('activity', 'Activity') + tabBtn('feedback', 'Feedback') + tabBtn('brief', 'Prompt') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messaging') + tabBtn('evaluation', 'Evaluation') + tabBtn('contract', 'Contract') + tabBtn('versions', 'Versions') + '</div>' +
2189
+ '<div class="wf-tabs" role="tablist">' + tabBtn('activity', 'Activity') + tabBtn('brief', 'Prompt') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messaging') + tabBtn('feedback', 'Feedback') + tabBtn('evaluation', 'Evaluation') + tabBtn('contract', 'Contract') + tabBtn('versions', 'Versions') + '</div>' +
2190
2190
  panel('contract', workflowContractHtml(w, name, params)) +
2191
2191
  panel('versions', workflowVersionsHtml()) +
2192
2192
  panel('feedback', workflowFeedbackHtml()) +
@@ -3283,7 +3283,6 @@ ${renderMarkdownScript}
3283
3283
  (f.outputSchema ? '<details class="wf-schema"><summary>Output schema</summary><pre>' + escapeHtml(JSON.stringify(f.outputSchema, null, 2)) + '</pre></details>' : ''));
3284
3284
  if (versionFull(v)) rows += row('Model', escapeHtml(versionModelText(f.model)));
3285
3285
  if (f.tools) rows += row('Tools', list(f.tools, 'None named in its prompt', versionToolHtml));
3286
- if (f.triggers) rows += row('Triggers', list(f.triggers, 'None: run by hand (Run now) or from an app', function (t) { return '<div>' + escapeHtml(t) + '</div>'; }));
3287
3286
  if (f.criteria) rows += row('Success criteria', list(f.criteria, 'None', function (c) { return '<div>' + escapeHtml(versionCritText(c)) + '</div>'; }));
3288
3287
  return '<div class="wf-vd">' + rows + '</div>' + (versionFull(v) ? '' : '<p class="hint" style="margin:6px 0 0">An early version: only its prompt and result format were kept.</p>');
3289
3288
  }
@@ -3343,10 +3342,6 @@ ${renderMarkdownScript}
3343
3342
  });
3344
3343
  if (tools.length) add('Tools', tools.join(''), tools.length + ' changed');
3345
3344
  }
3346
- if (a.triggers && b.triggers) {
3347
- var trig = setDiff(a.triggers, b.triggers, function (t) { return t; }, escapeHtml);
3348
- if (trig.length) add('Triggers', trig.join(''), trig.length + ' changed');
3349
- }
3350
3345
  if (a.criteria && b.criteria) {
3351
3346
  var crit = setDiff(a.criteria, b.criteria, function (c) { return c.kind + '|' + (c.value || '') + '|' + c.text; }, function (c) { return escapeHtml(versionCritText(c)); });
3352
3347
  if (crit.length) add('Success criteria', crit.join(''), crit.length + ' changed');
@@ -7,169 +7,210 @@
7
7
  // why the look is a shared import rather than a third copy of the same CSS.
8
8
  import { devUiCss } from './dev-ui-styles.js';
9
9
  import { consoleShellScript, consoleSidebarHtml } from './console-shell.js';
10
+ import { MASCOT_CSS, mascotSvg } from './mascot.js';
10
11
  export const agentsListPageHtml = `<!doctype html>
11
12
  <html lang="en">
12
13
  <head>
13
14
  <meta charset="utf-8">
14
15
  <meta name="viewport" content="width=device-width, initial-scale=1">
15
16
  <title>LoopEngine Agents</title>
16
- <style>${devUiCss}
17
- #agentUl { list-style: none; margin: 0; padding: 0; }
18
- #agentUl li { display: contents; }
19
- .agent-card { display: grid; gap: 10px; align-content: start; }
20
- .agent-card .name { font-weight: 600; font-size: 15px; }
21
- .agent-card .prompt { font-size: 12.5px; color: var(--ink-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
22
- .agent-card .does { font-size: 13px; color: var(--ink); line-height: 1.45; }
23
- .agent-card .does a { color: var(--accent-ink); text-decoration: none; }
24
- .agent-card .does .hint { font-size: 12.5px; }
25
- .agent-card .links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
26
- .agent-card .links a { font-size: 12.5px; font-weight: 500; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; color: var(--ink); }
27
- .agent-card .links a.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
28
- #empty { color: var(--ink-muted); }
29
- .hint { font-size: 12px; color: var(--ink-muted); }
17
+ <style>${devUiCss}${MASCOT_CSS}
18
+ .ag { max-width: 1120px; display: grid; gap: 0; }
19
+ .ag-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 36px 32px 28px; border: 1px solid var(--line); border-bottom: 0; }
20
+ .ag-hero .le-mascot { flex: none; margin-bottom: -6px; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .12)); }
21
+ .ag-cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
22
+ .ag-cols1 { grid-template-columns: minmax(0, 1fr); }
23
+ .ag-cols1[hidden] { display: none; }
24
+ .ag-card { display: grid; gap: 14px; align-content: start; padding: 20px 22px; background: var(--bg); }
25
+ .ag-filler { background: var(--bg); }
26
+ .ag-card-head { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
27
+ .ag-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); color: var(--ink-muted); box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
28
+ .ag-icon svg { width: 16px; height: 16px; }
29
+ .ag-icon.live { color: var(--good); }
30
+ .ag-card-text { display: grid; gap: 3px; min-width: 0; }
31
+ .ag-card-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; color: var(--ink); text-decoration: none; }
32
+ a.ag-card-title:hover { text-decoration: underline; }
33
+ .ag-id { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); font-weight: 400; margin-left: 6px; }
34
+ .ag-card-desc { font-size: 13px; line-height: 1.5; color: var(--ink-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
35
+ .ag-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
36
+ .ag-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); font-size: 12px; color: var(--ink-muted); white-space: nowrap; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
37
+ .ag-chip.strong { background: var(--surface); border-color: transparent; color: var(--ink); font-weight: 500; }
38
+ .ag-chip.good { background: var(--good-soft); border-color: transparent; color: var(--good); font-weight: 600; }
39
+ .ag-chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); font-weight: 600; }
40
+ a.ag-chip:hover { color: var(--ink); border-color: var(--ink-faint); }
41
+ .ag-actions { display: flex; gap: 8px; align-items: center; }
42
+ .ag-actions a { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 600; text-decoration: none; border: 1px solid var(--line); color: var(--ink); background: var(--bg); }
43
+ .ag-actions a:hover { background: var(--surface); }
44
+ .ag-actions a.dark { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
45
+ .ag-actions a.dark:hover { opacity: .88; }
46
+ .ag-tile { display: grid; gap: 6px; align-content: start; padding: 22px; background: var(--bg); text-decoration: none; color: inherit; transition: background .15s; }
47
+ .ag-tile:hover { background: var(--surface); }
48
+ .ag-tile b { font-size: 15px; font-weight: 600; color: var(--ink); }
49
+ .ag-tile span { font-size: 13px; color: var(--ink-muted); line-height: 1.45; }
50
+ .ag-empty { padding: 40px 32px; text-align: center; color: var(--ink-muted); font-size: 14px; background: var(--bg); grid-column: 1 / -1; margin: 0; }
51
+ .ag-topbar-link { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); font-size: 13.5px; font-weight: 500; color: var(--ink); text-decoration: none; }
52
+ .ag-topbar-link:hover { background: var(--surface); }
53
+ .hint { font-size: 12.5px; color: var(--ink-muted); }
30
54
  .error { font-size: 13px; color: var(--bad); }
31
- #newAgentForm {
32
- border: 1px solid var(--line);
33
- border-radius: var(--radius);
34
- padding: 16px;
35
- display: grid;
36
- gap: 12px;
37
- max-width: 560px;
55
+ #newAgentResult { margin: 12px 2px 0; }
56
+ /* New agent, in a dialog like Create schedule. */
57
+ .ag-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); color: var(--ink); box-shadow: 0 24px 60px rgba(0, 0, 0, .22); overflow: hidden; }
58
+ .ag-dialog::backdrop { background: rgba(20, 24, 25, .35); backdrop-filter: blur(3px); }
59
+ .ag-dialog form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100vh - 50px); }
60
+ .ag-dlg-head { display: flex; align-items: center; gap: 8px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
61
+ .ag-dlg-head h2 { margin: 0 auto 0 0; font-size: 18px; font-weight: 500; }
62
+ .ag-dlg-head button { height: 34px; padding: 0 14px; border-radius: 9px; font-size: 13px; }
63
+ .ag-dlg-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); overflow: auto; }
64
+ .ag-dlg-col { display: grid; align-content: start; }
65
+ .ag-dlg-col + .ag-dlg-col { border-left: 1px solid var(--line); background: var(--surface); }
66
+ .ag-field { display: grid; gap: 9px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
67
+ .ag-field > label, .ag-field-k { font-size: 14px; font-weight: 500; }
68
+ .ag-field label { display: grid; gap: 9px; }
69
+ .ag-field .hint { margin: 0; line-height: 1.45; }
70
+ .ag-field input, .ag-field select { height: 38px; border-radius: 9px; font-size: 13.5px; width: 100%; box-sizing: border-box; }
71
+ .ag-field textarea { min-height: 110px; border-radius: 9px; font-size: 13.5px; width: 100%; box-sizing: border-box; }
72
+ .ag-dlg-foot { padding: 12px 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-muted); min-height: 46px; display: flex; align-items: center; }
73
+ .ag-dlg-foot:not(:has(.error[style*="block"])) { display: none; }
74
+ @media (max-width: 860px) {
75
+ .ag-hero { padding: 24px 18px 20px; }
76
+ .ag-hero .le-mascot { display: none; }
77
+ .ag-cols2 { grid-template-columns: minmax(0, 1fr); }
78
+ .ag-dlg-body { grid-template-columns: minmax(0, 1fr); }
79
+ .ag-dlg-col + .ag-dlg-col { border-left: 0; border-top: 1px solid var(--line); }
80
+ .le-search, .ag-topbar-link { display: none; }
38
81
  }
39
- #newAgentForm h2 { font-size: 15px; margin: 0; }
40
- #newAgentForm label { display: grid; gap: 4px; font-size: 13px; }
41
- #newAgentForm .row { display: flex; gap: 8px; flex-wrap: wrap; }
42
- #newAgentForm details summary { cursor: pointer; color: var(--ink-muted); font-size: 13px; }
43
- #newAgentForm details[open] { display: grid; gap: 10px; }
44
- #newAgentForm textarea { min-height: 72px; }
45
82
  </style>
46
83
  </head>
47
84
  <body data-le-page="agents">
48
85
  <div class="le-app">
49
86
  ${consoleSidebarHtml}
50
87
  <main class="le-main">
51
- <div class="le-head plain">
52
- <div class="le-head-row">
53
- <div class="le-title"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
54
- <div><h1>Agents</h1><p>Each agent has its own instructions, tools and permissions. Open one to chat with it, give it workflows, or change how it works.</p></div>
55
- </div>
56
- <div style="display:flex;gap:8px;flex-wrap:wrap"><a href="/interview" style="padding:6px 12px;border:1px solid var(--line);border-radius:6px;text-decoration:none;color:var(--ink);font-size:13px">Find your first agent</a>
57
- <button type="button" id="newAgentBtn" class="primary">New agent</button></div>
58
- </div>
59
- </div>
60
- <div class="le-scroll"><div class="le-page">
61
- <form id="newAgentForm" style="display:none">
62
- <p class="hint" style="margin:0">Not sure what to build? <a href="/interview">Find your first agent</a>: a short interview that suggests one and creates it. Then give it workflows, described in your own words or from an example.</p>
63
- <h2>New agent</h2>
64
- <label>Name <span class="hint">(what you'll see in the sidebar; you can change it later)</span>
65
- <input type="text" name="displayName" placeholder="Weather assistant" maxlength="60" required>
66
- </label>
67
- <label>ID <span class="hint">(lowercase and hyphens; its folder agents/&lt;id&gt;/ and API address use it, so it can't be changed later)</span>
68
- <input type="text" name="name" placeholder="weather-assistant" pattern="[a-z0-9]+(-[a-z0-9]+)*" required>
69
- </label>
70
- <label>Instructions <span class="hint">(who it is and the rules it always follows)</span>
71
- <textarea name="systemPrompt" placeholder="You are ..."></textarea>
72
- </label>
73
- <label>Model provider
74
- <select name="provider">
75
- <option value="openai" selected>openai</option>
76
- <option value="anthropic">anthropic</option>
77
- <option value="gemini">gemini</option>
78
- <option value="meta">meta</option>
79
- <option value="xai">xai</option>
80
- <option value="deepseek">deepseek</option>
81
- <option value="kimi">kimi</option>
82
- <option value="glm">glm</option>
83
- </select>
84
- </label>
85
- <label id="modelNameLabel">Model name <span class="hint">(choose Other&hellip; to type a model that isn't listed)</span>
86
- <input type="text" name="modelName" value="gpt-6-luna" placeholder="model name">
87
- </label>
88
- <div class="row">
89
- <button type="submit">Create agent</button>
90
- <button type="button" id="cancelNewAgentBtn">Cancel</button>
91
- </div>
92
- </form>
93
- <p class="error" id="newAgentError" style="display:none"></p>
88
+ <header class="le-topbar">
89
+ <button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>
90
+ <h1 class="le-topbar-title">Agents</h1>
91
+ <span class="le-topbar-gap"></span>
92
+ <label class="le-search"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg><input type="search" id="agSearch" placeholder="Search agents" aria-label="Search agents"></label>
93
+ <a class="ag-topbar-link" href="/interview">Find your first agent</a>
94
+ <button type="button" id="newAgentBtn" class="le-btn-dark">+ New agent</button>
95
+ </header>
96
+ <div class="le-scroll"><div class="le-page"><div class="ag">
97
+ <div class="ag-hero"><div><h2 class="le-display">Your agents</h2><p class="le-display-sub" id="agSub">Each has its own instructions, tools and permissions. Open one to chat with it, give it workflows, or change how it works.</p></div>${mascotSvg(92)}</div>
98
+ <div class="le-grid ag-cols2" id="agentUl"><p class="ag-empty">Loading&hellip;</p></div>
94
99
  <p class="hint" id="newAgentResult" style="display:none"></p>
95
- <ul id="agentUl" class="le-cards"></ul>
96
- <p id="empty" style="display:none">No agents yet. Create one above, or add a folder under agents/.</p>
97
- </div></div>
100
+ </div></div></div>
98
101
  </main>
99
102
  </div>
103
+ <dialog class="ag-dialog" id="newAgentDialog" aria-labelledby="agDlgTitle">
104
+ <form id="newAgentForm">
105
+ <div class="ag-dlg-head"><h2 id="agDlgTitle">New agent</h2><button type="button" id="cancelNewAgentBtn">Cancel</button><button type="submit" class="primary">Create agent</button></div>
106
+ <div class="ag-dlg-body">
107
+ <div class="ag-dlg-col">
108
+ <div class="ag-field"><label for="agDisplayName">Name</label><input type="text" id="agDisplayName" name="displayName" placeholder="Weather assistant" maxlength="60" required><p class="hint">What you'll see in the sidebar. You can change it later.</p></div>
109
+ <div class="ag-field"><label for="agId">ID</label><input type="text" id="agId" name="name" placeholder="weather-assistant" pattern="[a-z0-9]+(-[a-z0-9]+)*" required><p class="hint">Lowercase and hyphens. Its folder agents/&lt;id&gt;/ and API address use it, so it can't be changed later.</p></div>
110
+ <div class="ag-field"><label for="agPrompt">Instructions</label><textarea id="agPrompt" name="systemPrompt" placeholder="You are ..."></textarea><p class="hint">Who it is and the rules it always follows. Its workflows say what to do.</p></div>
111
+ </div>
112
+ <div class="ag-dlg-col">
113
+ <div class="ag-field"><label for="agProvider">Model provider</label>
114
+ <select id="agProvider" name="provider">
115
+ <option value="openai" selected>openai</option>
116
+ <option value="anthropic">anthropic</option>
117
+ <option value="gemini">gemini</option>
118
+ <option value="meta">meta</option>
119
+ <option value="xai">xai</option>
120
+ <option value="deepseek">deepseek</option>
121
+ <option value="kimi">kimi</option>
122
+ <option value="glm">glm</option>
123
+ </select></div>
124
+ <div class="ag-field" id="modelNameLabel"><label>Model name
125
+ <input type="text" name="modelName" value="gpt-6-luna" placeholder="model name"></label><p class="hint">Choose Other&hellip; to type a model that isn't listed.</p></div>
126
+ <div class="ag-field"><span class="ag-field-k">Not sure what to build?</span><p class="hint"><a href="/interview">Find your first agent</a>: a short interview suggests one that fits your work and creates it. Then give it workflows, in your own words or from an example.</p></div>
127
+ </div>
128
+ </div>
129
+ <div class="ag-dlg-foot"><p class="error" id="newAgentError" style="display:none;margin:0"></p></div>
130
+ </form>
131
+ </dialog>
100
132
  ${consoleShellScript}
101
133
  <script>
102
134
  (function () {
103
135
  var agentUl = document.getElementById('agentUl');
104
- var empty = document.getElementById('empty');
105
136
  var newAgentBtn = document.getElementById('newAgentBtn');
137
+ var newAgentDialog = document.getElementById('newAgentDialog');
106
138
  var newAgentForm = document.getElementById('newAgentForm');
107
139
  var newAgentError = document.getElementById('newAgentError');
108
140
  var newAgentResult = document.getElementById('newAgentResult');
109
141
  var cancelNewAgentBtn = document.getElementById('cancelNewAgentBtn');
142
+ var search = document.getElementById('agSearch');
143
+ var ICON_AGENT = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="7" width="16" height="12" rx="3"/><path d="M12 3v4"/><circle cx="9" cy="13" r="1"/><circle cx="15" cy="13" r="1"/></svg>';
144
+
145
+ var agents = [];
146
+ var workflowsBy = null;
147
+
148
+ function escapeHtml(s) {
149
+ return String(s).replace(/[&<>"']/g, function (c) {
150
+ return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
151
+ });
152
+ }
110
153
 
111
- var agentNames = [];
112
- // What each agent does, from its workflows: on each card, the first
113
- // few by name, each opening its page.
154
+ // Each agent as a card: its name, its instructions in a line or two,
155
+ // what it does (its workflows, from /workflows/overview), Chat and Open.
156
+ function cardHtml(agent) {
157
+ var qs = '?agent=' + encodeURIComponent(agent.name);
158
+ var list = workflowsBy ? workflowsBy[agent.name] || [] : null;
159
+ var live = list ? list.filter(function (w) { return w.live; }).length : 0;
160
+ var chips = list === null ? '<span class="ag-chip">' + String.fromCharCode(8230) + '</span>'
161
+ : list.length
162
+ ? '<span class="ag-chip strong">' + list.length + (list.length === 1 ? ' workflow' : ' workflows') + '</span>' + (live ? '<span class="ag-chip good">' + live + ' running</span>' : '') +
163
+ list.slice(0, 3).map(function (w) { return '<a class="ag-chip" href="/agents/config' + qs + '&tab=workflows&workflow=' + encodeURIComponent(w.id) + '" title="' + escapeHtml(w.title) + '">' + escapeHtml(w.title) + '</a>'; }).join('') +
164
+ (list.length > 3 ? '<span class="hint">+' + (list.length - 3) + ' more</span>' : '')
165
+ : '<a class="ag-chip" href="/workflows/new' + qs + '">No workflows yet: give it one</a>';
166
+ return '<div class="ag-card">' +
167
+ '<div class="ag-card-head"><span class="ag-icon' + (live ? ' live' : '') + '">' + ICON_AGENT + '</span>' +
168
+ '<span class="ag-card-text"><a class="ag-card-title" href="/agents/config' + qs + '">' + escapeHtml(agent.displayName || agent.name) + (agent.displayName ? '<span class="ag-id">' + escapeHtml(agent.name) + '</span>' : '') + '</a>' +
169
+ (agent.systemPrompt ? '<span class="ag-card-desc">' + escapeHtml(agent.systemPrompt) + '</span>' : '') + '</span>' +
170
+ '<span class="ag-actions"><a class="dark" href="/playground' + qs + '">Chat</a><a href="/agents/config' + qs + '">Open</a></span></div>' +
171
+ '<div class="ag-chips">' + chips + (agent.toSet ? '<a class="ag-chip warn" href="/agents/config' + qs + '&tab=env">' + agent.toSet + (agent.toSet === 1 ? ' setting' : ' settings') + ' to set</a>' : '') + '</div>' +
172
+ '</div>';
173
+ }
174
+
175
+ function render() {
176
+ var q = (search.value || '').trim().toLowerCase();
177
+ var shown = agents.filter(function (a) { return !q || [a.name, a.displayName || '', a.systemPrompt || ''].join(' ').toLowerCase().indexOf(q) !== -1; });
178
+ var total = workflowsBy ? Object.keys(workflowsBy).reduce(function (n, k) { return n + workflowsBy[k].length; }, 0) : 0;
179
+ if (agents.length) document.getElementById('agSub').textContent = agents.length + (agents.length === 1 ? ' agent' : ' agents') + (total ? ', ' + total + (total === 1 ? ' workflow' : ' workflows') : '') + '. Open one to chat with it, give it workflows, or change how it works.';
180
+ var tiles = q ? [] : ['<a class="ag-tile" href="/agents?new=1" data-new-tile><b>+ New agent</b><span>Its own instructions, tools and permissions, for one area of your work.</span></a>',
181
+ '<a class="ag-tile" href="/interview"><b>Find an agent to build</b><span>A short interview suggests one that fits your work, and creates it.</span></a>'];
182
+ var cells = shown.map(cardHtml).concat(tiles);
183
+ agentUl.innerHTML = !agents.length && !q ? tiles.join('')
184
+ : shown.length || tiles.length ? cells.join('') + (cells.length % 2 ? '<div class="ag-filler" aria-hidden="true"></div>' : '')
185
+ : '<p class="ag-empty">No agent matches.</p>';
186
+ var tile = agentUl.querySelector('[data-new-tile]');
187
+ if (tile) tile.addEventListener('click', function (ev) { ev.preventDefault(); newAgentBtn.click(); });
188
+ }
189
+ search.addEventListener('input', render);
190
+
191
+ // What each agent does, from its workflows.
114
192
  function fillWorkflows() {
115
193
  return fetch('/workflows/overview', { headers: { accept: 'application/json' } })
116
194
  .then(function (r) { return r.ok ? r.json() : null; })
117
195
  .then(function (d) {
118
- var by = {};
119
- ((d && d.workflows) || []).forEach(function (w) { (by[w.agent] = by[w.agent] || []).push(w); });
120
- agentNames.forEach(function (name) {
121
- var box = document.querySelector('[data-agent-does="' + CSS.escape(name) + '"]');
122
- if (!box || !d) return;
123
- var list = by[name] || [];
124
- var link = function (w) { return '<a href="/agents/config?agent=' + encodeURIComponent(name) + '&tab=workflows&workflow=' + encodeURIComponent(w.id) + '">' + escapeHtml(w.title) + '</a>'; };
125
- box.innerHTML = list.length
126
- ? '<strong>' + list.length + (list.length === 1 ? ' workflow' : ' workflows') + ':</strong> ' + list.slice(0, 3).map(link).join(', ') + (list.length > 3 ? ' <span class="hint">and ' + (list.length - 3) + ' more</span>' : '')
127
- : '<span class="hint">No workflows yet. <a href="/workflows/new?agent=' + encodeURIComponent(name) + '">Give it one</a></span>';
128
- });
196
+ workflowsBy = {};
197
+ ((d && d.workflows) || []).forEach(function (w) { (workflowsBy[w.agent] = workflowsBy[w.agent] || []).push(w); });
198
+ render();
129
199
  })
130
200
  .catch(function () {});
131
201
  }
132
202
 
133
- function escapeHtml(s) {
134
- return String(s).replace(/[&<>"']/g, function (c) {
135
- return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
136
- });
137
- }
138
-
139
- // (Re)loads the list from GET /agents — factored out so a successful
140
- // create can refresh it directly instead of duplicating this fetch.
203
+ // (Re)loads the list from GET /agents.
141
204
  function loadAgents() {
142
205
  fetch('/agents')
143
206
  .then(function (r) { return r.json(); })
144
207
  .then(function (data) {
145
- var agents = data.agents || [];
146
- agentUl.textContent = '';
147
- agentNames = agents.map(function (a) { return a.name; });
148
- if (!agents.length) {
149
- empty.style.display = 'block';
150
- return;
151
- }
152
- empty.style.display = 'none';
153
- for (var i = 0; i < agents.length; i++) {
154
- var agent = agents[i];
155
- var li = document.createElement('li');
156
- var qs = '?agent=' + encodeURIComponent(agent.name);
157
- li.innerHTML =
158
- '<div class="le-card agent-card">' +
159
- '<div class="name">' + escapeHtml(agent.displayName || agent.name) + (agent.displayName ? ' <span class="hint" style="font-family:var(--font-mono);font-weight:400">' + escapeHtml(agent.name) + '</span>' : '') + '</div>' +
160
- '<div class="does" data-agent-does="' + escapeHtml(agent.name) + '"></div>' +
161
- '<div class="prompt">' + escapeHtml(agent.systemPrompt) + '</div>' +
162
- '<div class="links">' +
163
- '<a class="primary" href="/playground' + qs + '">Chat</a>' +
164
- '<a href="/agents/config' + qs + '">Open</a>' +
165
- '</div></div>';
166
- agentUl.appendChild(li);
167
- }
208
+ agents = data.agents || [];
209
+ render();
168
210
  })
169
211
  .then(fillWorkflows)
170
212
  .catch(function (err) {
171
- empty.textContent = 'Could not load agents: ' + err.message;
172
- empty.style.display = 'block';
213
+ agentUl.innerHTML = '<p class="ag-empty">Could not load agents: ' + escapeHtml(err.message) + '</p>';
173
214
  });
174
215
  }
175
216
 
@@ -206,9 +247,9 @@ ${consoleShellScript}
206
247
  newAgentForm.addEventListener('reset', function () { setTimeout(applyProviderKeys, 0); });
207
248
 
208
249
  newAgentBtn.addEventListener('click', function () {
209
- newAgentBtn.style.display = 'none';
210
- newAgentForm.style.display = 'grid';
211
250
  newAgentResult.style.display = 'none';
251
+ newAgentError.style.display = 'none';
252
+ if (!newAgentDialog.open) newAgentDialog.showModal();
212
253
  newAgentForm.querySelector('input[name="displayName"]').focus();
213
254
  // Checks which providers have keys, then loads the chosen provider's
214
255
  // models; both when the form opens, not on every visit to this page.
@@ -233,9 +274,9 @@ ${consoleShellScript}
233
274
  });
234
275
  newAgentForm.addEventListener('reset', function () { idTyped = false; });
235
276
 
277
+ newAgentDialog.addEventListener('click', function (ev) { if (ev.target === newAgentDialog) newAgentDialog.close(); });
236
278
  cancelNewAgentBtn.addEventListener('click', function () {
237
- newAgentForm.style.display = 'none';
238
- newAgentBtn.style.display = '';
279
+ newAgentDialog.close();
239
280
  newAgentError.style.display = 'none';
240
281
  });
241
282
 
@@ -269,8 +310,7 @@ ${consoleShellScript}
269
310
  .then(function (r) { return r.json().then(function (j) { return { ok: r.ok, body: j }; }); })
270
311
  .then(function (result) {
271
312
  if (!result.ok) throw new Error(result.body.error || 'request failed');
272
- newAgentForm.style.display = 'none';
273
- newAgentBtn.style.display = '';
313
+ newAgentDialog.close();
274
314
  newAgentForm.reset();
275
315
  newAgentResult.style.display = 'block';
276
316
  if (result.body.registered) {