@agentproto/agencies 0.1.0-alpha.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/AGENTAGENCIES.md +39 -0
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/capacity-98VwY285.d.ts +862 -0
- package/dist/chunk-DYQ4A5HV.mjs +649 -0
- package/dist/chunk-DYQ4A5HV.mjs.map +1 -0
- package/dist/chunk-GAJQ5ZC2.mjs +149 -0
- package/dist/chunk-GAJQ5ZC2.mjs.map +1 -0
- package/dist/chunk-SOJ4GQR7.mjs +3 -0
- package/dist/chunk-SOJ4GQR7.mjs.map +1 -0
- package/dist/composition/index.d.ts +61 -0
- package/dist/composition/index.mjs +75 -0
- package/dist/composition/index.mjs.map +1 -0
- package/dist/doctypes/index.d.ts +61 -0
- package/dist/doctypes/index.mjs +4 -0
- package/dist/doctypes/index.mjs.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.mjs +17 -0
- package/dist/index.mjs.map +1 -0
- package/dist/renderers/index.d.ts +288 -0
- package/dist/renderers/index.mjs +321 -0
- package/dist/renderers/index.mjs.map +1 -0
- package/dist/validators/index.d.ts +70 -0
- package/dist/validators/index.mjs +4 -0
- package/dist/validators/index.mjs.map +1 -0
- package/package.json +94 -0
- package/src/spec/canvakit-templates/agency.agency-overview/template.canvakit.html +173 -0
- package/src/spec/canvakit-templates/agency.agency-profile/template.canvakit.html +121 -0
- package/src/spec/canvakit-templates/agency.agreement-signing/template.canvakit.html +164 -0
- package/src/spec/canvakit-templates/agency.deliverable-review/template.canvakit.html +148 -0
- package/src/spec/canvakit-templates/agency.engagement-dashboard/template.canvakit.html +191 -0
- package/src/spec/canvakit-templates/agency.invoice-pdf/template.canvakit.html +142 -0
- package/src/spec/canvakit-templates/agency.procedure-card/template.canvakit.html +93 -0
- package/src/spec/snippets/agency-overview-rollup/procedures/compute-agency-overview/PROCEDURE.md +88 -0
- package/src/spec/snippets/agency-overview-rollup/routines/agency-overview-rollup/ROUTINE.md +58 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
template: true
|
|
3
|
+
name: agency.procedure-card
|
|
4
|
+
version: 1.0.0-alpha
|
|
5
|
+
description: |
|
|
6
|
+
Narrative card view of a PROCEDURE.md — what it does, who triggers it,
|
|
7
|
+
what skills it requires, and the step list. Doubles as an in-product help
|
|
8
|
+
surface ("how does this engagement work?") and a published preview on
|
|
9
|
+
agencies.sh template registry pages.
|
|
10
|
+
|
|
11
|
+
Reads the source PROCEDURE.md by path; the host is responsible for
|
|
12
|
+
computing `currentStepId` if rendered inside an active engagement context
|
|
13
|
+
(so the card can highlight progress).
|
|
14
|
+
author: agencies.sh
|
|
15
|
+
refreshEvery: 5m
|
|
16
|
+
variables:
|
|
17
|
+
agencyName: ""
|
|
18
|
+
procedurePath: "procedures/example/PROCEDURE.md"
|
|
19
|
+
currentStepId: ""
|
|
20
|
+
sources:
|
|
21
|
+
procedure:
|
|
22
|
+
kind: file
|
|
23
|
+
path: "{{procedurePath}}"
|
|
24
|
+
---
|
|
25
|
+
<!doctype html>
|
|
26
|
+
<html lang="en">
|
|
27
|
+
<head>
|
|
28
|
+
<meta charset="utf-8" />
|
|
29
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
30
|
+
<title>{{procedure.name}} · procedure</title>
|
|
31
|
+
<style>
|
|
32
|
+
:root { --fg: #1a1a1a; --muted: #666; --bg: #faf9f7; --panel: #fff; --border: #e5e5e5; --accent: #1a1a1a; --done: #0a7d30; --active: #2563eb; }
|
|
33
|
+
body { font: 15px/1.55 ui-sans-serif, system-ui, sans-serif; max-width: 44rem; margin: 0 auto; padding: 2.5rem 1.5rem; color: var(--fg); background: var(--bg); }
|
|
34
|
+
header { margin-bottom: 1.5rem; }
|
|
35
|
+
.lead { color: var(--muted); margin: 0 0 0.25rem; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.06em; }
|
|
36
|
+
h1 { font-size: 1.625rem; letter-spacing: -0.01em; margin: 0; }
|
|
37
|
+
.description { color: #333; margin: 0.5rem 0 1.5rem; font-size: 1rem; line-height: 1.55; }
|
|
38
|
+
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
|
|
39
|
+
.panel h2 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.08em; color: #666; margin: 0 0 0.875rem; }
|
|
40
|
+
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; font-size: 0.875rem; }
|
|
41
|
+
.meta dt { font-weight: 500; color: #444; }
|
|
42
|
+
.meta dd { margin: 0; }
|
|
43
|
+
.pill { display: inline-block; padding: 0.125rem 0.5rem; border-radius: 999px; font-size: 0.75rem; background: #f0eee5; color: #444; margin-right: 0.25rem; margin-bottom: 0.25rem; }
|
|
44
|
+
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
|
|
45
|
+
.step { position: relative; padding: 0.875rem 0 0.875rem 2.75rem; border-bottom: 1px solid #efece5; }
|
|
46
|
+
.step:last-child { border-bottom: 0; }
|
|
47
|
+
.step::before { content: counter(step); counter-increment: step; position: absolute; left: 0; top: 0.875rem; width: 1.875rem; height: 1.875rem; border-radius: 999px; background: #f0eee5; color: #555; font-weight: 600; font-size: 0.875rem; display: flex; align-items: center; justify-content: center; }
|
|
48
|
+
.step.active::before { background: var(--active); color: #fff; }
|
|
49
|
+
.step.done::before { background: var(--done); color: #fff; content: "✓"; counter-increment: step; }
|
|
50
|
+
.step .name { font-weight: 500; font-size: 0.9375rem; }
|
|
51
|
+
.step .name .marker { display: none; }
|
|
52
|
+
.step.active .name .marker { display: inline-block; padding: 0.125rem 0.5rem; border-radius: 999px; font-size: 0.6875rem; background: var(--active); color: #fff; margin-left: 0.5rem; }
|
|
53
|
+
.step .desc { color: var(--muted); font-size: 0.875rem; margin-top: 0.25rem; line-height: 1.55; }
|
|
54
|
+
.step .skill { font-size: 0.75rem; color: #777; margin-top: 0.25rem; }
|
|
55
|
+
</style>
|
|
56
|
+
</head>
|
|
57
|
+
<body>
|
|
58
|
+
<header>
|
|
59
|
+
<p class="lead">{{#agencyName}}{{agencyName}} · {{/agencyName}}procedure</p>
|
|
60
|
+
<h1>{{procedure.name}}</h1>
|
|
61
|
+
<p class="description">{{procedure.description}}</p>
|
|
62
|
+
</header>
|
|
63
|
+
|
|
64
|
+
<section class="panel">
|
|
65
|
+
<h2>Overview</h2>
|
|
66
|
+
<dl class="meta">
|
|
67
|
+
<dt>Estimated duration</dt><dd>{{procedure.estimatedDuration}}</dd>
|
|
68
|
+
<dt>Required skills</dt><dd>
|
|
69
|
+
{{#procedure.requiredSkills}}<span class="pill">{{.}}</span>{{/procedure.requiredSkills}}
|
|
70
|
+
</dd>
|
|
71
|
+
<dt>Triggers</dt><dd>
|
|
72
|
+
{{#procedure.triggerLabels}}<span class="pill">{{.}}</span>{{/procedure.triggerLabels}}
|
|
73
|
+
</dd>
|
|
74
|
+
{{#procedure.autonomyPolicy}}
|
|
75
|
+
<dt>Autonomy policy</dt><dd><code>{{.}}</code></dd>
|
|
76
|
+
{{/procedure.autonomyPolicy}}
|
|
77
|
+
</dl>
|
|
78
|
+
</section>
|
|
79
|
+
|
|
80
|
+
<section class="panel">
|
|
81
|
+
<h2>Steps</h2>
|
|
82
|
+
<ol class="steps">
|
|
83
|
+
{{#procedure.steps}}
|
|
84
|
+
<li class="step {{stateClass}}">
|
|
85
|
+
<div class="name">{{name}}<span class="marker">In progress</span></div>
|
|
86
|
+
<div class="desc">{{description}}</div>
|
|
87
|
+
{{#requiredSkill}}<div class="skill">requires <code>{{.}}</code></div>{{/requiredSkill}}
|
|
88
|
+
</li>
|
|
89
|
+
{{/procedure.steps}}
|
|
90
|
+
</ol>
|
|
91
|
+
</section>
|
|
92
|
+
</body>
|
|
93
|
+
</html>
|
package/src/spec/snippets/agency-overview-rollup/procedures/compute-agency-overview/PROCEDURE.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
schema: agentagencies/v1
|
|
3
|
+
doctype: procedure
|
|
4
|
+
slug: compute-agency-overview
|
|
5
|
+
name: Compute agency overview snapshot
|
|
6
|
+
description: |
|
|
7
|
+
Walk the workspace and emit a fresh agency-overview snapshot. Vendor-neutral
|
|
8
|
+
playbook — any orchestration runtime can follow these steps (the canonical
|
|
9
|
+
implementation lives in `@agencies/spec/runtime` as
|
|
10
|
+
`computeAgencyOverview(config)`).
|
|
11
|
+
|
|
12
|
+
triggers:
|
|
13
|
+
- routine: agency-overview-rollup
|
|
14
|
+
requiredSkills:
|
|
15
|
+
- workspace.read
|
|
16
|
+
estimatedDuration: PT30S
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- id: walk-counterparties
|
|
20
|
+
description: |
|
|
21
|
+
List counterparties/*/COUNTERPARTY.md and project the active subset
|
|
22
|
+
(mergedIntoId == null, status != "archived"). Used to count distinct
|
|
23
|
+
counterparties in the snapshot.
|
|
24
|
+
output: in-memory list
|
|
25
|
+
|
|
26
|
+
- id: walk-engagements
|
|
27
|
+
description: |
|
|
28
|
+
List engagements/*/ENGAGEMENT.md and parse frontmatter for status,
|
|
29
|
+
activeStep, expected value (sum of AGREEMENT.md line items), and
|
|
30
|
+
requiredSignatures. Group by status to fill `byStatus`. Compute
|
|
31
|
+
`pipelineValueFormatted` = sum of expected value where status ∈
|
|
32
|
+
{`scoping`, `proposed`, `negotiating`}.
|
|
33
|
+
|
|
34
|
+
- id: walk-invoices
|
|
35
|
+
description: |
|
|
36
|
+
Scan engagements/*/invoices/*/INVOICE.md. Sum paidAmount per month for
|
|
37
|
+
MRR; collect the top-N most-recent paid invoices for `recentPayments`.
|
|
38
|
+
|
|
39
|
+
- id: walk-pending-signatures
|
|
40
|
+
description: |
|
|
41
|
+
Read `_index/pending-signatures.json` (regeneratable; rebuild from
|
|
42
|
+
a directory walk if missing). Group by engagement, compute oldest
|
|
43
|
+
pending age. Tag staleness label per (oldest, threshold).
|
|
44
|
+
|
|
45
|
+
- id: project-snapshot
|
|
46
|
+
description: |
|
|
47
|
+
Assemble the result against `AgencyOverviewSnapshot` shape from
|
|
48
|
+
`@agencies/spec/renderers`. Stamp `generatedAt = now`. Validate
|
|
49
|
+
against `agencyOverviewSnapshotSchema` before writing.
|
|
50
|
+
|
|
51
|
+
- id: write-snapshot
|
|
52
|
+
description: |
|
|
53
|
+
Atomically write `_snapshots/agency-overview.json`. The dashboard
|
|
54
|
+
reads this file on its next refresh tick.
|
|
55
|
+
output: _snapshots/agency-overview.json
|
|
56
|
+
|
|
57
|
+
- id: record-audit
|
|
58
|
+
description: |
|
|
59
|
+
Append a `snapshot.refreshed` entry to `audit/audit-log.jsonl` with
|
|
60
|
+
the row counts as payload (counterparties, engagements, invoices).
|
|
61
|
+
Lets operators see "did the rollup actually run?" in the dashboard's
|
|
62
|
+
audit feed.
|
|
63
|
+
output: audit/audit-log.jsonl (one line)
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
# Compute agency overview snapshot
|
|
67
|
+
|
|
68
|
+
The vendor-neutral playbook for the agency-overview rollup. The agencies/v1
|
|
69
|
+
runtime ships a Node implementation as `computeAgencyOverview()` from
|
|
70
|
+
`@agencies/spec/runtime`. Other runtimes (Temporal, n8n, hand-rolled) can follow
|
|
71
|
+
the steps above — every step has a deterministic input/output described in the
|
|
72
|
+
workspace contract.
|
|
73
|
+
|
|
74
|
+
## Performance notes
|
|
75
|
+
|
|
76
|
+
The walk is O(N) over engagements + invoices. For an agency with 500 engagements
|
|
77
|
+
and 50 invoices each, expect ~0.5–1s on cold cache. Most cost is in YAML
|
|
78
|
+
frontmatter parsing — if that becomes a bottleneck, cache parsed frontmatter
|
|
79
|
+
keyed by `(path, mtime)` between invocations.
|
|
80
|
+
|
|
81
|
+
## Failure modes
|
|
82
|
+
|
|
83
|
+
- **Corrupted ENGAGEMENT.md** — the walker logs the path + skips the row. The
|
|
84
|
+
audit-log entry includes a `skipped` count so operators see drift.
|
|
85
|
+
- **Missing `_index/pending-signatures.json`** — falls back to a fresh walk of
|
|
86
|
+
`signatures/` directories. Slower but correct.
|
|
87
|
+
- **Concurrent writes during walk** — the snapshot is a best-effort
|
|
88
|
+
point-in-time view. The next tick (10m) reconciles.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
schema: agentagencies/v1
|
|
3
|
+
doctype: routine
|
|
4
|
+
slug: agency-overview-rollup
|
|
5
|
+
name: Agency overview rollup
|
|
6
|
+
description: |
|
|
7
|
+
Recompute the agency-wide overview snapshot every 10 minutes. The procedure
|
|
8
|
+
walks counterparties/, engagements/, invoices/ and writes a JSON file at
|
|
9
|
+
`_snapshots/agency-overview.json` for the agency.agency-overview canvakit
|
|
10
|
+
template to read.
|
|
11
|
+
|
|
12
|
+
Cheap to recompute (a directory walk + frontmatter parse), so the cadence
|
|
13
|
+
errs on the side of fresh. Bump down to 5 minutes if operators complain
|
|
14
|
+
about staleness; bump up to 30 minutes if the agency has hundreds of
|
|
15
|
+
engagements and the walk becomes expensive.
|
|
16
|
+
|
|
17
|
+
runs: compute-agency-overview
|
|
18
|
+
trigger:
|
|
19
|
+
kind: schedule
|
|
20
|
+
cronExpression: "*/10 * * * *"
|
|
21
|
+
timezone: UTC
|
|
22
|
+
escalation:
|
|
23
|
+
ifPendingAfter: PT2H
|
|
24
|
+
escalateTo:
|
|
25
|
+
- operator:founder
|
|
26
|
+
metadata:
|
|
27
|
+
agency:
|
|
28
|
+
canonical: true
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# Agency overview rollup
|
|
32
|
+
|
|
33
|
+
Schedules the **`compute-agency-overview`** procedure every 10 minutes. The
|
|
34
|
+
procedure does a single-pass walk of the workspace, projects the aggregate into
|
|
35
|
+
a JSON snapshot, and writes it to `_snapshots/agency-overview.json`.
|
|
36
|
+
|
|
37
|
+
The agency dashboard (canvakit template `agency.agency-overview`) reads the
|
|
38
|
+
snapshot via a `kind: file` data source — no live globs at render time, so the
|
|
39
|
+
page stays cheap regardless of engagement count.
|
|
40
|
+
|
|
41
|
+
## When to override this routine
|
|
42
|
+
|
|
43
|
+
Fork this ROUTINE.md if you need:
|
|
44
|
+
|
|
45
|
+
- **A different cadence** — change `cronExpression`. Match it to your operators'
|
|
46
|
+
working hours if you don't need 24/7 freshness.
|
|
47
|
+
- **An additional snapshot** — copy this routine, change `runs` to a sibling
|
|
48
|
+
procedure that writes a different snapshot file (e.g.,
|
|
49
|
+
`_snapshots/cashflow.json` for a cashflow widget).
|
|
50
|
+
- **Per-vertical aggregations** — your `compute-agency-overview` procedure can
|
|
51
|
+
branch on `AGENCY.md.verticals[]` and emit verticalized stats.
|
|
52
|
+
|
|
53
|
+
## How to disable
|
|
54
|
+
|
|
55
|
+
Delete this file. The procedure can still be invoked ad-hoc via
|
|
56
|
+
`runProcedureTool({ slug: "compute-agency-overview" })`, and the dashboard will
|
|
57
|
+
simply show whatever snapshot is on disk (or render the staleness banner if
|
|
58
|
+
none).
|