lastlight-core 0.24.5 → 0.25.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/config/default.yaml +31 -0
- package/dist/admin/chat-session-reader.js +3 -0
- package/dist/admin/chat-session-reader.js.map +1 -1
- package/dist/admin/index.js +3 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/routes.js +86 -19
- package/dist/admin/routes.js.map +1 -1
- package/dist/admin/sessions.d.ts +23 -2
- package/dist/admin/sessions.js +5 -1
- package/dist/admin/sessions.js.map +1 -1
- package/dist/config/config.d.ts +38 -0
- package/dist/config/config.js +16 -0
- package/dist/config/config.js.map +1 -1
- package/dist/connectors/github-webhook.d.ts +34 -0
- package/dist/connectors/github-webhook.js +69 -0
- package/dist/connectors/github-webhook.js.map +1 -1
- package/dist/engine/dispatcher.js +18 -4
- package/dist/engine/dispatcher.js.map +1 -1
- package/dist/engine/github/github.d.ts +53 -1
- package/dist/engine/github/github.js +176 -2
- package/dist/engine/github/github.js.map +1 -1
- package/dist/engine/github/team-visibility.d.ts +118 -0
- package/dist/engine/github/team-visibility.js +298 -0
- package/dist/engine/github/team-visibility.js.map +1 -0
- package/dist/index.js +25 -6
- package/dist/index.js.map +1 -1
- package/dist/state/db.d.ts +9 -0
- package/dist/state/db.js +9 -0
- package/dist/state/db.js.map +1 -1
- package/dist/state/execution-store.d.ts +33 -11
- package/dist/state/execution-store.js +174 -77
- package/dist/state/execution-store.js.map +1 -1
- package/dist/state/migrate.js +133 -0
- package/dist/state/migrate.js.map +1 -1
- package/dist/state/repo-ref.d.ts +75 -0
- package/dist/state/repo-ref.js +104 -0
- package/dist/state/repo-ref.js.map +1 -0
- package/dist/state/team-store.d.ts +108 -0
- package/dist/state/team-store.js +178 -0
- package/dist/state/team-store.js.map +1 -0
- package/dist/state/workflow-run-store.d.ts +32 -6
- package/dist/state/workflow-run-store.js +70 -31
- package/dist/state/workflow-run-store.js.map +1 -1
- package/dist/workflows/resume.js +5 -2
- package/dist/workflows/resume.js.map +1 -1
- package/package.json +3 -3
package/config/default.yaml
CHANGED
|
@@ -97,6 +97,37 @@ feedback:
|
|
|
97
97
|
retentionDays: 90 # anchors pruned after this; signals kept
|
|
98
98
|
otel: true # export each signal as a span on the run's trace
|
|
99
99
|
|
|
100
|
+
# The optional "my teams' repos" dashboard filter (issue #169).
|
|
101
|
+
#
|
|
102
|
+
# Offers each GitHub-authenticated user a header toggle that narrows every list
|
|
103
|
+
# to the managed repos their GitHub org teams own. **Opt-in and off by default**
|
|
104
|
+
# — nobody's view changes until they choose it, and the choice is remembered per
|
|
105
|
+
# browser.
|
|
106
|
+
#
|
|
107
|
+
# Opt-in is load-bearing, not timidity. Team grants describe INVOLVEMENT, not
|
|
108
|
+
# access: an org owner reaches every repo without a team grant anywhere. Applied
|
|
109
|
+
# as a default this hides people's own work — measured against the live nearform
|
|
110
|
+
# install, one maintainer's single team covered 4 of 8 managed repos and hid
|
|
111
|
+
# `nearform/lastlight`, which they own. Applied as a filter somebody switched on,
|
|
112
|
+
# the same narrowing is exactly the decluttering they asked for.
|
|
113
|
+
#
|
|
114
|
+
# This flag is the OPERATOR switch: it needs the GitHub App's organization
|
|
115
|
+
# `Members: read` permission, so turn it on once you've granted that and
|
|
116
|
+
# re-consented the App on each installation. Without it the toggle never
|
|
117
|
+
# appears. UI only — every list endpoint still returns global data, and each
|
|
118
|
+
# budget below fails OPEN (shows more).
|
|
119
|
+
#
|
|
120
|
+
# Nothing is crawled up front. A user's teams are resolved on demand, on their
|
|
121
|
+
# first dashboard request, and cached — so an org with thousands of repos and
|
|
122
|
+
# hundreds of teams costs a handful of GraphQL requests per logged-in person,
|
|
123
|
+
# not a full-org walk.
|
|
124
|
+
teamVisibility:
|
|
125
|
+
enabled: false # operator switch — needs the App's `Members: read`
|
|
126
|
+
ttlMinutes: 60 # how long a resolved answer is reused
|
|
127
|
+
maxTeamsPerUser: 50 # more teams than this ⇒ fail open
|
|
128
|
+
maxPagesPerTeam: 20 # 100 repos/page; a bigger grant ⇒ fail open
|
|
129
|
+
maxRequestsPerResolve: 60 # absolute ceiling for one cache miss
|
|
130
|
+
|
|
100
131
|
cleanup:
|
|
101
132
|
sandbox:
|
|
102
133
|
enabled: true # master switch for the TTL/LRU sweep
|
|
@@ -52,6 +52,9 @@ export class ChatSessionReader {
|
|
|
52
52
|
last_assistant_content: t.lastAssistantContent,
|
|
53
53
|
agentIds: [],
|
|
54
54
|
platform: t.platform,
|
|
55
|
+
// Sourced straight from `executions.repo` (issue #169) — a repo-less
|
|
56
|
+
// Slack thread reports null and is never filtered out.
|
|
57
|
+
repo: t.repo,
|
|
55
58
|
};
|
|
56
59
|
}
|
|
57
60
|
async read(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-session-reader.js","sourceRoot":"","sources":["../../src/admin/chat-session-reader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,UAAU,GAEX,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAiB;IACpB,EAAE,CAAU;IACZ,UAAU,CAAa;IAI/B,YAAY,EAAW,EAAE,oBAAyC;QAChE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,OAAO,oBAAoB,KAAK,QAAQ;YACxD,CAAC,CAAC,IAAI,UAAU,CAAC,oBAAoB,CAAC;YACtC,CAAC,CAAC,oBAAoB,CAAC;IAC3B,CAAC;IAED,mFAAmF;IACnF,cAAc;QACZ,uEAAuE;QACvE,yDAAyD;QACzD,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,C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ssetStore } from "../state/build-assets.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export function mountAdmin(app, db, config) {
|
|
12
12
|
const sessionLog = new SessionLog(config.sessionsDir);
|
|
13
|
-
|
|
13
|
+
// The third argument is the `executions` join that gives a sandbox session a
|
|
14
|
+
// repo (issue #169) — the jsonl envelopes themselves carry none.
|
|
15
|
+
const sessions = new SessionReader(sessionLog, "sandbox", (id) => db.executions.repoForSessionId(id));
|
|
14
16
|
// Chat is DB-backed: list comes from `executions` grouped by trigger_id
|
|
15
17
|
// (the Slack thread), and message reads target the single jsonl owned by
|
|
16
18
|
// that thread's agent_session_id rather than scanning every file in -app.
|
package/dist/admin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/admin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAI3D;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAS,EAAE,EAAW,EAAE,MAAmB;IACpE,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/admin/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE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E,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAEnH,2EAA2E;IAC3E,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IACjF,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
package/dist/admin/routes.js
CHANGED
|
@@ -19,6 +19,14 @@ import { classifyComment } from "../engine/screen/classifier.js";
|
|
|
19
19
|
import { getWorkflowTriggers, getWorkflowTriggerKinds, } from "../workflows/triggers.js";
|
|
20
20
|
import { getManagedRepos, getInstallationRepoBreakdown, getInstallationRepos, getInstallationReposRefreshedAt, isManagedRepo, } from "../managed-repos.js";
|
|
21
21
|
import { getInstallationDirectory, installationSettingsUrl, } from "../engine/github/installations.js";
|
|
22
|
+
import { TeamVisibilityResolver } from "../engine/github/team-visibility.js";
|
|
23
|
+
/**
|
|
24
|
+
* Most repos a `?repos=` scope may name (issue #169). Past this the client is
|
|
25
|
+
* told to stop filtering rather than have the server build a WHERE clause with
|
|
26
|
+
* thousands of OR branches — and since the scope is declutter, dropping it just
|
|
27
|
+
* shows more.
|
|
28
|
+
*/
|
|
29
|
+
const MAX_REPO_SCOPE = 200;
|
|
22
30
|
import { getRuntimeConfig, getRoutes, getBotName, resolveKubernetesConfig,
|
|
23
31
|
// The redaction rule for every surface that echoes YAML back to the
|
|
24
32
|
// dashboard. IMPORTED, never mirrored: `GET /repos/:owner/:repo/config`
|
|
@@ -424,6 +432,13 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
424
432
|
"explicitly allow any GitHub user. GitHub OAuth is disabled until this is set.");
|
|
425
433
|
}
|
|
426
434
|
const githubAllowAnyUser = config.githubAllowedOrg === "*";
|
|
435
|
+
// Per-repo dashboard visibility (issue #169). Constructed unconditionally —
|
|
436
|
+
// it is inert (and answers the fail-open sentinel) when `teamVisibility` is
|
|
437
|
+
// off or there is no GitHub client, which is what tests and chat-only mode see.
|
|
438
|
+
const teamVisibility = new TeamVisibilityResolver({
|
|
439
|
+
store: db.teams,
|
|
440
|
+
github: config.github ?? null,
|
|
441
|
+
});
|
|
427
442
|
// Auth is required when ANY login method is configured — a password OR a
|
|
428
443
|
// working OAuth provider. Gating on the password alone left the dashboard
|
|
429
444
|
// fully open whenever ADMIN_PASSWORD was cleared, even with OAuth set up.
|
|
@@ -485,6 +500,54 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
485
500
|
}),
|
|
486
501
|
});
|
|
487
502
|
});
|
|
503
|
+
// The managed repos THIS user should see by default, from their GitHub team
|
|
504
|
+
// grants (issue #169).
|
|
505
|
+
//
|
|
506
|
+
// Read `repos: null` as "no filter" — it is the sentinel, and it is what every
|
|
507
|
+
// non-happy path returns: a password/Slack login (no GitHub identity), an
|
|
508
|
+
// `allowedOrg: "*"` deployment, the feature switched off, a team too large to
|
|
509
|
+
// enumerate, or GitHub refusing the query. This is UI declutter, NOT access
|
|
510
|
+
// control: `/workflow-runs`, `/sessions` and `/stats` all keep returning
|
|
511
|
+
// global data and the filtering happens in the browser, so failing open costs
|
|
512
|
+
// nothing but a noisier list.
|
|
513
|
+
//
|
|
514
|
+
// Cheap by design — served from the SQLite cache, with a stale answer returned
|
|
515
|
+
// immediately while it refreshes behind the request. Only a genuine first
|
|
516
|
+
// resolution touches GitHub, and even that is a handful of GraphQL calls
|
|
517
|
+
// scoped to this one person's teams (see engine/github/team-visibility.ts).
|
|
518
|
+
app.get("/me/repos", async (c) => {
|
|
519
|
+
const result = await teamVisibility.visibleRepos(actorFromContext(c));
|
|
520
|
+
return c.json({
|
|
521
|
+
repos: result.repos,
|
|
522
|
+
synced: result.synced,
|
|
523
|
+
reason: result.reason,
|
|
524
|
+
teams: result.teams,
|
|
525
|
+
syncedAt: result.syncedAt,
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
// Force a re-resolution for the CALLER. The fallback for orgs where the
|
|
529
|
+
// `team`/`membership`/`organization` webhooks aren't wired up yet — those
|
|
530
|
+
// events normally invalidate the cache for us.
|
|
531
|
+
//
|
|
532
|
+
// Always self, never an arbitrary `?login=`. The response carries `teams`,
|
|
533
|
+
// which names the GitHub org teams a person belongs to — including secret
|
|
534
|
+
// ones — and the admin dashboard's authenticated population is not the same
|
|
535
|
+
// as "people entitled to enumerate org membership". A password-only session
|
|
536
|
+
// has no GitHub identity at all, so an override param would have let it read
|
|
537
|
+
// any login's teams with nothing to check it against.
|
|
538
|
+
app.post("/me/repos/resync", async (c) => {
|
|
539
|
+
const login = actorFromContext(c);
|
|
540
|
+
if (!login)
|
|
541
|
+
return c.json({ error: "no GitHub identity on this session" }, 400);
|
|
542
|
+
const result = await teamVisibility.resync(login);
|
|
543
|
+
return c.json({
|
|
544
|
+
repos: result.repos,
|
|
545
|
+
synced: result.synced,
|
|
546
|
+
reason: result.reason,
|
|
547
|
+
teams: result.teams,
|
|
548
|
+
syncedAt: result.syncedAt,
|
|
549
|
+
});
|
|
550
|
+
});
|
|
488
551
|
// Forked/overridden assets the deployment overlay supplies — workflows,
|
|
489
552
|
// prompts, skills, agent-context — each tagged as shadowing a built-in or a
|
|
490
553
|
// fresh addition. Powers the Config → Overrides pane. Shares the enumerator
|
|
@@ -1137,6 +1200,19 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1137
1200
|
const since = c.req.query("since") || undefined;
|
|
1138
1201
|
const workflowName = c.req.query("workflow") || undefined;
|
|
1139
1202
|
const repo = c.req.query("repo") || undefined;
|
|
1203
|
+
// Per-repo visibility scope (issue #169) — the caller's allowed repo set,
|
|
1204
|
+
// so the dashboard's panels ask for exactly the rows they show instead of
|
|
1205
|
+
// over-fetching and narrowing in the browser.
|
|
1206
|
+
//
|
|
1207
|
+
// This is a QUERY FILTER, not enforcement: the caller supplies it, omitting
|
|
1208
|
+
// it still returns global data, and it is the plural sibling of the `repo`
|
|
1209
|
+
// param the Repos tab has always used. Capped so a pathological query
|
|
1210
|
+
// string can't build a WHERE clause with thousands of OR branches.
|
|
1211
|
+
const repos = (c.req.query("repos") || "")
|
|
1212
|
+
.split(",")
|
|
1213
|
+
.map((r) => r.trim())
|
|
1214
|
+
.filter(Boolean)
|
|
1215
|
+
.slice(0, MAX_REPO_SCOPE);
|
|
1140
1216
|
const statusParam = c.req.query("status");
|
|
1141
1217
|
const limit = Math.min(Math.max(parseInt(rawLimit ?? "20", 10) || 20, 1), 200);
|
|
1142
1218
|
const offset = Math.max(parseInt(rawOffset ?? "0", 10) || 0, 0);
|
|
@@ -1155,6 +1231,7 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1155
1231
|
sinceIso: since,
|
|
1156
1232
|
workflowName,
|
|
1157
1233
|
repo,
|
|
1234
|
+
repos: repos.length > 0 ? repos : undefined,
|
|
1158
1235
|
statuses,
|
|
1159
1236
|
});
|
|
1160
1237
|
return c.json({ workflowRuns: runs, total });
|
|
@@ -1530,20 +1607,11 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1530
1607
|
const ctx = run.context ?? {};
|
|
1531
1608
|
const ctxOwner = typeof ctx.owner === "string" ? ctx.owner : undefined;
|
|
1532
1609
|
const branch = typeof ctx.branch === "string" ? ctx.branch : undefined;
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
const [maybeOwner, maybeRepo] = repoField.split("/", 2);
|
|
1539
|
-
owner = ctxOwner ?? maybeOwner;
|
|
1540
|
-
repo = maybeRepo;
|
|
1541
|
-
}
|
|
1542
|
-
else {
|
|
1543
|
-
owner = ctxOwner;
|
|
1544
|
-
repo = repoField;
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1610
|
+
// The row IS the pair (issue #279) — `owner` plus a bare `repo`, normalized
|
|
1611
|
+
// by the store on the way in and on the way out. `context.owner` stays as
|
|
1612
|
+
// the fallback for a row whose owner column was never captured.
|
|
1613
|
+
const repo = run.repo;
|
|
1614
|
+
const owner = repo ? run.owner ?? ctxOwner : undefined;
|
|
1547
1615
|
const issueKey = buildAssetIssueKey(run.workflowName, run.issueNumber, run.id);
|
|
1548
1616
|
return { owner, repo, issueKey, branch };
|
|
1549
1617
|
}
|
|
@@ -1846,13 +1914,12 @@ export function createAdminRoutes(db, sessions, chatSessions, config) {
|
|
|
1846
1914
|
const run = db.runs.getRun(approval.workflowRunId);
|
|
1847
1915
|
let artifactRef = null;
|
|
1848
1916
|
if (approval.artifact && run && run.repo) {
|
|
1849
|
-
//
|
|
1850
|
-
//
|
|
1851
|
-
// may store "owner/repo". Handle both: prefer context.owner, else split.
|
|
1917
|
+
// The row is the (owner, BARE repo) pair (issue #279); `context.owner` is
|
|
1918
|
+
// the fallback for a row whose owner column was never captured.
|
|
1852
1919
|
const ctx = run.context ?? {};
|
|
1853
1920
|
const ctxOwner = typeof ctx.owner === "string" ? ctx.owner : undefined;
|
|
1854
|
-
const repo = run.repo
|
|
1855
|
-
const owner =
|
|
1921
|
+
const repo = run.repo;
|
|
1922
|
+
const owner = run.owner ?? ctxOwner ?? "";
|
|
1856
1923
|
if (owner && repo) {
|
|
1857
1924
|
const mode = config.buildAssets ?? "repo";
|
|
1858
1925
|
const issueKey = buildAssetIssueKey(run.workflowName, run.issueNumber, run.id);
|