@nanocollective/roster 0.1.0-beta.14 → 0.1.0-beta.15
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/dist/agents-NMGVORU3.js +232 -0
- package/dist/chunk-E3EVPK4I.js +338 -0
- package/dist/chunk-QCKEGMXD.js +562 -0
- package/dist/cli.js +1689 -820
- package/dist/compose-56JIIIHA.js +15 -0
- package/dist/connectors-ZVEPXSAR.js +23 -0
- package/dist/worker/assets/assets/css/connectors.css +50 -0
- package/dist/worker/assets/assets/js/api.js +3 -0
- package/dist/worker/assets/assets/js/app.js +4 -1
- package/dist/worker/assets/assets/js/icons.js +2 -0
- package/dist/worker/assets/assets/js/state.js +11 -1
- package/dist/worker/assets/assets/js/views/connectors.js +290 -0
- package/dist/worker/assets/index.html +4 -0
- package/dist/worker/index.js +2743 -1014
- package/docs/README.md +1 -0
- package/docs/architecture.md +1 -1
- package/docs/commands.md +37 -1
- package/docs/connectors.md +157 -0
- package/docs/cost.md +1 -1
- package/docs/developing.md +2 -2
- package/docs/doctor-codes.md +5 -1
- package/docs/export.md +1 -1
- package/docs/extending.md +1 -1
- package/docs/hosting.md +12 -1
- package/docs/memory.md +1 -1
- package/docs/org-yaml.md +25 -1
- package/docs/portal.md +18 -1
- package/docs/prompts.md +1 -1
- package/docs/security.md +17 -1
- package/docs/session-workflow.md +23 -5
- package/docs/staff-yaml.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/upgrading.md +1 -1
- package/docs/writing-a-charter.md +1 -1
- package/package.json +2 -1
- package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +8 -6
- package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +8 -6
- package/templates/ops/.github/workflows/session.yaml +52 -11
- package/templates/ops/agents.mjs +38 -11
- package/templates/ops/compose.mjs +12 -0
- package/templates/ops/connectors.mjs +722 -0
- package/templates/ops/prompts/_identity.md +14 -0
- package/templates/portal/css/connectors.css +50 -0
- package/templates/portal/index.html +4 -0
- package/templates/portal/js/api.js +3 -0
- package/templates/portal/js/app.js +4 -1
- package/templates/portal/js/icons.js +2 -0
- package/templates/portal/js/state.js +11 -1
- package/templates/portal/js/views/connectors.js +290 -0
|
@@ -45,6 +45,23 @@ on:
|
|
|
45
45
|
required: false
|
|
46
46
|
default: "Bash,Read,Write,Edit,Glob,Grep,WebFetch,WebSearch"
|
|
47
47
|
type: string
|
|
48
|
+
# Which of the caller's secrets are this staff member's. A caller passes its secrets with
|
|
49
|
+
# `secrets: inherit`, so that a connector's key reaches the run without the caller naming
|
|
50
|
+
# it, and `secrets: inherit` cannot rename: CTO_APP_ID stays CTO_APP_ID. These say which
|
|
51
|
+
# names to read. Empty on a caller written before connectors, which maps the secrets by
|
|
52
|
+
# hand instead, and then the mapped names below are the ones read.
|
|
53
|
+
secret_prefix:
|
|
54
|
+
required: false
|
|
55
|
+
default: ""
|
|
56
|
+
type: string
|
|
57
|
+
public_secret_prefix:
|
|
58
|
+
required: false
|
|
59
|
+
default: ""
|
|
60
|
+
type: string
|
|
61
|
+
agent_secret:
|
|
62
|
+
required: false
|
|
63
|
+
default: ""
|
|
64
|
+
type: string
|
|
48
65
|
# Trigger context. Empty on a scheduled run; set when a comment woke us.
|
|
49
66
|
issue_number:
|
|
50
67
|
required: false
|
|
@@ -54,11 +71,13 @@ on:
|
|
|
54
71
|
required: false
|
|
55
72
|
default: ""
|
|
56
73
|
type: string
|
|
74
|
+
# None of these is required, because a caller that inherits passes them under its own names
|
|
75
|
+
# (see secret_prefix above), and GitHub checks `required` against the names declared here.
|
|
57
76
|
secrets:
|
|
58
77
|
APP_ID:
|
|
59
|
-
required:
|
|
78
|
+
required: false
|
|
60
79
|
APP_PRIVATE_KEY:
|
|
61
|
-
required:
|
|
80
|
+
required: false
|
|
62
81
|
PUBLIC_APP_ID:
|
|
63
82
|
required: false
|
|
64
83
|
PUBLIC_APP_PRIVATE_KEY:
|
|
@@ -133,15 +152,18 @@ jobs:
|
|
|
133
152
|
|
|
134
153
|
# `issues: write` is for the failure notice alone, which falls back to this job's own token
|
|
135
154
|
# when the App's cannot be minted. `actions: write` starts a follow-on run. A called workflow
|
|
136
|
-
# cannot raise what its caller granted, so the callers ask for the same.
|
|
155
|
+
# cannot raise what its caller granted, so the callers ask for the same. `id-token: write`
|
|
156
|
+
# lets a run prove to the hosted portal which repo it is, which is how it collects a
|
|
157
|
+
# signed-in connector's access token without a shared secret.
|
|
137
158
|
permissions:
|
|
138
159
|
contents: read
|
|
139
160
|
issues: write
|
|
140
161
|
actions: write
|
|
162
|
+
id-token: write
|
|
141
163
|
|
|
142
164
|
# secrets are not usable in a step-level `if`, so the presence check is hoisted here.
|
|
143
165
|
env:
|
|
144
|
-
HAS_PUBLIC_APP: ${{ secrets.PUBLIC_APP_ID != '' }}
|
|
166
|
+
HAS_PUBLIC_APP: ${{ (secrets.PUBLIC_APP_ID || secrets[format('{0}_APP_ID', inputs.public_secret_prefix)]) != '' }}
|
|
145
167
|
# Nothing is listening once the agent ends its turn: the session is over and a background
|
|
146
168
|
# job dies with the runner. Claude Code moves any command past its timeout (ten minutes by
|
|
147
169
|
# default) into the background, and an agent told "you will be notified" ends its turn to
|
|
@@ -160,8 +182,8 @@ jobs:
|
|
|
160
182
|
id: private
|
|
161
183
|
uses: actions/create-github-app-token@v2
|
|
162
184
|
with:
|
|
163
|
-
app-id: ${{ secrets.APP_ID }}
|
|
164
|
-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
|
185
|
+
app-id: ${{ secrets.APP_ID || secrets[format('{0}_APP_ID', inputs.secret_prefix)] }}
|
|
186
|
+
private-key: ${{ secrets.APP_PRIVATE_KEY || secrets[format('{0}_APP_PRIVATE_KEY', inputs.secret_prefix)] }}
|
|
165
187
|
owner: ${{ github.repository_owner }}
|
|
166
188
|
|
|
167
189
|
# A PR opened with the default GITHUB_TOKEN does not trigger pull_request workflows, so CI
|
|
@@ -171,8 +193,8 @@ jobs:
|
|
|
171
193
|
if: env.HAS_PUBLIC_APP == 'true'
|
|
172
194
|
uses: actions/create-github-app-token@v2
|
|
173
195
|
with:
|
|
174
|
-
app-id: ${{ secrets.PUBLIC_APP_ID }}
|
|
175
|
-
private-key: ${{ secrets.PUBLIC_APP_PRIVATE_KEY }}
|
|
196
|
+
app-id: ${{ secrets.PUBLIC_APP_ID || secrets[format('{0}_APP_ID', inputs.public_secret_prefix)] }}
|
|
197
|
+
private-key: ${{ secrets.PUBLIC_APP_PRIVATE_KEY || secrets[format('{0}_APP_PRIVATE_KEY', inputs.public_secret_prefix)] }}
|
|
176
198
|
owner: ${{ github.repository_owner }}
|
|
177
199
|
|
|
178
200
|
# Tell the human it was heard. This is the only signal between the request and the reply
|
|
@@ -347,7 +369,7 @@ jobs:
|
|
|
347
369
|
# forty lines into a log, after the checkout has already happened.
|
|
348
370
|
- name: Check the agent has a credential
|
|
349
371
|
env:
|
|
350
|
-
A: ${{ secrets.AGENT_TOKEN }}
|
|
372
|
+
A: ${{ secrets.AGENT_TOKEN || secrets[inputs.agent_secret] }}
|
|
351
373
|
B: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
352
374
|
run: |
|
|
353
375
|
if [ -z "$A" ] && [ -z "$B" ]; then
|
|
@@ -355,8 +377,27 @@ jobs:
|
|
|
355
377
|
exit 1
|
|
356
378
|
fi
|
|
357
379
|
|
|
380
|
+
# The services this staff member may use (`connectors:` in org.yaml), written as the
|
|
381
|
+
# running agent's own MCP config, with each key read from the caller's secrets. The file
|
|
382
|
+
# goes in the runner's temp directory, outside every checkout, so no commit can carry it.
|
|
383
|
+
# Never fatal: a connector without its key is left out and named in the summary, and the
|
|
384
|
+
# run goes ahead without it.
|
|
385
|
+
#
|
|
386
|
+
# `toJSON(secrets)` is read by this step alone. Nothing else in the job sees the secrets
|
|
387
|
+
# it does not name, and the agent sees only the keys of its own connectors, inside the file.
|
|
388
|
+
- name: Connect services
|
|
389
|
+
id: connectors
|
|
390
|
+
if: hashFiles('roster-ops/connectors.mjs') != ''
|
|
391
|
+
continue-on-error: true
|
|
392
|
+
env:
|
|
393
|
+
ROSTER_SECRETS: ${{ toJSON(secrets) }}
|
|
394
|
+
ROSTER_PORTAL_TOKEN_URL: ${{ vars.ROSTER_PORTAL_URL }}
|
|
395
|
+
run: node roster-ops/connectors.mjs --staff "${{ inputs.staff }}" --ops roster-ops --brains . --out "$RUNNER_TEMP/roster-connectors" >> "$GITHUB_OUTPUT"
|
|
396
|
+
|
|
358
397
|
- name: Work out which agent runs this
|
|
359
398
|
id: agent
|
|
399
|
+
env:
|
|
400
|
+
ROSTER_CONNECTORS: ${{ steps.connectors.outputs.file }}
|
|
360
401
|
run: node roster-ops/agents.mjs --staff "${{ inputs.staff }}" --ops roster-ops --brains . >> "$GITHUB_OUTPUT"
|
|
361
402
|
|
|
362
403
|
# `uses:` cannot be an expression, so an Action-based runner has to be written out
|
|
@@ -369,7 +410,7 @@ jobs:
|
|
|
369
410
|
GH_TOKEN: ${{ steps.private.outputs.token }}
|
|
370
411
|
PUBLIC_TOKEN: ${{ steps.public.outputs.token }}
|
|
371
412
|
with:
|
|
372
|
-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN || secrets.AGENT_TOKEN }}
|
|
413
|
+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN || secrets.AGENT_TOKEN || secrets[inputs.agent_secret] }}
|
|
373
414
|
# The action refuses to run for a bot unless it is named here. A peer's ask is opened
|
|
374
415
|
# by that peer's App, so on a peer run, and only then, the one bot that opened it is
|
|
375
416
|
# allowed. The caller has already checked it is an App, not this staff member's own,
|
|
@@ -405,7 +446,7 @@ jobs:
|
|
|
405
446
|
AGENT_FLAGS: ${{ steps.agent.outputs.flags }}
|
|
406
447
|
# Kept for a custom `run` written before permissions existed.
|
|
407
448
|
AGENT_TOOLS: ${{ inputs.allowed_tools }}
|
|
408
|
-
AGENT_TOKEN: ${{ secrets.AGENT_TOKEN }}
|
|
449
|
+
AGENT_TOKEN: ${{ secrets.AGENT_TOKEN || secrets[inputs.agent_secret] }}
|
|
409
450
|
FALLBACK_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
410
451
|
TOKEN_ENV: ${{ steps.agent.outputs.token_env }}
|
|
411
452
|
INSTALL: ${{ steps.agent.outputs.install }}
|
package/templates/ops/agents.mjs
CHANGED
|
@@ -136,7 +136,7 @@ export const PRESETS = {
|
|
|
136
136
|
* anything written out longhand. A tenant that needs an agent nobody has heard of writes
|
|
137
137
|
* `install`, `run` and `token_env` and never touches this file.
|
|
138
138
|
*/
|
|
139
|
-
export function resolveAgent(org, staff = {}) {
|
|
139
|
+
export function resolveAgent(org, staff = {}, extra = {}) {
|
|
140
140
|
const asked = staff.agent ?? org.agent ?? {};
|
|
141
141
|
const spec = typeof asked === "string" ? { id: asked } : asked;
|
|
142
142
|
const id = spec.id ?? "claude-code-action";
|
|
@@ -163,7 +163,7 @@ export function resolveAgent(org, staff = {}) {
|
|
|
163
163
|
token_env: merged.token_env,
|
|
164
164
|
// The staff member's own model wins; then the agent's default. Empty means "the agent's".
|
|
165
165
|
model: staff.model ?? merged.model ?? "",
|
|
166
|
-
flags: flagsFor(merged, spec, org, staff),
|
|
166
|
+
flags: flagsFor(merged, spec, org, staff, extra),
|
|
167
167
|
config: merged.config ?? null,
|
|
168
168
|
};
|
|
169
169
|
}
|
|
@@ -183,24 +183,27 @@ export const LEVELS = ["read-only", "workspace", "full"];
|
|
|
183
183
|
* `options` is the escape hatch, in that agent's own vocabulary, spelled onto its command line
|
|
184
184
|
* by the preset. Anything roster does not model is still reachable without waiting for us.
|
|
185
185
|
*/
|
|
186
|
-
function flagsFor(merged, spec, org, staff) {
|
|
186
|
+
function flagsFor(merged, spec, org, staff, extra = {}) {
|
|
187
187
|
const out = [];
|
|
188
|
-
const asked =
|
|
189
|
-
if (!LEVELS.includes(asked)) {
|
|
190
|
-
throw new Error(`unknown permissions "${asked}". One of: ${LEVELS.join(", ")}`);
|
|
191
|
-
}
|
|
188
|
+
const asked = permissionOf(org, staff);
|
|
192
189
|
|
|
193
190
|
/* `allowed_tools` predates the levels and is Claude's own vocabulary, so it still wins for
|
|
194
191
|
an agent that takes a tool list. Nothing translates it for the others: a list written for
|
|
195
192
|
one tool is not a permission level for another, and guessing would be worse than saying so. */
|
|
196
193
|
const tools = staff.allowed_tools ?? org.defaults?.allowed_tools;
|
|
197
194
|
const table = merged.permissions;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
195
|
+
/* A connector's tools join the list, or Claude would be handed an MCP server and forbidden
|
|
196
|
+
to call it. Only for an agent that takes a list: the others gate a server by its config. */
|
|
197
|
+
const more = (extra.tools ?? []).filter(Boolean);
|
|
198
|
+
if (table === CLAUDE_TOOLS) {
|
|
199
|
+
const base = tools
|
|
200
|
+
? (Array.isArray(tools) ? tools.join(",") : String(tools)).replace(/\s+/g, "")
|
|
201
|
+
: CLAUDE_TOOLS[asked].match(/"([^"]*)"/)[1];
|
|
202
|
+
out.push(`--allowedTools "${[base, ...more].filter(Boolean).join(",")}"`);
|
|
201
203
|
} else if (table) {
|
|
202
204
|
out.push(table[asked]);
|
|
203
205
|
}
|
|
206
|
+
if (extra.flags) out.push(extra.flags);
|
|
204
207
|
|
|
205
208
|
const options = { ...(spec.options ?? {}), ...(staff.options ?? {}) };
|
|
206
209
|
const speller = merged.option;
|
|
@@ -217,10 +220,24 @@ function flagsFor(merged, spec, org, staff) {
|
|
|
217
220
|
return out.filter(Boolean).join(" ");
|
|
218
221
|
}
|
|
219
222
|
|
|
223
|
+
/** The level a staff member runs at: their own, else the agent's, else the org's, else full. */
|
|
224
|
+
export function permissionOf(org, staff = {}) {
|
|
225
|
+
const agent = staff.agent ?? org.agent;
|
|
226
|
+
const spec = agent && typeof agent === "object" ? agent : {};
|
|
227
|
+
const level = staff.permissions ?? spec.permissions ?? org.permissions ?? "full";
|
|
228
|
+
if (!LEVELS.includes(level)) {
|
|
229
|
+
throw new Error(`unknown permissions "${level}". One of: ${LEVELS.join(", ")}`);
|
|
230
|
+
}
|
|
231
|
+
return level;
|
|
232
|
+
}
|
|
233
|
+
|
|
220
234
|
function strip(o) {
|
|
221
235
|
const out = {};
|
|
222
236
|
for (const [k, v] of Object.entries(o)) if (v !== undefined && v !== null && v !== "") out[k] = v;
|
|
223
237
|
delete out.id;
|
|
238
|
+
// The spec's `permissions` is a level, one word, and permissionOf reads it from the spec.
|
|
239
|
+
// Merged in, it would replace the preset's table of spellings and leave no flags at all.
|
|
240
|
+
delete out.permissions;
|
|
224
241
|
return out;
|
|
225
242
|
}
|
|
226
243
|
|
|
@@ -248,7 +265,17 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
|
|
248
265
|
/* A staff member with no manifest is doctor's problem; the org's default still resolves. */
|
|
249
266
|
}
|
|
250
267
|
|
|
251
|
-
|
|
268
|
+
/* What connectors.mjs wired up for this run, if anything: flags for the command line and
|
|
269
|
+
tool names for the allowlist. Paths only; the keys are in files this never reads. */
|
|
270
|
+
let wiring = {};
|
|
271
|
+
if (process.env.ROSTER_CONNECTORS) {
|
|
272
|
+
try {
|
|
273
|
+
wiring = JSON.parse(readFileSync(process.env.ROSTER_CONNECTORS, "utf8"));
|
|
274
|
+
} catch {
|
|
275
|
+
process.stderr.write("agents: the connectors' wiring could not be read, so none are used\n");
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const agent = resolveAgent(org, manifest, wiring);
|
|
252
279
|
const out = [
|
|
253
280
|
`kind=${agent.kind}`,
|
|
254
281
|
`id=${agent.id}`,
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
import * as nodeFs from "node:fs";
|
|
15
15
|
import { join, dirname, resolve } from "node:path";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
|
+
// Beside this file in a tenant, but read without failing when it is not: an ops repo vendored
|
|
18
|
+
// before connectors existed still composes, with no services in its prompts.
|
|
19
|
+
const { connectorsOf } = await import("./connectors.mjs").catch(() => ({ connectorsOf: () => [] }));
|
|
17
20
|
|
|
18
21
|
// ---------------------------------------------------------------------------
|
|
19
22
|
// A strict, tiny YAML subset: nested maps, lists of scalars, lists of inline
|
|
@@ -388,6 +391,15 @@ export function compose({
|
|
|
388
391
|
humans_extra: humanSentence(humans.slice(1)),
|
|
389
392
|
// Who can read along and cannot rule. Empty, and the paragraph gone, when nobody is.
|
|
390
393
|
humans_viewing: humanSentence(everyone.filter((h) => h.viewOnly)),
|
|
394
|
+
// The services this staff member may use, as a list for the prompt. Empty, and the section
|
|
395
|
+
// gone, when they have none. Whether each one's key is present is only known in the run.
|
|
396
|
+
connectors: connectorsOf(org, staff)
|
|
397
|
+
.filter((c) => !c.problem)
|
|
398
|
+
.map((c) => {
|
|
399
|
+
const ro = c.readOnly || self.permissions === "read-only";
|
|
400
|
+
return `- **${c.name}**, as the \`${c.id}\` MCP server${ro ? ", read only" : ""}`;
|
|
401
|
+
})
|
|
402
|
+
.join("\n"),
|
|
391
403
|
};
|
|
392
404
|
|
|
393
405
|
// "staff:foo.md" resolves inside the staff member's own brain repo, which is how a
|