wicked-crew 0.18.0 → 0.18.2
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 +4 -1
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +166 -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.map +1 -1
- package/dist/api/server.js +2 -0
- package/dist/api/server.js.map +1 -1
- package/dist/api/system-snapshot.d.ts +4 -0
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +12 -1
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/core/adapter.d.ts +6 -2
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +8 -4
- package/dist/core/adapter.js.map +1 -1
- 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/skills/plugin-source.d.ts +4 -0
- package/dist/skills/plugin-source.d.ts.map +1 -1
- package/dist/skills/plugin-source.js +4 -0
- package/dist/skills/plugin-source.js.map +1 -1
- package/dist/skills/runtime.d.ts +47 -0
- package/dist/skills/runtime.d.ts.map +1 -1
- package/dist/skills/runtime.js +95 -7
- package/dist/skills/runtime.js.map +1 -1
- package/dist/skills/store.d.ts +2 -0
- package/dist/skills/store.d.ts.map +1 -1
- package/dist/skills/store.js +4 -0
- package/dist/skills/store.js.map +1 -1
- package/dist/studio/apps-standalone/fixture.js +3 -3
- package/dist/studio/assets/{KnowledgeGraph-AtkRlS3c.js → KnowledgeGraph-D05VIXiQ.js} +1 -1
- package/dist/studio/assets/index-BPBBSo15.css +32 -0
- package/dist/studio/assets/{index-DU_8o4uq.js → index-CUudUAZ_.js} +299 -299
- 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 +118 -4
- package/endpoint-manifest.json +2 -2
- package/package.json +3 -3
- package/dist/studio/assets/index-CdbCAs7s.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) {
|
|
@@ -2382,7 +2422,7 @@ runtime = {}) {
|
|
|
2382
2422
|
* the run and names who started it) is always written; with a `projectId` the run joins that
|
|
2383
2423
|
* project. The run is LIVE by then, so a filing failure is named in the answer, never a 4xx. */
|
|
2384
2424
|
const recordOnboardingLaunch = async (req, runId, repoId, opts) => {
|
|
2385
|
-
recordRunLaunched(audit, runTimingIndex,
|
|
2425
|
+
recordRunLaunched(audit, runTimingIndex, req.actor, runId, {
|
|
2386
2426
|
workflow: 'onboarding',
|
|
2387
2427
|
repoRef: repoId,
|
|
2388
2428
|
...(opts.autoCapture === false ? { autoCapture: false } : {}),
|
|
@@ -2393,9 +2433,9 @@ runtime = {}) {
|
|
|
2393
2433
|
if (opts.projectId === undefined)
|
|
2394
2434
|
return undefined;
|
|
2395
2435
|
try {
|
|
2396
|
-
const { member } = await adapter.projectMemberAttach(opts.projectId, 'crew.run', runId, { onboarding: true },
|
|
2436
|
+
const { member } = await adapter.projectMemberAttach(opts.projectId, 'crew.run', runId, { onboarding: true }, req.actor.id);
|
|
2397
2437
|
projects.index.set(runId, opts.projectId);
|
|
2398
|
-
projects.bus?.emit(MEMBERSHIP_ATTACHED, { project_id: opts.projectId, member: { kind: 'crew.run', ref: runId }, actor:
|
|
2438
|
+
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
2439
|
return undefined;
|
|
2400
2440
|
}
|
|
2401
2441
|
catch (err) {
|
|
@@ -2434,71 +2474,99 @@ runtime = {}) {
|
|
|
2434
2474
|
* (core has no unregister). A registered repo returns 201 with `onboardRunId: null` and
|
|
2435
2475
|
* `onboardError` on launch failure, so callers can attach it to their project and retry onboarding.
|
|
2436
2476
|
*/
|
|
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
|
-
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Register (cloning a URL first) and launch onboarding, filing its run and (crew-0182) attaching the repo to
|
|
2479
|
+
* `projectId` through the one attach path ({@link attachRepoToProject}). THE body of `POST /repos`, shared with a chat's
|
|
2480
|
+
* onboarding proposal, so both behave identically. `runId` (internal, a proposal's identity) names the onboarding run.
|
|
2481
|
+
*/
|
|
2482
|
+
const registerAndOnboard = async (data, ctx) => {
|
|
2461
2483
|
const refused = await onboardRefusal();
|
|
2462
2484
|
if (refused !== null)
|
|
2463
|
-
return
|
|
2464
|
-
const { name, gitUrl, projectId, channel, actor, autoCapture } =
|
|
2485
|
+
return { status: refused.status, body: refused.body };
|
|
2486
|
+
const { name, gitUrl, projectId, channel, actor, autoCapture } = data;
|
|
2465
2487
|
// 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 =
|
|
2488
|
+
let rootPath = data.rootPath;
|
|
2467
2489
|
if (rootPath !== undefined && rootPath !== '') {
|
|
2468
2490
|
const read = readRepoPath(rootPath);
|
|
2469
2491
|
if (!read.ok)
|
|
2470
|
-
return
|
|
2492
|
+
return { status: 400, body: { code: read.code, error: read.error } };
|
|
2471
2493
|
rootPath = read.path;
|
|
2472
2494
|
}
|
|
2473
2495
|
// (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(
|
|
2496
|
+
const repointed = await reRegisterRefusal(ctx.actor, name, rootPath, Boolean(gitUrl), () => adapter.listRepos());
|
|
2475
2497
|
if (repointed !== null)
|
|
2476
|
-
return
|
|
2498
|
+
return { status: repointed.status, body: repointed.body };
|
|
2477
2499
|
let repo;
|
|
2478
2500
|
let runId;
|
|
2479
2501
|
try {
|
|
2480
2502
|
if (gitUrl) {
|
|
2481
2503
|
// Remote: clone to rootPath (if provided) or default ~/.wicked/repos/<name>,
|
|
2482
2504
|
// register, and launch onboarding run.
|
|
2483
|
-
repo =
|
|
2484
|
-
|
|
2505
|
+
repo = ctx.gitProtocols !== undefined
|
|
2506
|
+
? await adapter.cloneAndRegister(name, gitUrl, rootPath, { allowProtocols: ctx.gitProtocols })
|
|
2507
|
+
: await adapter.cloneAndRegister(name, gitUrl, rootPath);
|
|
2485
2508
|
}
|
|
2486
2509
|
else {
|
|
2487
2510
|
// Local: register then launch onboarding run.
|
|
2488
2511
|
repo = await adapter.registerRepo(name, rootPath);
|
|
2489
|
-
runId = await adapter.launchOnboardingRun(repo.id, name);
|
|
2490
2512
|
}
|
|
2513
|
+
runId = ctx.runId !== undefined ? await adapter.launchOnboardingRun(repo.id, name, ctx.runId) : await adapter.launchOnboardingRun(repo.id, name);
|
|
2491
2514
|
}
|
|
2492
2515
|
catch (err) {
|
|
2493
2516
|
if (repo === undefined)
|
|
2494
|
-
return
|
|
2495
|
-
|
|
2496
|
-
// No run exists to record or file
|
|
2517
|
+
return { status: 400, body: registerFailure(message(err), gitUrl ? undefined : rootPath) };
|
|
2518
|
+
ctx.log.warn({ repoId: repo.id }, `repo registered but onboarding launch failed: ${message(err)}`);
|
|
2519
|
+
// No run exists to record or file (crew#1019); the repo still joins its project.
|
|
2497
2520
|
const failure = onboardFailure(message(err));
|
|
2498
|
-
|
|
2521
|
+
const attach = await attachToProject(repo.id, projectId, ctx.actor, channel);
|
|
2522
|
+
return { status: 201, body: { repo, onboardRunId: null, onboardError: failure.error, ...(failure.code !== undefined ? { onboardErrorCode: failure.code, missingTool: failure.tool } : {}), ...attach } };
|
|
2499
2523
|
}
|
|
2500
|
-
const projectAttachError = await recordOnboardingLaunch(
|
|
2501
|
-
|
|
2524
|
+
const projectAttachError = await recordOnboardingLaunch(ctx, runId, repo.id, { projectId, channel, actor, autoCapture });
|
|
2525
|
+
const attach = await attachToProject(repo.id, projectId, ctx.actor, channel);
|
|
2526
|
+
const errors = [...new Set([projectAttachError, attach.projectAttachError].filter((e) => e !== undefined))];
|
|
2527
|
+
return { status: 201, body: { repo, onboardRunId: runId, ...(attach.projectAttached === true ? { projectAttached: true } : {}), ...(errors.length > 0 ? { projectAttachError: errors.join('; ') } : {}) } };
|
|
2528
|
+
};
|
|
2529
|
+
/** crew-0182: the repo joins `projectId` (`crew.repo`) the one way every surface does; a refusal is named, never thrown. */
|
|
2530
|
+
const attachToProject = async (repoId, projectId, actor, channel) => {
|
|
2531
|
+
// A repo joins a project only by a person (DES-PM-001 Q-PM2): an agent's projectId files the run, as before.
|
|
2532
|
+
if (projectId === undefined || projectId === DEFAULT_PROJECT_ID || !mayAttachRepo(actor))
|
|
2533
|
+
return {};
|
|
2534
|
+
try {
|
|
2535
|
+
await attachRepoToProject(adapter, projects, { projectId, repoId, actor, ...(channel !== undefined ? { attachedBy: channel } : {}) });
|
|
2536
|
+
return { projectAttached: true };
|
|
2537
|
+
}
|
|
2538
|
+
catch (err) {
|
|
2539
|
+
return { projectAttachError: message(err) };
|
|
2540
|
+
}
|
|
2541
|
+
};
|
|
2542
|
+
app.post(`${V}/repos`, { config: { manifest: { requestType: 'RegisterRepoBody', statusCodes: [201, 400, 409, 422, 503] } } }, async (req, reply) => {
|
|
2543
|
+
const parsed = RegisterRepoSchema.safeParse(req.body);
|
|
2544
|
+
if (!parsed.success) {
|
|
2545
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
2546
|
+
}
|
|
2547
|
+
if (parsed.data.create === true) {
|
|
2548
|
+
// DES-APPS-001 (K2a): `<apps root>/<name>`, `git init` with one empty commit, registered; an empty
|
|
2549
|
+
// tree has nothing to onboard. A taken (or reserved) name is refused with a suggestion.
|
|
2550
|
+
const store = runtime.apps;
|
|
2551
|
+
if (store === undefined)
|
|
2552
|
+
return reply.code(503).send({ code: 'apps_unavailable', error: 'this daemon has no apps root to make a repo in' });
|
|
2553
|
+
const name = parsed.data.name;
|
|
2554
|
+
try {
|
|
2555
|
+
const { repo } = await store.createRepo(name);
|
|
2556
|
+
audit.record('repo.created', actorOf(req), { detail: { repoId: repo.id, name } });
|
|
2557
|
+
// crew-0182: a projectId puts the new repo in the project, as for every other registration (no onboarding).
|
|
2558
|
+
const attach = await attachToProject(repo.id, parsed.data.projectId, actorOf(req), parsed.data.channel);
|
|
2559
|
+
return reply.code(201).send({ repo, onboardRunId: null, ...attach });
|
|
2560
|
+
}
|
|
2561
|
+
catch (err) {
|
|
2562
|
+
if (err instanceof AppStoreError)
|
|
2563
|
+
return reply.code(err.status).send({ code: err.code, error: err.message, ...err.extra });
|
|
2564
|
+
// A registration the engine refused: the repo was removed again, nothing is left.
|
|
2565
|
+
return reply.code(400).send({ error: message(err) });
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
const out = await registerAndOnboard(parsed.data, { actor: actorOf(req), log: req.log });
|
|
2569
|
+
return reply.code(out.status).send(out.body);
|
|
2502
2570
|
});
|
|
2503
2571
|
// Return the onboarding run id for a repo (so the UI can navigate to it).
|
|
2504
2572
|
app.get(`${V}/repos/:id/onboard`, async (req, reply) => {
|
|
@@ -2529,7 +2597,7 @@ runtime = {}) {
|
|
|
2529
2597
|
const failure = onboardFailure(message(err));
|
|
2530
2598
|
return reply.code(400).send({ error: failure.error, ...(failure.code !== undefined ? { code: failure.code, missingTool: failure.tool } : {}) });
|
|
2531
2599
|
}
|
|
2532
|
-
const projectAttachError = await recordOnboardingLaunch(req, runId, repo.id, body.data);
|
|
2600
|
+
const projectAttachError = await recordOnboardingLaunch({ actor: actorOf(req), log: req.log }, runId, repo.id, body.data);
|
|
2533
2601
|
return reply.code(201).send({ runId, ...(projectAttachError !== undefined ? { projectAttachError } : {}) });
|
|
2534
2602
|
});
|
|
2535
2603
|
// crew#825: what a workflow launch WOULD append — the same reading `POST /runs` does, before Send,
|
|
@@ -4241,6 +4309,30 @@ runtime = {}) {
|
|
|
4241
4309
|
});
|
|
4242
4310
|
/** (DES-CATALOG-002 §4.6) Chats whose client renders job proposals (`accepts: ['job']`), by its newest declaration. */
|
|
4243
4311
|
const chatAccepts = new Map();
|
|
4312
|
+
/** (crew-0182) Chats whose client draws onboard cards (`accepts: ['onboard']`), by its newest declaration. */
|
|
4313
|
+
const chatAcceptsOnboard = new Map();
|
|
4314
|
+
/** (crew-0182) What a chat seat is told exists here: every project with its repositories, every registered repository. */
|
|
4315
|
+
const readDaemonGrounding = async (chatId, accepts) => {
|
|
4316
|
+
try {
|
|
4317
|
+
// A read that fails names nothing (never "none yet"): the whole section is left out.
|
|
4318
|
+
const [projectRows, repoRows] = await Promise.all([adapter.projectList(), adapter.listRepos()]);
|
|
4319
|
+
const nameOf = new Map(repoRows.map((r) => [r.id, r.name]));
|
|
4320
|
+
const live = projectRows.filter((p) => p.id !== DEFAULT_PROJECT_ID && p.status !== 'archived');
|
|
4321
|
+
// Members are read for the projects the statement shows (daemonGroundingLines' cap); the rest are counted.
|
|
4322
|
+
const projectsOut = await Promise.all(live.map(async (p, i) => ({
|
|
4323
|
+
id: p.id,
|
|
4324
|
+
name: p.name,
|
|
4325
|
+
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),
|
|
4326
|
+
})));
|
|
4327
|
+
const onboard = chatArtifactFlags.onboard === true && (accepts !== undefined ? accepts.includes('onboard') : chatAcceptsOnboard.get(chatId) === true);
|
|
4328
|
+
const text = (v, or) => (typeof v === 'string' && v !== '' ? v : or);
|
|
4329
|
+
// A registered origin carrying a token is never handed to a seat (crew-0182 review).
|
|
4330
|
+
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 };
|
|
4331
|
+
}
|
|
4332
|
+
catch {
|
|
4333
|
+
return undefined;
|
|
4334
|
+
}
|
|
4335
|
+
};
|
|
4244
4336
|
/** A seed as the person route's body (one spelling, so its request digest is the same on every retry). */
|
|
4245
4337
|
const seedBody = (seed, requestId) => ({
|
|
4246
4338
|
card: seed.card,
|
|
@@ -4461,6 +4553,7 @@ runtime = {}) {
|
|
|
4461
4553
|
// 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
4554
|
// A refused open (409 above) never touched the live chat's (codex r3).
|
|
4463
4555
|
chatAccepts.set(chatId, openAccepts);
|
|
4556
|
+
chatAcceptsOnboard.set(chatId, b.accepts?.includes('onboard') === true);
|
|
4464
4557
|
// DC-S7: the in-force rules the statement lists; recorded as "told" only once the open succeeds.
|
|
4465
4558
|
let inForceAtOpen = [];
|
|
4466
4559
|
// Everything below either ends in `chatScopes.set(chatId, …, token)` or releases the reservation.
|
|
@@ -4729,7 +4822,7 @@ runtime = {}) {
|
|
|
4729
4822
|
/** (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §5.1) What studio shows beside the message. */
|
|
4730
4823
|
context: ChatMessageContextSchema.optional(),
|
|
4731
4824
|
/** (api-types 0.192.0, DES-CATALOG-002 §4.6) What the client renders (`['job']`): the newest declaration wins. */
|
|
4732
|
-
accepts: z.array(z.
|
|
4825
|
+
accepts: z.array(z.enum(['job', 'onboard'])).max(4).optional(),
|
|
4733
4826
|
});
|
|
4734
4827
|
// DES-CHAT-ARTIFACTS-001 §5.1 (A1): what a turn's block reads — the docs roots, the decorated runs (project,
|
|
4735
4828
|
// document and chat ids), unit outputs and the acceptance line. One set of deps, so the block and the run pages
|
|
@@ -4921,6 +5014,21 @@ runtime = {}) {
|
|
|
4921
5014
|
return new Set((await adapter.listPresets(projectId !== null && projectId !== DEFAULT_PROJECT_ID ? projectId : undefined)).map((p) => p.name));
|
|
4922
5015
|
},
|
|
4923
5016
|
acceptsJobs: (chatId) => chatAccepts.get(chatId) === true,
|
|
5017
|
+
acceptsOnboard: (chatId) => chatAcceptsOnboard.get(chatId) === true,
|
|
5018
|
+
onboard: {
|
|
5019
|
+
...onboardReads,
|
|
5020
|
+
projects: async () => (await adapter.projectList()).filter((p) => p.id !== DEFAULT_PROJECT_ID && p.status !== 'archived').map((p) => ({ id: p.id, name: p.name })),
|
|
5021
|
+
originOf,
|
|
5022
|
+
probe: (url) => probeGitUrl(url),
|
|
5023
|
+
// POST /repos's own intake refusal (no garden, an old one, the state home): the card says it before anyone presses.
|
|
5024
|
+
onboardRefusal: async () => {
|
|
5025
|
+
const refused = await onboardRefusal();
|
|
5026
|
+
if (refused === null)
|
|
5027
|
+
return null;
|
|
5028
|
+
const why = refused.body.error;
|
|
5029
|
+
return `this daemon can't onboard a repository now: ${typeof why === 'string' && why !== '' ? why : `refused (${refused.status})`}`;
|
|
5030
|
+
},
|
|
5031
|
+
},
|
|
4924
5032
|
served: (projectId) => servedFor(shapeReads, projectId ?? undefined),
|
|
4925
5033
|
turnLive: (chatId, turnId) => chatTurns.turnsOf(chatId).some((t) => t.turnId === turnId),
|
|
4926
5034
|
broadcast: (frame) => runtime.broadcast?.(frame),
|
|
@@ -5028,8 +5136,10 @@ runtime = {}) {
|
|
|
5028
5136
|
try {
|
|
5029
5137
|
// DES-CATALOG-002 §4.6: the client's declaration takes effect with an ACCEPTED message only (a refused one, a
|
|
5030
5138
|
// second tab's 409, never changes how a turn in flight is read; codex r2 on Lane D).
|
|
5031
|
-
if (parsed.data.accepts !== undefined)
|
|
5139
|
+
if (parsed.data.accepts !== undefined) {
|
|
5032
5140
|
chatAccepts.set(id, parsed.data.accepts.includes('job'));
|
|
5141
|
+
chatAcceptsOnboard.set(id, parsed.data.accepts.includes('onboard'));
|
|
5142
|
+
}
|
|
5033
5143
|
after();
|
|
5034
5144
|
if (preface !== null)
|
|
5035
5145
|
chatTranscripts?.appendSystem(id, turnId, preface);
|
|
@@ -5141,7 +5251,8 @@ runtime = {}) {
|
|
|
5141
5251
|
const pending = await considerations.pendingPreface(id, { inForce: rules });
|
|
5142
5252
|
// A7: a seat is told it can propose a studio theme only when this message carried the tab's appearance (a client
|
|
5143
5253
|
// that can preview and apply one sends it).
|
|
5144
|
-
|
|
5254
|
+
// crew-0182: this message's own onboard declaration (the chat's stored one changes once the message is accepted).
|
|
5255
|
+
const themeClient = { appearance: msgContext?.appearance !== undefined, onboard: parsed.data.accepts !== undefined ? parsed.data.accepts.includes('onboard') : chatAcceptsOnboard.get(id) === true };
|
|
5145
5256
|
// DES-CATALOG-002 §2.3, §4.6: the per-message job lines (the chat catalog digest, the open proposal, the held plan),
|
|
5146
5257
|
// read here, before the last check (no await after it). Never in an analysis.
|
|
5147
5258
|
// The declaration this message's instructions are written for: its own, else the chat's (applied to the chat only
|
|
@@ -5177,6 +5288,8 @@ runtime = {}) {
|
|
|
5177
5288
|
const requirementsBuilt = scope !== undefined
|
|
5178
5289
|
? await buildRequirementsMaps(scope, { listRepos: () => adapter.listRepos(), reader: adapter }).catch(() => [])
|
|
5179
5290
|
: [];
|
|
5291
|
+
// crew-0182: the daemon's projects and repositories for this message (a failed read names none; never fails the turn).
|
|
5292
|
+
const daemonGrounding = path.workflow === undefined ? await readDaemonGrounding(id, parsed.data.accepts) : undefined;
|
|
5180
5293
|
// The last await before delivery may also have closed/reopened the chat. From this check
|
|
5181
5294
|
// through publication and the send there is no await, so no executing turn's files change.
|
|
5182
5295
|
if (askPaths.get(id)?.generation !== lease || chatScopes.get(id) !== storedScope) {
|
|
@@ -5240,7 +5353,7 @@ runtime = {}) {
|
|
|
5240
5353
|
// A2: the per-message digest of what the chat can make now (advertised operations only).
|
|
5241
5354
|
// crew#1412: written after the last await and the generation check; a map that cannot be written says so.
|
|
5242
5355
|
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) };
|
|
5356
|
+
const statementOpts = { analysis: path.workflow !== undefined, make: chatProposals.digest(id, turnAccepts, themeClient), requirementsMaps, ...voiceFor(scope?.projectId), ...(daemonGrounding !== undefined ? { daemon: daemonGrounding } : {}) };
|
|
5244
5357
|
const projectId = scope?.projectId;
|
|
5245
5358
|
if (path.runId === undefined) {
|
|
5246
5359
|
const stepId = 'answer-1';
|