wicked-crew 0.18.1 → 0.18.3
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/README.md +15 -11
- package/dist/api/chat-proposals.d.ts +10 -2
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +20 -2
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/chat-scope.d.ts +25 -0
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +49 -4
- package/dist/api/chat-scope.js.map +1 -1
- package/dist/api/proposal-onboard.d.ts +147 -0
- package/dist/api/proposal-onboard.d.ts.map +1 -0
- package/dist/api/proposal-onboard.js +390 -0
- package/dist/api/proposal-onboard.js.map +1 -0
- package/dist/api/routes.d.ts +8 -1
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +168 -53
- package/dist/api/routes.js.map +1 -1
- package/dist/api/seat-container-login.d.ts +4 -0
- package/dist/api/seat-container-login.d.ts.map +1 -1
- package/dist/api/seat-container-login.js +51 -5
- package/dist/api/seat-container-login.js.map +1 -1
- package/dist/api/server.d.ts +8 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +49 -2
- package/dist/api/server.js.map +1 -1
- package/dist/core/adapter.d.ts +17 -2
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +19 -4
- package/dist/core/adapter.js.map +1 -1
- package/dist/projects/auto-refresh.d.ts +17 -6
- package/dist/projects/auto-refresh.d.ts.map +1 -1
- package/dist/projects/auto-refresh.js +16 -11
- package/dist/projects/auto-refresh.js.map +1 -1
- package/dist/projects/graph.d.ts +6 -0
- package/dist/projects/graph.d.ts.map +1 -1
- package/dist/projects/graph.js +16 -4
- package/dist/projects/graph.js.map +1 -1
- package/dist/projects/repo-watch-routes.d.ts +16 -0
- package/dist/projects/repo-watch-routes.d.ts.map +1 -0
- package/dist/projects/repo-watch-routes.js +51 -0
- package/dist/projects/repo-watch-routes.js.map +1 -0
- package/dist/projects/repo-watch.d.ts +227 -0
- package/dist/projects/repo-watch.d.ts.map +1 -0
- package/dist/projects/repo-watch.js +851 -0
- package/dist/projects/repo-watch.js.map +1 -0
- package/dist/projects/routes.d.ts +30 -0
- package/dist/projects/routes.d.ts.map +1 -1
- package/dist/projects/routes.js +57 -24
- package/dist/projects/routes.js.map +1 -1
- package/dist/projects/state-home-registry.d.ts.map +1 -1
- package/dist/projects/state-home-registry.js +2 -0
- package/dist/projects/state-home-registry.js.map +1 -1
- package/dist/studio/apps-standalone/fixture.js +3 -3
- package/dist/studio/assets/{KnowledgeGraph-BT5Y-B8b.js → KnowledgeGraph-8Nfz0zPk.js} +1 -1
- package/dist/studio/assets/{index-Bl9m8ldl.js → index-C-0B6Ue3.js} +306 -302
- package/dist/studio/assets/index-Hi4Wevnb.css +32 -0
- package/dist/studio/editors/wicked-apps/editor.json +1 -1
- package/dist/studio/editors/wicked-apps/index.html +1 -1
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +1 -1
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +1 -1
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +1 -1
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/index.html +2 -2
- package/dist/studio/testid-inventory.json +197 -4
- package/endpoint-manifest.json +34 -2
- package/package.json +4 -4
- package/dist/studio/assets/index-B_JwrHVF.css +0 -32
package/dist/api/routes.js
CHANGED
|
@@ -12,7 +12,7 @@ import { promises as fsp } from 'node:fs';
|
|
|
12
12
|
import { basename, isAbsolute, join, relative, resolve } from 'node:path';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
14
|
import { videoPalette } from '../appearance/video-palette.js';
|
|
15
|
-
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, settingsFilePath } from '../core/adapter.js';
|
|
15
|
+
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, settingsFilePath, wickedDir } from '../core/adapter.js';
|
|
16
16
|
import { codeGraphDb, codeGraphErrorStatus, repoFolderMissing, repoFolderMissingBody } from '../core/repoPaths.js';
|
|
17
17
|
import { resolveCursorUnit } from '../core/cursor.js';
|
|
18
18
|
/** Create `dir` (private) when missing and answer it — a read root must exist when a run launches. */
|
|
@@ -79,7 +79,7 @@ import { listInteractiveDocs } from '../interactive/docs-index.js';
|
|
|
79
79
|
import { SearchService, registerSearchRoutes } from './search-routes.js';
|
|
80
80
|
import { TestSetIndex } from '../qe/test-sets.js';
|
|
81
81
|
import { estateExe, parseEstateTotals, readBlastRadiusPages, resolveProjectGraphBinding } from '../projects/graph.js';
|
|
82
|
-
import { registerProjectRoutes } from '../projects/routes.js';
|
|
82
|
+
import { attachRepoToProject, registerProjectRoutes } from '../projects/routes.js';
|
|
83
83
|
import { registerProjectAggregateRoutes } from './project-aggregates.js';
|
|
84
84
|
import { composeLaunch, composePreflight, registerProductRoutes } from './product.js';
|
|
85
85
|
import { buildWorkflowCatalogV2, parseCommand, resolveOption } from '../workflow-catalog/build-v2.js';
|
|
@@ -133,6 +133,7 @@ import { artifactStatus, beneathSupported, buildTurnContext, chatMount, ChatMess
|
|
|
133
133
|
import { createDocInProcess, registerInteractiveProxy } from '../interactive/proxy-routes.js';
|
|
134
134
|
import { CreateLauncher } from '../interactive/proposal-create.js';
|
|
135
135
|
import { ThemeLauncher } from './proposal-theme.js';
|
|
136
|
+
import { CHAT_GIT_PROTOCOLS, OnboardLauncher, probeGitUrl, withoutCredentials } from './proposal-onboard.js';
|
|
136
137
|
import { RefineLauncher } from '../interactive/proposal-refine.js';
|
|
137
138
|
import { lineageSteps, protectedEdits } from '../interactive/protected-edits.js';
|
|
138
139
|
import { buildRunBrief } from './run-brief.js';
|
|
@@ -153,7 +154,7 @@ import { REVIEWS_DIRNAME } from '../interactive/review-ledger.js';
|
|
|
153
154
|
import { MembershipIndex } from '../projects/membership-index.js';
|
|
154
155
|
import { MEMBERSHIP_ATTACHED, membershipAttachedKey } from '../projects/events.js';
|
|
155
156
|
import { resolveLinkedIssues, stripLinkedIssues } from '../core/linked-issues.js';
|
|
156
|
-
import { reRegisterRefusal } from '../projects/repo-guard.js';
|
|
157
|
+
import { mayAttachRepo, reRegisterRefusal } from '../projects/repo-guard.js';
|
|
157
158
|
import { registerTrackerActionRoutes } from '../knowledge/trackers/actions.js';
|
|
158
159
|
import { pmRegistered, readPmIssues } from '../knowledge/trackers/issues.js';
|
|
159
160
|
import { registerTrackerRoutes } from '../knowledge/trackers/routes.js';
|
|
@@ -926,7 +927,7 @@ export const ChatOpenSchema = z.strictObject({
|
|
|
926
927
|
}).optional(),
|
|
927
928
|
requestId: z.string().trim().min(1).max(128).optional(),
|
|
928
929
|
/** (api-types 0.192.0) What the client renders (`['job']`). */
|
|
929
|
-
accepts: z.array(z.
|
|
930
|
+
accepts: z.array(z.enum(['job', 'onboard'])).max(4).optional(),
|
|
930
931
|
}).refine((b) => b.seed === undefined || (b.requestId !== undefined && b.chatId === undefined), {
|
|
931
932
|
path: ['seed'],
|
|
932
933
|
error: 'seed needs requestId and no chatId: the chat id derives from you and the request',
|
|
@@ -1119,10 +1120,49 @@ runtime = {}) {
|
|
|
1119
1120
|
'demo',
|
|
1120
1121
|
];
|
|
1121
1122
|
const chatArtifactFlags = chatArtifactsStub
|
|
1122
|
-
? { context: true, proposals: true, create: true, refine: true, theme: true, demo: true, stub: true, stubOps }
|
|
1123
|
-
: { context: true, proposals: true, create: realCreate, refine: realRefine, theme: true, demo: false };
|
|
1123
|
+
? { context: true, proposals: true, create: true, refine: true, theme: true, demo: true, stub: true, stubOps, onboard: true }
|
|
1124
|
+
: { context: true, proposals: true, create: realCreate, refine: realRefine, theme: true, demo: false, onboard: true };
|
|
1124
1125
|
const proposalLaunchers = new LaunchOnceRegistry();
|
|
1125
1126
|
proposalLaunchers.register('theme', new ThemeLauncher());
|
|
1127
|
+
// crew-0182: what an onboard card is resolved and its Go is checked against (one set of reads for both).
|
|
1128
|
+
const originOf = async (rootPath) => {
|
|
1129
|
+
try {
|
|
1130
|
+
const out = await execCapped('git', ['-C', rootPath, 'remote', 'get-url', 'origin'], { timeout: 5_000 });
|
|
1131
|
+
return out.stdout.trim() || null;
|
|
1132
|
+
}
|
|
1133
|
+
catch {
|
|
1134
|
+
return null;
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
const onboardReads = {
|
|
1138
|
+
repos: () => adapter.listRepos(),
|
|
1139
|
+
projectRepoRefs: async (projectId) => (await adapter.projectMembers(projectId)).filter((m) => m.member_kind === 'crew.repo').map((m) => m.member_ref),
|
|
1140
|
+
checkoutOf: (name) => homeless(wickedDir('repos', name)),
|
|
1141
|
+
occupant: async (name) => {
|
|
1142
|
+
const dir = wickedDir('repos', name);
|
|
1143
|
+
if (!existsSync(join(dir, '.git')))
|
|
1144
|
+
return existsSync(dir) ? '' : null;
|
|
1145
|
+
return (await originOf(dir)) ?? '';
|
|
1146
|
+
},
|
|
1147
|
+
};
|
|
1148
|
+
// Go on an onboard card is `POST /repos {gitUrl, projectId}`'s own body (`registerAndOnboard`, below), its clone held
|
|
1149
|
+
// to https and ssh whatever git's `insteadOf` rewrites say.
|
|
1150
|
+
proposalLaunchers.register('onboard', new OnboardLauncher({
|
|
1151
|
+
...onboardReads,
|
|
1152
|
+
sessions: () => adapter.sessions(),
|
|
1153
|
+
register: (data, ctx) => registerAndOnboard(data, { actor: ctx.actor, runId: ctx.runId, gitProtocols: CHAT_GIT_PROTOCOLS, log: { warn: (o, m) => app.log.warn(o, m) } }),
|
|
1154
|
+
attach: async (projectId, repoId, actor) => {
|
|
1155
|
+
await attachRepoToProject(adapter, projects, { projectId, repoId, actor, attachedBy: 'studio' });
|
|
1156
|
+
},
|
|
1157
|
+
// The onboarding run's filing (as recordOnboardingLaunch files it), idempotent: a Go again after a crash files it.
|
|
1158
|
+
fileRun: async (projectId, runId, actor) => {
|
|
1159
|
+
const { member, created } = await adapter.projectMemberAttach(projectId, 'crew.run', runId, { onboarding: true }, actor.id);
|
|
1160
|
+
projects.index.set(runId, projectId);
|
|
1161
|
+
if (created) {
|
|
1162
|
+
projects.bus?.emit(MEMBERSHIP_ATTACHED, { project_id: projectId, member: { kind: 'crew.run', ref: runId }, actor: actor.id }, membershipAttachedKey(projectId, 'crew.run', runId, member.attached_at));
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
}));
|
|
1126
1166
|
/** (DES-CATALOG-002 §4.6) Job proposals in a chat: on wherever chat proposals are. */
|
|
1127
1167
|
const chatJobProposalsOn = chatArtifactFlags.proposals;
|
|
1128
1168
|
if (chatArtifactsStub) {
|
|
@@ -1879,6 +1919,8 @@ runtime = {}) {
|
|
|
1879
1919
|
vault: adapter.vaultBin != null ? vaultDiagnostics(adapter.vaultBin) : null,
|
|
1880
1920
|
// crew#1147: the repo-checks floor cache's disk usage (cached 60 s); `null` on an addon without it.
|
|
1881
1921
|
floorCache,
|
|
1922
|
+
// crew-0183: the repo watcher's standing and loop numbers; null on a route set without it.
|
|
1923
|
+
repoWatch: runtime.repoWatch?.diagnostics() ?? null,
|
|
1882
1924
|
};
|
|
1883
1925
|
};
|
|
1884
1926
|
app.get(`${V}/diagnostics`, { config: { manifest: { responseType: 'DiagnosticsResponse', statusCodes: [200] } } }, async () => diagnosticsNow());
|
|
@@ -2382,7 +2424,7 @@ runtime = {}) {
|
|
|
2382
2424
|
* the run and names who started it) is always written; with a `projectId` the run joins that
|
|
2383
2425
|
* project. The run is LIVE by then, so a filing failure is named in the answer, never a 4xx. */
|
|
2384
2426
|
const recordOnboardingLaunch = async (req, runId, repoId, opts) => {
|
|
2385
|
-
recordRunLaunched(audit, runTimingIndex,
|
|
2427
|
+
recordRunLaunched(audit, runTimingIndex, req.actor, runId, {
|
|
2386
2428
|
workflow: 'onboarding',
|
|
2387
2429
|
repoRef: repoId,
|
|
2388
2430
|
...(opts.autoCapture === false ? { autoCapture: false } : {}),
|
|
@@ -2393,9 +2435,9 @@ runtime = {}) {
|
|
|
2393
2435
|
if (opts.projectId === undefined)
|
|
2394
2436
|
return undefined;
|
|
2395
2437
|
try {
|
|
2396
|
-
const { member } = await adapter.projectMemberAttach(opts.projectId, 'crew.run', runId, { onboarding: true },
|
|
2438
|
+
const { member } = await adapter.projectMemberAttach(opts.projectId, 'crew.run', runId, { onboarding: true }, req.actor.id);
|
|
2397
2439
|
projects.index.set(runId, opts.projectId);
|
|
2398
|
-
projects.bus?.emit(MEMBERSHIP_ATTACHED, { project_id: opts.projectId, member: { kind: 'crew.run', ref: runId }, actor:
|
|
2440
|
+
projects.bus?.emit(MEMBERSHIP_ATTACHED, { project_id: opts.projectId, member: { kind: 'crew.run', ref: runId }, actor: req.actor.id }, membershipAttachedKey(opts.projectId, 'crew.run', runId, member.attached_at));
|
|
2399
2441
|
return undefined;
|
|
2400
2442
|
}
|
|
2401
2443
|
catch (err) {
|
|
@@ -2434,71 +2476,99 @@ runtime = {}) {
|
|
|
2434
2476
|
* (core has no unregister). A registered repo returns 201 with `onboardRunId: null` and
|
|
2435
2477
|
* `onboardError` on launch failure, so callers can attach it to their project and retry onboarding.
|
|
2436
2478
|
*/
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
// DES-APPS-001 (K2a): `<apps root>/<name>`, `git init` with one empty commit, registered; an empty
|
|
2444
|
-
// tree has nothing to onboard. A taken (or reserved) name is refused with a suggestion.
|
|
2445
|
-
const store = runtime.apps;
|
|
2446
|
-
if (store === undefined)
|
|
2447
|
-
return reply.code(503).send({ code: 'apps_unavailable', error: 'this daemon has no apps root to make a repo in' });
|
|
2448
|
-
const name = parsed.data.name;
|
|
2449
|
-
try {
|
|
2450
|
-
const { repo } = await store.createRepo(name);
|
|
2451
|
-
audit.record('repo.created', actorOf(req), { detail: { repoId: repo.id, name } });
|
|
2452
|
-
return reply.code(201).send({ repo, onboardRunId: null });
|
|
2453
|
-
}
|
|
2454
|
-
catch (err) {
|
|
2455
|
-
if (err instanceof AppStoreError)
|
|
2456
|
-
return reply.code(err.status).send({ code: err.code, error: err.message, ...err.extra });
|
|
2457
|
-
// A registration the engine refused: the repo was removed again, nothing is left.
|
|
2458
|
-
return reply.code(400).send({ error: message(err) });
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2479
|
+
/**
|
|
2480
|
+
* Register (cloning a URL first) and launch onboarding, filing its run and (crew-0182) attaching the repo to
|
|
2481
|
+
* `projectId` through the one attach path ({@link attachRepoToProject}). THE body of `POST /repos`, shared with a chat's
|
|
2482
|
+
* onboarding proposal, so both behave identically. `runId` (internal, a proposal's identity) names the onboarding run.
|
|
2483
|
+
*/
|
|
2484
|
+
const registerAndOnboard = async (data, ctx) => {
|
|
2461
2485
|
const refused = await onboardRefusal();
|
|
2462
2486
|
if (refused !== null)
|
|
2463
|
-
return
|
|
2464
|
-
const { name, gitUrl, projectId, channel, actor, autoCapture } =
|
|
2487
|
+
return { status: refused.status, body: refused.body };
|
|
2488
|
+
const { name, gitUrl, projectId, channel, actor, autoCapture } = data;
|
|
2465
2489
|
// First-run C1: `~/code/my-app` (the field's own example) is expanded; a relative or missing folder is refused in plain words.
|
|
2466
|
-
let rootPath =
|
|
2490
|
+
let rootPath = data.rootPath;
|
|
2467
2491
|
if (rootPath !== undefined && rootPath !== '') {
|
|
2468
2492
|
const read = readRepoPath(rootPath);
|
|
2469
2493
|
if (!read.ok)
|
|
2470
|
-
return
|
|
2494
|
+
return { status: 400, body: { code: read.code, error: read.error } };
|
|
2471
2495
|
rootPath = read.path;
|
|
2472
2496
|
}
|
|
2473
2497
|
// (DES-PM-001 Q-PM2) Re-pointing an existing repo id at another checkout keeps its projects and tracker links.
|
|
2474
|
-
const repointed = await reRegisterRefusal(
|
|
2498
|
+
const repointed = await reRegisterRefusal(ctx.actor, name, rootPath, Boolean(gitUrl), () => adapter.listRepos());
|
|
2475
2499
|
if (repointed !== null)
|
|
2476
|
-
return
|
|
2500
|
+
return { status: repointed.status, body: repointed.body };
|
|
2477
2501
|
let repo;
|
|
2478
2502
|
let runId;
|
|
2479
2503
|
try {
|
|
2480
2504
|
if (gitUrl) {
|
|
2481
2505
|
// Remote: clone to rootPath (if provided) or default ~/.wicked/repos/<name>,
|
|
2482
2506
|
// register, and launch onboarding run.
|
|
2483
|
-
repo =
|
|
2484
|
-
|
|
2507
|
+
repo = ctx.gitProtocols !== undefined
|
|
2508
|
+
? await adapter.cloneAndRegister(name, gitUrl, rootPath, { allowProtocols: ctx.gitProtocols })
|
|
2509
|
+
: await adapter.cloneAndRegister(name, gitUrl, rootPath);
|
|
2485
2510
|
}
|
|
2486
2511
|
else {
|
|
2487
2512
|
// Local: register then launch onboarding run.
|
|
2488
2513
|
repo = await adapter.registerRepo(name, rootPath);
|
|
2489
|
-
runId = await adapter.launchOnboardingRun(repo.id, name);
|
|
2490
2514
|
}
|
|
2515
|
+
runId = ctx.runId !== undefined ? await adapter.launchOnboardingRun(repo.id, name, ctx.runId) : await adapter.launchOnboardingRun(repo.id, name);
|
|
2491
2516
|
}
|
|
2492
2517
|
catch (err) {
|
|
2493
2518
|
if (repo === undefined)
|
|
2494
|
-
return
|
|
2495
|
-
|
|
2496
|
-
// No run exists to record or file
|
|
2519
|
+
return { status: 400, body: registerFailure(message(err), gitUrl ? undefined : rootPath) };
|
|
2520
|
+
ctx.log.warn({ repoId: repo.id }, `repo registered but onboarding launch failed: ${message(err)}`);
|
|
2521
|
+
// No run exists to record or file (crew#1019); the repo still joins its project.
|
|
2497
2522
|
const failure = onboardFailure(message(err));
|
|
2498
|
-
|
|
2523
|
+
const attach = await attachToProject(repo.id, projectId, ctx.actor, channel);
|
|
2524
|
+
return { status: 201, body: { repo, onboardRunId: null, onboardError: failure.error, ...(failure.code !== undefined ? { onboardErrorCode: failure.code, missingTool: failure.tool } : {}), ...attach } };
|
|
2499
2525
|
}
|
|
2500
|
-
const projectAttachError = await recordOnboardingLaunch(
|
|
2501
|
-
|
|
2526
|
+
const projectAttachError = await recordOnboardingLaunch(ctx, runId, repo.id, { projectId, channel, actor, autoCapture });
|
|
2527
|
+
const attach = await attachToProject(repo.id, projectId, ctx.actor, channel);
|
|
2528
|
+
const errors = [...new Set([projectAttachError, attach.projectAttachError].filter((e) => e !== undefined))];
|
|
2529
|
+
return { status: 201, body: { repo, onboardRunId: runId, ...(attach.projectAttached === true ? { projectAttached: true } : {}), ...(errors.length > 0 ? { projectAttachError: errors.join('; ') } : {}) } };
|
|
2530
|
+
};
|
|
2531
|
+
/** crew-0182: the repo joins `projectId` (`crew.repo`) the one way every surface does; a refusal is named, never thrown. */
|
|
2532
|
+
const attachToProject = async (repoId, projectId, actor, channel) => {
|
|
2533
|
+
// A repo joins a project only by a person (DES-PM-001 Q-PM2): an agent's projectId files the run, as before.
|
|
2534
|
+
if (projectId === undefined || projectId === DEFAULT_PROJECT_ID || !mayAttachRepo(actor))
|
|
2535
|
+
return {};
|
|
2536
|
+
try {
|
|
2537
|
+
await attachRepoToProject(adapter, projects, { projectId, repoId, actor, ...(channel !== undefined ? { attachedBy: channel } : {}) });
|
|
2538
|
+
return { projectAttached: true };
|
|
2539
|
+
}
|
|
2540
|
+
catch (err) {
|
|
2541
|
+
return { projectAttachError: message(err) };
|
|
2542
|
+
}
|
|
2543
|
+
};
|
|
2544
|
+
app.post(`${V}/repos`, { config: { manifest: { requestType: 'RegisterRepoBody', statusCodes: [201, 400, 409, 422, 503] } } }, async (req, reply) => {
|
|
2545
|
+
const parsed = RegisterRepoSchema.safeParse(req.body);
|
|
2546
|
+
if (!parsed.success) {
|
|
2547
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
2548
|
+
}
|
|
2549
|
+
if (parsed.data.create === true) {
|
|
2550
|
+
// DES-APPS-001 (K2a): `<apps root>/<name>`, `git init` with one empty commit, registered; an empty
|
|
2551
|
+
// tree has nothing to onboard. A taken (or reserved) name is refused with a suggestion.
|
|
2552
|
+
const store = runtime.apps;
|
|
2553
|
+
if (store === undefined)
|
|
2554
|
+
return reply.code(503).send({ code: 'apps_unavailable', error: 'this daemon has no apps root to make a repo in' });
|
|
2555
|
+
const name = parsed.data.name;
|
|
2556
|
+
try {
|
|
2557
|
+
const { repo } = await store.createRepo(name);
|
|
2558
|
+
audit.record('repo.created', actorOf(req), { detail: { repoId: repo.id, name } });
|
|
2559
|
+
// crew-0182: a projectId puts the new repo in the project, as for every other registration (no onboarding).
|
|
2560
|
+
const attach = await attachToProject(repo.id, parsed.data.projectId, actorOf(req), parsed.data.channel);
|
|
2561
|
+
return reply.code(201).send({ repo, onboardRunId: null, ...attach });
|
|
2562
|
+
}
|
|
2563
|
+
catch (err) {
|
|
2564
|
+
if (err instanceof AppStoreError)
|
|
2565
|
+
return reply.code(err.status).send({ code: err.code, error: err.message, ...err.extra });
|
|
2566
|
+
// A registration the engine refused: the repo was removed again, nothing is left.
|
|
2567
|
+
return reply.code(400).send({ error: message(err) });
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
const out = await registerAndOnboard(parsed.data, { actor: actorOf(req), log: req.log });
|
|
2571
|
+
return reply.code(out.status).send(out.body);
|
|
2502
2572
|
});
|
|
2503
2573
|
// Return the onboarding run id for a repo (so the UI can navigate to it).
|
|
2504
2574
|
app.get(`${V}/repos/:id/onboard`, async (req, reply) => {
|
|
@@ -2529,7 +2599,7 @@ runtime = {}) {
|
|
|
2529
2599
|
const failure = onboardFailure(message(err));
|
|
2530
2600
|
return reply.code(400).send({ error: failure.error, ...(failure.code !== undefined ? { code: failure.code, missingTool: failure.tool } : {}) });
|
|
2531
2601
|
}
|
|
2532
|
-
const projectAttachError = await recordOnboardingLaunch(req, runId, repo.id, body.data);
|
|
2602
|
+
const projectAttachError = await recordOnboardingLaunch({ actor: actorOf(req), log: req.log }, runId, repo.id, body.data);
|
|
2533
2603
|
return reply.code(201).send({ runId, ...(projectAttachError !== undefined ? { projectAttachError } : {}) });
|
|
2534
2604
|
});
|
|
2535
2605
|
// crew#825: what a workflow launch WOULD append — the same reading `POST /runs` does, before Send,
|
|
@@ -4241,6 +4311,30 @@ runtime = {}) {
|
|
|
4241
4311
|
});
|
|
4242
4312
|
/** (DES-CATALOG-002 §4.6) Chats whose client renders job proposals (`accepts: ['job']`), by its newest declaration. */
|
|
4243
4313
|
const chatAccepts = new Map();
|
|
4314
|
+
/** (crew-0182) Chats whose client draws onboard cards (`accepts: ['onboard']`), by its newest declaration. */
|
|
4315
|
+
const chatAcceptsOnboard = new Map();
|
|
4316
|
+
/** (crew-0182) What a chat seat is told exists here: every project with its repositories, every registered repository. */
|
|
4317
|
+
const readDaemonGrounding = async (chatId, accepts) => {
|
|
4318
|
+
try {
|
|
4319
|
+
// A read that fails names nothing (never "none yet"): the whole section is left out.
|
|
4320
|
+
const [projectRows, repoRows] = await Promise.all([adapter.projectList(), adapter.listRepos()]);
|
|
4321
|
+
const nameOf = new Map(repoRows.map((r) => [r.id, r.name]));
|
|
4322
|
+
const live = projectRows.filter((p) => p.id !== DEFAULT_PROJECT_ID && p.status !== 'archived');
|
|
4323
|
+
// Members are read for the projects the statement shows (daemonGroundingLines' cap); the rest are counted.
|
|
4324
|
+
const projectsOut = await Promise.all(live.map(async (p, i) => ({
|
|
4325
|
+
id: p.id,
|
|
4326
|
+
name: p.name,
|
|
4327
|
+
repos: i >= 40 ? [] : (await adapter.projectMembers(p.id)).filter((m) => m.member_kind === 'crew.repo').map((m) => nameOf.get(m.member_ref) ?? m.member_ref),
|
|
4328
|
+
})));
|
|
4329
|
+
const onboard = chatArtifactFlags.onboard === true && (accepts !== undefined ? accepts.includes('onboard') : chatAcceptsOnboard.get(chatId) === true);
|
|
4330
|
+
const text = (v, or) => (typeof v === 'string' && v !== '' ? v : or);
|
|
4331
|
+
// A registered origin carrying a token is never handed to a seat (crew-0182 review).
|
|
4332
|
+
return { projects: projectsOut, repos: repoRows.map((r) => ({ id: r.id, name: text(r.name, r.id), ...(typeof r.git_url === 'string' ? { gitUrl: withoutCredentials(r.git_url) } : {}) })), onboard };
|
|
4333
|
+
}
|
|
4334
|
+
catch {
|
|
4335
|
+
return undefined;
|
|
4336
|
+
}
|
|
4337
|
+
};
|
|
4244
4338
|
/** A seed as the person route's body (one spelling, so its request digest is the same on every retry). */
|
|
4245
4339
|
const seedBody = (seed, requestId) => ({
|
|
4246
4340
|
card: seed.card,
|
|
@@ -4461,6 +4555,7 @@ runtime = {}) {
|
|
|
4461
4555
|
// DES-CATALOG-002 §4.6: this open owns the id now: its declaration is the chat's (an omitted one is "no job cards").
|
|
4462
4556
|
// A refused open (409 above) never touched the live chat's (codex r3).
|
|
4463
4557
|
chatAccepts.set(chatId, openAccepts);
|
|
4558
|
+
chatAcceptsOnboard.set(chatId, b.accepts?.includes('onboard') === true);
|
|
4464
4559
|
// DC-S7: the in-force rules the statement lists; recorded as "told" only once the open succeeds.
|
|
4465
4560
|
let inForceAtOpen = [];
|
|
4466
4561
|
// Everything below either ends in `chatScopes.set(chatId, …, token)` or releases the reservation.
|
|
@@ -4729,7 +4824,7 @@ runtime = {}) {
|
|
|
4729
4824
|
/** (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §5.1) What studio shows beside the message. */
|
|
4730
4825
|
context: ChatMessageContextSchema.optional(),
|
|
4731
4826
|
/** (api-types 0.192.0, DES-CATALOG-002 §4.6) What the client renders (`['job']`): the newest declaration wins. */
|
|
4732
|
-
accepts: z.array(z.
|
|
4827
|
+
accepts: z.array(z.enum(['job', 'onboard'])).max(4).optional(),
|
|
4733
4828
|
});
|
|
4734
4829
|
// DES-CHAT-ARTIFACTS-001 §5.1 (A1): what a turn's block reads — the docs roots, the decorated runs (project,
|
|
4735
4830
|
// document and chat ids), unit outputs and the acceptance line. One set of deps, so the block and the run pages
|
|
@@ -4921,6 +5016,21 @@ runtime = {}) {
|
|
|
4921
5016
|
return new Set((await adapter.listPresets(projectId !== null && projectId !== DEFAULT_PROJECT_ID ? projectId : undefined)).map((p) => p.name));
|
|
4922
5017
|
},
|
|
4923
5018
|
acceptsJobs: (chatId) => chatAccepts.get(chatId) === true,
|
|
5019
|
+
acceptsOnboard: (chatId) => chatAcceptsOnboard.get(chatId) === true,
|
|
5020
|
+
onboard: {
|
|
5021
|
+
...onboardReads,
|
|
5022
|
+
projects: async () => (await adapter.projectList()).filter((p) => p.id !== DEFAULT_PROJECT_ID && p.status !== 'archived').map((p) => ({ id: p.id, name: p.name })),
|
|
5023
|
+
originOf,
|
|
5024
|
+
probe: (url) => probeGitUrl(url),
|
|
5025
|
+
// POST /repos's own intake refusal (no garden, an old one, the state home): the card says it before anyone presses.
|
|
5026
|
+
onboardRefusal: async () => {
|
|
5027
|
+
const refused = await onboardRefusal();
|
|
5028
|
+
if (refused === null)
|
|
5029
|
+
return null;
|
|
5030
|
+
const why = refused.body.error;
|
|
5031
|
+
return `this daemon can't onboard a repository now: ${typeof why === 'string' && why !== '' ? why : `refused (${refused.status})`}`;
|
|
5032
|
+
},
|
|
5033
|
+
},
|
|
4924
5034
|
served: (projectId) => servedFor(shapeReads, projectId ?? undefined),
|
|
4925
5035
|
turnLive: (chatId, turnId) => chatTurns.turnsOf(chatId).some((t) => t.turnId === turnId),
|
|
4926
5036
|
broadcast: (frame) => runtime.broadcast?.(frame),
|
|
@@ -5028,8 +5138,10 @@ runtime = {}) {
|
|
|
5028
5138
|
try {
|
|
5029
5139
|
// DES-CATALOG-002 §4.6: the client's declaration takes effect with an ACCEPTED message only (a refused one, a
|
|
5030
5140
|
// second tab's 409, never changes how a turn in flight is read; codex r2 on Lane D).
|
|
5031
|
-
if (parsed.data.accepts !== undefined)
|
|
5141
|
+
if (parsed.data.accepts !== undefined) {
|
|
5032
5142
|
chatAccepts.set(id, parsed.data.accepts.includes('job'));
|
|
5143
|
+
chatAcceptsOnboard.set(id, parsed.data.accepts.includes('onboard'));
|
|
5144
|
+
}
|
|
5033
5145
|
after();
|
|
5034
5146
|
if (preface !== null)
|
|
5035
5147
|
chatTranscripts?.appendSystem(id, turnId, preface);
|
|
@@ -5141,7 +5253,8 @@ runtime = {}) {
|
|
|
5141
5253
|
const pending = await considerations.pendingPreface(id, { inForce: rules });
|
|
5142
5254
|
// A7: a seat is told it can propose a studio theme only when this message carried the tab's appearance (a client
|
|
5143
5255
|
// that can preview and apply one sends it).
|
|
5144
|
-
|
|
5256
|
+
// crew-0182: this message's own onboard declaration (the chat's stored one changes once the message is accepted).
|
|
5257
|
+
const themeClient = { appearance: msgContext?.appearance !== undefined, onboard: parsed.data.accepts !== undefined ? parsed.data.accepts.includes('onboard') : chatAcceptsOnboard.get(id) === true };
|
|
5145
5258
|
// DES-CATALOG-002 §2.3, §4.6: the per-message job lines (the chat catalog digest, the open proposal, the held plan),
|
|
5146
5259
|
// read here, before the last check (no await after it). Never in an analysis.
|
|
5147
5260
|
// The declaration this message's instructions are written for: its own, else the chat's (applied to the chat only
|
|
@@ -5177,6 +5290,8 @@ runtime = {}) {
|
|
|
5177
5290
|
const requirementsBuilt = scope !== undefined
|
|
5178
5291
|
? await buildRequirementsMaps(scope, { listRepos: () => adapter.listRepos(), reader: adapter }).catch(() => [])
|
|
5179
5292
|
: [];
|
|
5293
|
+
// crew-0182: the daemon's projects and repositories for this message (a failed read names none; never fails the turn).
|
|
5294
|
+
const daemonGrounding = path.workflow === undefined ? await readDaemonGrounding(id, parsed.data.accepts) : undefined;
|
|
5180
5295
|
// The last await before delivery may also have closed/reopened the chat. From this check
|
|
5181
5296
|
// through publication and the send there is no await, so no executing turn's files change.
|
|
5182
5297
|
if (askPaths.get(id)?.generation !== lease || chatScopes.get(id) !== storedScope) {
|
|
@@ -5240,7 +5355,7 @@ runtime = {}) {
|
|
|
5240
5355
|
// A2: the per-message digest of what the chat can make now (advertised operations only).
|
|
5241
5356
|
// crew#1412: written after the last await and the generation check; a map that cannot be written says so.
|
|
5242
5357
|
const requirementsMaps = scope !== undefined ? publishRequirementsMaps(scope.cwd, requirementsBuilt) : [];
|
|
5243
|
-
const statementOpts = { analysis: path.workflow !== undefined, make: chatProposals.digest(id, turnAccepts, themeClient), requirementsMaps, ...voiceFor(scope?.projectId) };
|
|
5358
|
+
const statementOpts = { analysis: path.workflow !== undefined, make: chatProposals.digest(id, turnAccepts, themeClient), requirementsMaps, ...voiceFor(scope?.projectId), ...(daemonGrounding !== undefined ? { daemon: daemonGrounding } : {}) };
|
|
5244
5359
|
const projectId = scope?.projectId;
|
|
5245
5360
|
if (path.runId === undefined) {
|
|
5246
5361
|
const stepId = 'answer-1';
|