From 6933e5624b9fdd695afa2c06b3b82c99408b23f1 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sat, 31 Oct 2026 12:36:32 -0400 Subject: [PATCH 1/4] chore: bring the knip baseline to zero and run knip in J5 CI knip:check failed on a clean j5/main with 6 unused files and 142 unused exports, and J5 CI didn't run it. J5 code no longer exports what only its own file uses; dead J5 exports and the unused a2a barrel are deleted; J5 scripts run by path are knip entries. Upstream code whose callers J5 removed is left as written and ignored in knip.jsonc (FORK.md case 94). J5 CI now runs knip:check, as upstream's CI does. Closes #812 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/j5-ci.yml | 3 + FORK.md | 2 + apps/desktop/scripts/electron-launcher.mjs | 4 +- apps/desktop/src/electron/ElectronProtocol.ts | 4 +- apps/server/src/cloud/j5/legacyBootService.ts | 9 +- .../src/j5/a2a/AgentCrewProposalService.ts | 6 +- apps/server/src/j5/a2a/ArchiveCrewService.ts | 6 +- apps/server/src/j5/a2a/ClientReadsService.ts | 4 +- apps/server/src/j5/a2a/CrewLaunchService.ts | 12 ++- apps/server/src/j5/a2a/CrewProposalService.ts | 6 +- .../src/j5/a2a/CrewRuntimeRequestService.ts | 13 +-- .../src/j5/a2a/CrewSeatFinishNotifier.ts | 2 +- apps/server/src/j5/a2a/CrewStopService.ts | 2 +- apps/server/src/j5/a2a/DeliveryTransport.ts | 6 +- apps/server/src/j5/a2a/DeliveryWorker.ts | 5 +- apps/server/src/j5/a2a/LifecycleService.ts | 4 +- .../src/j5/a2a/MachineParticipantService.ts | 2 +- apps/server/src/j5/a2a/MachineSenderHttp.ts | 5 +- apps/server/src/j5/a2a/SendService.ts | 2 +- apps/server/src/j5/a2a/contracts.ts | 2 +- .../server/src/j5/a2a/crewSeatArchiveGuard.ts | 2 +- apps/server/src/j5/a2a/crewSeatIds.ts | 2 +- apps/server/src/j5/a2a/index.ts | 69 -------------- .../src/j5/a2a/mcp/codexToolApproval.ts | 2 - apps/server/src/j5/a2a/mcp/handlers.ts | 2 +- .../src/j5/a2a/mcp/j5ToolPreapproval.ts | 2 +- .../src/j5/a2a/mcp/orchestratorSurface.ts | 2 +- apps/server/src/j5/a2a/mcp/tools.ts | 17 ++-- apps/server/src/j5/a2a/runtimeLayer.ts | 6 +- .../src/j5/agents/agentPersonaArtifacts.ts | 2 +- .../j5/agents/agentPersonaOrchestration.ts | 4 +- .../src/j5/agents/agentPersonaRuntime.ts | 2 +- .../src/j5/analytics/ExchangeAnalytics.ts | 89 ++++++++---------- .../ArtifactRunFinalizationObserver.ts | 2 +- .../src/j5/artifacts/ArtifactWorkspace.ts | 4 +- apps/server/src/j5/cli/a2a.ts | 4 +- .../src/j5/persistence/MigrationSnapshot.ts | 2 +- .../src/j5/playbooks/PlaybookCrewRelay.ts | 2 +- apps/server/src/j5/playbooks/PlaybookStore.ts | 2 +- apps/server/src/j5/settlementActivity.ts | 2 +- apps/server/src/j5/sharing/AccessGate.ts | 2 +- .../server/src/j5/sharing/CommandAdmission.ts | 2 +- .../src/j5/sharing/GuestProjectIcons.ts | 2 +- apps/server/src/j5/sharing/GuestView.ts | 2 +- apps/server/src/j5/sharing/LinkHttp.ts | 2 +- apps/server/src/j5/sharing/McpApproval.ts | 2 +- apps/server/src/j5/sharing/PairingIntents.ts | 5 +- apps/server/src/j5/sharing/PersonAccess.ts | 2 +- .../src/j5/sharing/SharedConversation.ts | 6 +- .../src/j5/skills/skillCatalogInstaller.ts | 4 +- apps/server/src/j5/skills/skillLinks.ts | 4 +- .../j5/test-support/threadLaunchHarness.ts | 2 +- apps/server/src/mcp/McpInvocationContext.ts | 2 +- .../src/mcp/toolkits/artifacts/tools.ts | 6 +- .../orchestration-v2/ThreadLaunchService.ts | 2 +- apps/web/src/j5/a2a/HumanInboxPage.tsx | 2 +- apps/web/src/j5/agents/agentDraftState.ts | 3 +- apps/web/src/j5/fleet/fleet.logic.ts | 4 +- apps/web/src/j5/highlights/seenHighlights.ts | 2 +- apps/web/src/j5/logicalProjects.ts | 2 +- .../src/j5/notifications/completionSound.ts | 2 +- apps/web/src/j5/sharing/PersonAvatar.tsx | 2 +- apps/web/src/j5/sharing/ShareLinkPanel.tsx | 2 +- apps/web/src/j5/sharing/access.ts | 7 +- .../src/j5/sharing/sharedTimeline.logic.ts | 2 +- apps/web/src/j5/skills/SkillLinksPanel.tsx | 2 +- apps/web/src/j5/threads/useThreadRowReads.ts | 2 +- apps/web/src/rightPanelStore.ts | 2 +- knip.jsonc | 17 ++++ .../client-runtime/src/j5/agentPersonas.ts | 4 +- packages/client-runtime/src/j5/playbooks.ts | 6 +- .../src/j5/scopedThreadReadStore.ts | 2 +- packages/client-runtime/src/j5/sharing.ts | 2 +- .../src/j5/userMessagePresentation.ts | 2 +- packages/contracts/src/j5.ts | 2 +- packages/contracts/src/j5/agentPersona.ts | 92 ++++++++----------- packages/contracts/src/j5/artifacts.ts | 15 ++- packages/contracts/src/j5/peerPoll.ts | 2 +- packages/contracts/src/j5/skillCatalog.ts | 17 ++-- packages/contracts/src/settings.ts | 2 +- .../src/j5/playbookInstructions.ts | 2 +- packages/shared/src/j5/agentMention.ts | 2 +- packages/shared/src/promptLinks.ts | 2 +- 83 files changed, 233 insertions(+), 333 deletions(-) delete mode 100644 apps/server/src/j5/a2a/index.ts diff --git a/.github/workflows/j5-ci.yml b/.github/workflows/j5-ci.yml index 071e643fa7ebb..1e6f112af7fbe 100644 --- a/.github/workflows/j5-ci.yml +++ b/.github/workflows/j5-ci.yml @@ -64,6 +64,9 @@ jobs: - name: Typecheck run: pnpm exec vp run -r --concurrency-limit 2 --log grouped typecheck + - name: Check unused code + run: pnpm exec vp run knip:check + # These gitlinks belong to vendored manifests, not this repository. # Remove them only from the disposable index before checkout's cleanup. - name: Exclude vendored gitlinks from checkout cleanup diff --git a/FORK.md b/FORK.md index fe63bbc79d4d7..c86dda76ce7d6 100644 --- a/FORK.md +++ b/FORK.md @@ -499,6 +499,7 @@ migrations after upstream migrations. The server, the contracts and mobile's owner screens are upstream's: `guestSharingEnabled` defaults off, and the server refuses a guest link without T3 Connect. J5's allow-lists for a narrowed connection (case 69's `ACCESS_RPC_RULES`, case 78's `NARROWED_COMMAND_SCOPES`) don't list `guestShare.create`, `thread.guest-share.close` or `thread.guest-message.dismiss`, so they refuse them to anyone whose scope is narrower than the server. Proof: `apps/web/src/j5/sharing/guestLinks.test.ts` (the atom stays false where the server would allow guest links) and `guestLinksSettings.test.ts` (search and the palette don't offer the row). Exit: [#725](https://github.com/Jacksondr5/j5code/issues/725), whether J5 runs its own T3 Connect; if it does, set the constant to true and retire this case and D40. On a pin advance: if upstream gates a new guest-link door on something other than `canShareWithGuestAtom`, close it too; if upstream moves the guest-links row out of the Beta section, or adds other rows to that section, hide only the row. 93. `vp run check:changed` compares against J5's trunk ([#701](https://github.com/Jacksondr5/j5code/issues/701)). Upstream's `scripts/check-changed.ts` defaults its base ref to `origin/main`, which a J5 clone does not have, so a bare run stopped with "no merge base". The default is `origin/j5/main` (the `ref` line and the usage comment above it); a ref passed on the command line still wins. Upstream's `docs/operations/development.md` keeps its `origin/main` wording, as J5 does not edit upstream's docs. On every rebase, keep the default when upstream rewrites the script. +94. Knip covers J5's code ([#812](https://github.com/Jacksondr5/j5code/issues/812)). J5 CI runs `vp run knip:check`, as upstream's CI does, and `knip.jsonc` carries J5's additions, each marked `J5:`. The `scripts` and `apps/server` workspaces list the J5 scripts that run by path. The top-level `ignoreFiles` and `ignoreIssues` cover upstream code whose only callers J5 removed or replaced: the T3 wordmarks (rebrand), the `thread` CLI command (case 82), `configuredHostedAppUrl` (case 76), `useNpmReleasePublished` (J5's release check) and `buildT3ProjectFileJsonSchema` (the marketing site's schema page). That code is left as upstream wrote it, so advances merge cleanly. Drop an entry when upstream deletes its code or J5 calls it again. 94. Cmd+K names who wrote a person's message it found ([#809](https://github.com/Jacksondr5/j5code/issues/809)). Upstream labels every user-role hit "You:", which is wrong for anyone else's words in a shared conversation. Upstream's `OrchestrationThreadSearchMatch` (`packages/contracts/src/threadSearch.ts`) gains an optional `author`, J5's `ThreadSearchAuthor` (`you`, or `person` with the name they wrote under). The server fills it in J5-owned code: `connectionView` (case 69) labels each search's matches through `apps/server/src/j5/sharing/searchAuthors.ts`, by the message's `j5_a2a_message_author` record (case 80), or as the first owner's when a person typed it before the thread was shared. ws.ts is unchanged. On the web, `ThreadSearchMatchExcerpt` (`apps/web/src/components/ThreadSearchMatch.tsx`) draws `threadSearchMatchLabel` (`apps/web/src/j5/sharing/searchAuthorLabel.ts`) in place of its "You"/"Agent" choice, and the author is passed through `CommandPaletteThreadContentMatch` (`CommandPalette.logic.ts`), `CommandPaletteThreadItems.tsx` and the sidebar's `SidebarThreadRow.tsx`. A match without `author`, from an older server or any message no person typed, keeps upstream's label. Mobile's palette still says "You". On every rebase, keep the field on the match and the one-line label call. @@ -893,6 +894,7 @@ explicitly marked. | `scripts/build-desktop-artifact.test.ts` | A | B, S, 50 | | `scripts/build-desktop-artifact.ts` | R | B, S, 50 | | `scripts/check-changed.ts` | N | 93 | +| `knip.jsonc` | N | 94 | | `scripts/dev-runner.test.ts` | R | H, 63, 83, 88 | | `scripts/dev-runner.ts` | R | H, 63, 83, 88 | | `scripts/export-android-icons.ts` | N | B | diff --git a/apps/desktop/scripts/electron-launcher.mjs b/apps/desktop/scripts/electron-launcher.mjs index 3f89857ae9795..ceb20794220f6 100644 --- a/apps/desktop/scripts/electron-launcher.mjs +++ b/apps/desktop/scripts/electron-launcher.mjs @@ -14,10 +14,10 @@ const repoRoot = NodePath.resolve(desktopDir, "..", ".."); const devBundleIdSuffix = NodePath.basename(repoRoot) .toLowerCase() .replaceAll(/[^a-z0-9]+/g, ""); -export const APP_DISPLAY_NAME = isDevelopment +const APP_DISPLAY_NAME = isDevelopment ? J5_BRANDING.desktop.developmentName : J5_BRANDING.desktop.baseName; -export const APP_BUNDLE_ID = isDevelopment +const APP_BUNDLE_ID = isDevelopment ? `${J5_BRANDING.desktop.developmentAppId}.${devBundleIdSuffix || "local"}` : J5_BRANDING.desktop.appId; const APP_PROTOCOL_SCHEMES = isDevelopment diff --git a/apps/desktop/src/electron/ElectronProtocol.ts b/apps/desktop/src/electron/ElectronProtocol.ts index 0bf51365a14c3..eb70a46c0b3f0 100644 --- a/apps/desktop/src/electron/ElectronProtocol.ts +++ b/apps/desktop/src/electron/ElectronProtocol.ts @@ -15,8 +15,8 @@ import { J5_BRANDING } from "../../../../scripts/lib/j5-branding.ts"; import * as Electron from "electron"; export const DESKTOP_HOST = "app"; -export const DESKTOP_PRODUCTION_SCHEME = J5_BRANDING.desktop.productionScheme; -export const DESKTOP_DEVELOPMENT_SCHEME = J5_BRANDING.desktop.developmentScheme; +const DESKTOP_PRODUCTION_SCHEME = J5_BRANDING.desktop.productionScheme; +const DESKTOP_DEVELOPMENT_SCHEME = J5_BRANDING.desktop.developmentScheme; export function getDesktopScheme(isDevelopment: boolean): string { return isDevelopment ? DESKTOP_DEVELOPMENT_SCHEME : DESKTOP_PRODUCTION_SCHEME; diff --git a/apps/server/src/cloud/j5/legacyBootService.ts b/apps/server/src/cloud/j5/legacyBootService.ts index d67ce14640551..c4bc472b216f3 100644 --- a/apps/server/src/cloud/j5/legacyBootService.ts +++ b/apps/server/src/cloud/j5/legacyBootService.ts @@ -9,8 +9,8 @@ import type { BootServiceStep } from "../bootService.ts"; * T3 Code. `j5 service install` retires such a unit only when it is provably J5's: it names * `J5CODE_HOME` and never `T3CODE_HOME`. A T3 Code unit is never touched. */ -export const LEGACY_J5_SYSTEMD_UNIT_FILE = "t3code.service"; -export const LEGACY_J5_LAUNCHD_LABEL = "com.t3tools.t3code.service"; +const LEGACY_J5_SYSTEMD_UNIT_FILE = "t3code.service"; +const LEGACY_J5_LAUNCHD_LABEL = "com.t3tools.t3code.service"; /** Whether a unit or plist at a legacy path was written by a J5 CLI. */ export function isLegacyJ5BootServiceUnit(contents: string): boolean { @@ -37,10 +37,7 @@ export function isRenderedJ5BootServiceUnit(contents: string): boolean { * denied, bus unreachable, a timeout) is a real failure: the old server may still be running, so * the handover must stop before a second writer starts on the same home. */ -export function legacyStopMeansNotRunning( - kind: "systemd" | "launchd", - result: ProcessRunOutput, -): boolean { +function legacyStopMeansNotRunning(kind: "systemd" | "launchd", result: ProcessRunOutput): boolean { if (result.timedOut) return false; const output = `${result.stdout}\n${result.stderr}`; if (kind === "systemd") { diff --git a/apps/server/src/j5/a2a/AgentCrewProposalService.ts b/apps/server/src/j5/a2a/AgentCrewProposalService.ts index f08daecff1cea..9037fc4b7dc95 100644 --- a/apps/server/src/j5/a2a/AgentCrewProposalService.ts +++ b/apps/server/src/j5/a2a/AgentCrewProposalService.ts @@ -65,11 +65,7 @@ export type CrewProposalKind = "roster" | "addition"; */ export type CrewProposalStatus = "open" | "approved" | "declined"; export type CrewProposalDecision = "approve" | "decline"; -export const CREW_PROPOSAL_STATUSES: ReadonlyArray = [ - "open", - "approved", - "declined", -]; +const CREW_PROPOSAL_STATUSES: ReadonlyArray = ["open", "approved", "declined"]; const finalStatus = (decision: CrewProposalDecision) => decision === "approve" ? ("approved" as const) : ("declined" as const); diff --git a/apps/server/src/j5/a2a/ArchiveCrewService.ts b/apps/server/src/j5/a2a/ArchiveCrewService.ts index 9abcbf524b224..3752276415c60 100644 --- a/apps/server/src/j5/a2a/ArchiveCrewService.ts +++ b/apps/server/src/j5/a2a/ArchiveCrewService.ts @@ -98,9 +98,7 @@ export class ArchiveCrewNotCaptainError extends Data.TaggedError("ArchiveCrewNot } } -export class ArchiveCrewProjectMismatchError extends Data.TaggedError( - "ArchiveCrewProjectMismatchError", -)<{ +class ArchiveCrewProjectMismatchError extends Data.TaggedError("ArchiveCrewProjectMismatchError")<{ readonly crewInstanceId: string; readonly projectId: LedgerProjectId; readonly expected: LedgerProjectId; @@ -133,7 +131,7 @@ export class ArchiveCrewConfirmationStaleError extends Data.TaggedError( } } -export class ArchiveCrewConfirmationTokenError extends Data.TaggedError( +class ArchiveCrewConfirmationTokenError extends Data.TaggedError( "ArchiveCrewConfirmationTokenError", )<{ readonly reason: "malformed" | "unsupported-version" }> { override get message(): string { diff --git a/apps/server/src/j5/a2a/ClientReadsService.ts b/apps/server/src/j5/a2a/ClientReadsService.ts index 85a79961e66c5..bec6b46439f49 100644 --- a/apps/server/src/j5/a2a/ClientReadsService.ts +++ b/apps/server/src/j5/a2a/ClientReadsService.ts @@ -142,7 +142,7 @@ export const participantIdentityRows = ( `; /** This exact statement is executed for count reads and compiled by the plan proof below. */ -export const openInboxCountStatement = (sql: SqlClient.SqlClient, personId: ParticipantId) => +const openInboxCountStatement = (sql: SqlClient.SqlClient, personId: ParticipantId) => sql` SELECT COUNT(*) AS count FROM j5_a2a_human_inbox AS inbox @@ -164,7 +164,7 @@ const decodeLatestPeerDelivery = Schema.decodeUnknownSync( Schema.fromJsonString(Schema.Struct({ label: Schema.String, environmentId: Schema.String })), ); -export const peerSenderLabelStatement = ( +const peerSenderLabelStatement = ( sql: SqlClient.SqlClient, participantIds: ReadonlyArray, ) => diff --git a/apps/server/src/j5/a2a/CrewLaunchService.ts b/apps/server/src/j5/a2a/CrewLaunchService.ts index 26ff500d2a4e9..a426763d76c01 100644 --- a/apps/server/src/j5/a2a/CrewLaunchService.ts +++ b/apps/server/src/j5/a2a/CrewLaunchService.ts @@ -169,16 +169,18 @@ export interface CrewLaunchResult { readonly seats: ReadonlyArray; } -export class CrewLaunchSeatUnavailableError extends Data.TaggedError( - "CrewLaunchSeatUnavailableError", -)<{ readonly seatName: string; readonly agentId: string; readonly detail: string }> { +class CrewLaunchSeatUnavailableError extends Data.TaggedError("CrewLaunchSeatUnavailableError")<{ + readonly seatName: string; + readonly agentId: string; + readonly detail: string; +}> { override get message(): string { return `Seat ${this.seatName} (agent ${this.agentId}) is unavailable: ${this.detail} Nothing was spawned.`; } } /** The Crew is full; the seats it holds already reach the cap once the request is counted. */ -export class CrewLaunchCapError extends Data.TaggedError("CrewLaunchCapError")<{ +class CrewLaunchCapError extends Data.TaggedError("CrewLaunchCapError")<{ readonly crewInstanceId: string; readonly held: number; readonly adding: number; @@ -190,7 +192,7 @@ export class CrewLaunchCapError extends Data.TaggedError("CrewLaunchCapError")<{ } /** A seat name the reservation could not take: another participant already holds it. */ -export class CrewLaunchSeatConflictError extends Data.TaggedError("CrewLaunchSeatConflictError")<{ +class CrewLaunchSeatConflictError extends Data.TaggedError("CrewLaunchSeatConflictError")<{ readonly crewInstanceId: string; readonly seatNames: ReadonlyArray; }> { diff --git a/apps/server/src/j5/a2a/CrewProposalService.ts b/apps/server/src/j5/a2a/CrewProposalService.ts index 4a72d6242427e..abe43c0664dc4 100644 --- a/apps/server/src/j5/a2a/CrewProposalService.ts +++ b/apps/server/src/j5/a2a/CrewProposalService.ts @@ -71,7 +71,7 @@ const launchSeatOf = (seat: CrewProposalSeat): CrewLaunchSeat => { }; }; -export class CrewProposalRequestError extends Data.TaggedError("CrewProposalRequestError")<{ +class CrewProposalRequestError extends Data.TaggedError("CrewProposalRequestError")<{ readonly detail: string; readonly nextStep: string; }> { @@ -89,7 +89,7 @@ export class CrewProposalNotOpenError extends Data.TaggedError("CrewProposalNotO } } -export class CrewProposalNotFoundError extends Data.TaggedError("CrewProposalNotFoundError")<{ +class CrewProposalNotFoundError extends Data.TaggedError("CrewProposalNotFoundError")<{ readonly proposalId: string; }> { override get message(): string { @@ -97,7 +97,7 @@ export class CrewProposalNotFoundError extends Data.TaggedError("CrewProposalNot } } -export class CrewProposalOperationError extends Data.TaggedError("CrewProposalOperationError")<{ +class CrewProposalOperationError extends Data.TaggedError("CrewProposalOperationError")<{ readonly phase: string; readonly cause: unknown; }> { diff --git a/apps/server/src/j5/a2a/CrewRuntimeRequestService.ts b/apps/server/src/j5/a2a/CrewRuntimeRequestService.ts index 91ec622675461..45c7350201b08 100644 --- a/apps/server/src/j5/a2a/CrewRuntimeRequestService.ts +++ b/apps/server/src/j5/a2a/CrewRuntimeRequestService.ts @@ -30,9 +30,10 @@ interface CrewSeatThread { export { inboxAnswerableApprovals } from "@t3tools/shared/j5/crewRuntimeRequests"; -export class CrewRuntimeRequestNotFoundError extends Data.TaggedError( - "CrewRuntimeRequestNotFoundError", -)<{ readonly threadId: ThreadId; readonly requestId: RuntimeRequestId }> { +class CrewRuntimeRequestNotFoundError extends Data.TaggedError("CrewRuntimeRequestNotFoundError")<{ + readonly threadId: ThreadId; + readonly requestId: RuntimeRequestId; +}> { override get message() { return `No pending approval ${this.requestId} on a live Crew seat's thread ${this.threadId}.`; } @@ -48,9 +49,9 @@ export class CrewRuntimeRequestConflictError extends Data.TaggedError( } /** The answer could not be sent for a reason other than the request's state; the route logs it. */ -export class CrewRuntimeRequestDispatchError extends Data.TaggedError( - "CrewRuntimeRequestDispatchError", -)<{ readonly cause: OrchestratorV2Error | ThreadManagementProviderInstanceDisabledError }> { +class CrewRuntimeRequestDispatchError extends Data.TaggedError("CrewRuntimeRequestDispatchError")<{ + readonly cause: OrchestratorV2Error | ThreadManagementProviderInstanceDisabledError; +}> { override get message() { return "The answer could not be sent."; } diff --git a/apps/server/src/j5/a2a/CrewSeatFinishNotifier.ts b/apps/server/src/j5/a2a/CrewSeatFinishNotifier.ts index d2ba057474d18..9d6585b6be277 100644 --- a/apps/server/src/j5/a2a/CrewSeatFinishNotifier.ts +++ b/apps/server/src/j5/a2a/CrewSeatFinishNotifier.ts @@ -60,7 +60,7 @@ export class CrewSeatFinishNotifier extends Context.Service< const FINISH_SESSION = "j5-crew-seat-finish"; /** Bodies up to this size ride inline in the Captain's notice; longer ones are read on demand. */ -export const INLINE_HANDOFF_MAX_CHARS = 4_000; +const INLINE_HANDOFF_MAX_CHARS = 4_000; /** * A seat has finished only when its run completed or failed. Interrupted, cancelled and rolled back diff --git a/apps/server/src/j5/a2a/CrewStopService.ts b/apps/server/src/j5/a2a/CrewStopService.ts index ffb605e3e830c..690f71888fdc9 100644 --- a/apps/server/src/j5/a2a/CrewStopService.ts +++ b/apps/server/src/j5/a2a/CrewStopService.ts @@ -48,7 +48,7 @@ export class CrewStopNotFoundError extends Data.TaggedError("CrewStopNotFoundErr } } -export class CrewStopRequestError extends Data.TaggedError("CrewStopRequestError")<{ +class CrewStopRequestError extends Data.TaggedError("CrewStopRequestError")<{ readonly detail: string; readonly nextStep: string; }> { diff --git a/apps/server/src/j5/a2a/DeliveryTransport.ts b/apps/server/src/j5/a2a/DeliveryTransport.ts index 35028126ad078..dc63149c0e7f7 100644 --- a/apps/server/src/j5/a2a/DeliveryTransport.ts +++ b/apps/server/src/j5/a2a/DeliveryTransport.ts @@ -191,10 +191,8 @@ export const deliveryCommandId = (messageId: LedgerMessageId) => * and rejects a restart aimed at a turn that has just ended and a steer to a run that Stop has * reached, so the plain delivery that follows must keep a command id that nothing has refused. */ -export const askedDeliveryCommandId = ( - messageId: LedgerMessageId, - mode: Exclude, -) => CommandId.make(`${deliveryCommandId(messageId)}:${mode}`); +const askedDeliveryCommandId = (messageId: LedgerMessageId, mode: Exclude) => + CommandId.make(`${deliveryCommandId(messageId)}:${mode}`); /** Every command one message's delivery may have been dispatched under. */ const deliveryCommandIds = (messageId: LedgerMessageId) => [ diff --git a/apps/server/src/j5/a2a/DeliveryWorker.ts b/apps/server/src/j5/a2a/DeliveryWorker.ts index d7853e60239e7..bca5db767a221 100644 --- a/apps/server/src/j5/a2a/DeliveryWorker.ts +++ b/apps/server/src/j5/a2a/DeliveryWorker.ts @@ -56,10 +56,7 @@ import { } from "./deliveryNotices.ts"; import { buildPeerDeliveryBody } from "./peerDeliveryBody.ts"; -export const A2A_DELIVERY_CONFIG_VERSION = config.version; - /** One poll hands out at most this many deliveries, or about this many bytes of message text. */ -export { PEER_POLL_BATCH_COUNT }; export const PEER_POLL_BATCH_BYTES = 1_000_000; const decodeSentPayload = Schema.decodeUnknownEffect(Schema.fromJsonString(MessageSentPayload)); @@ -124,7 +121,7 @@ export class A2ADeliveryHooks extends Context.Service @@ -185,7 +185,7 @@ export const formatAccessEndedNotice = (input: { "This is a platform-authored terminal notice, not a peer reply.", ].join("\n\n"); -export const formatLifecycleNotice = (input: { +const formatLifecycleNotice = (input: { readonly exchangeId: ExchangeId; readonly retiredParticipantId: ParticipantId; readonly disposition: ExchangeDropDisposition; diff --git a/apps/server/src/j5/a2a/MachineParticipantService.ts b/apps/server/src/j5/a2a/MachineParticipantService.ts index f26675cca2cad..8cd8a739e23b9 100644 --- a/apps/server/src/j5/a2a/MachineParticipantService.ts +++ b/apps/server/src/j5/a2a/MachineParticipantService.ts @@ -21,7 +21,7 @@ import { */ /** Server-unique, shell-friendly: the part after `machine:`. */ -export const MACHINE_PARTICIPANT_NAME_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/; +const MACHINE_PARTICIPANT_NAME_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/; export interface MachineParticipantRecord { readonly participantId: ParticipantId; diff --git a/apps/server/src/j5/a2a/MachineSenderHttp.ts b/apps/server/src/j5/a2a/MachineSenderHttp.ts index 2a1ffe5a925d5..150dcf9f3df55 100644 --- a/apps/server/src/j5/a2a/MachineSenderHttp.ts +++ b/apps/server/src/j5/a2a/MachineSenderHttp.ts @@ -62,10 +62,7 @@ export const machineSendCommandId = (input: { `command:j5:a2a:machine:${stablePart(input.senderParticipantId)}:send:${stablePart(input.clientRequestId)}`, ); -export const machineRegisterCommandId = (input: { - readonly projectId: string; - readonly name: string; -}) => +const machineRegisterCommandId = (input: { readonly projectId: string; readonly name: string }) => CommCommandId.make( `command:j5:a2a:machine:register:${stablePart(input.projectId)}:${stablePart(input.name)}`, ); diff --git a/apps/server/src/j5/a2a/SendService.ts b/apps/server/src/j5/a2a/SendService.ts index e4e86befecf68..f4696a3af2757 100644 --- a/apps/server/src/j5/a2a/SendService.ts +++ b/apps/server/src/j5/a2a/SendService.ts @@ -468,7 +468,7 @@ const withdrawalMessageIdFor = (commandId: CommCommandId) => LedgerMessageId.make(`message:j5:a2a:withdraw:${encodeURIComponent(commandId)}`); /** Platform-authored, like the retirement notice: the asker cleared its own ask, nothing is owed. */ -export const formatWithdrawalNotice = (input: { +const formatWithdrawalNotice = (input: { readonly exchangeId: ExchangeId; readonly askerId: ParticipantId; }): string => diff --git a/apps/server/src/j5/a2a/contracts.ts b/apps/server/src/j5/a2a/contracts.ts index 919daedb85781..fd0ac2579d9f2 100644 --- a/apps/server/src/j5/a2a/contracts.ts +++ b/apps/server/src/j5/a2a/contracts.ts @@ -71,7 +71,7 @@ export const isDurableHumanParticipantId = (id: ParticipantId): boolean => */ export const EVERYONE_HERE_PERSON_ID = ParticipantId.make("human:everyone-here"); -export const MACHINE_PARTICIPANT_ID_PREFIX = "machine:"; +const MACHINE_PARTICIPANT_ID_PREFIX = "machine:"; export const isMachineParticipantId = (id: ParticipantId): boolean => id.startsWith(MACHINE_PARTICIPANT_ID_PREFIX) && id.length > MACHINE_PARTICIPANT_ID_PREFIX.length; export const isPlatformParticipantId = (id: string): boolean => id.startsWith("platform:"); diff --git a/apps/server/src/j5/a2a/crewSeatArchiveGuard.ts b/apps/server/src/j5/a2a/crewSeatArchiveGuard.ts index a98c85383e78a..3a55d4d494e38 100644 --- a/apps/server/src/j5/a2a/crewSeatArchiveGuard.ts +++ b/apps/server/src/j5/a2a/crewSeatArchiveGuard.ts @@ -11,7 +11,7 @@ import { participantIdForThread } from "./HomeRegistrar.ts"; * so this check on that handler covers every door, and the organize MCP tool applies it too. The * unit paths archive seats through the lifecycle service, not this handler. */ -export class CrewSeatArchivedAloneError extends Data.TaggedError("CrewSeatArchivedAloneError")<{ +class CrewSeatArchivedAloneError extends Data.TaggedError("CrewSeatArchivedAloneError")<{ readonly threadId: string; readonly action: "archive" | "delete"; readonly seatName: string; diff --git a/apps/server/src/j5/a2a/crewSeatIds.ts b/apps/server/src/j5/a2a/crewSeatIds.ts index 6b05dcbab5d7b..bd072407e12fc 100644 --- a/apps/server/src/j5/a2a/crewSeatIds.ts +++ b/apps/server/src/j5/a2a/crewSeatIds.ts @@ -13,7 +13,7 @@ import { */ export const CREW_PROPOSAL_SESSION = "j5-crew-proposal"; -export const crewSeatSpawnInput = (proposalId: string, seatName: string): SpawnStableInput => ({ +const crewSeatSpawnInput = (proposalId: string, seatName: string): SpawnStableInput => ({ providerSessionId: CREW_PROPOSAL_SESSION, requestKey: crewSeatRequestKey(proposalId, seatName), }); diff --git a/apps/server/src/j5/a2a/index.ts b/apps/server/src/j5/a2a/index.ts deleted file mode 100644 index 58ff6bee69db4..0000000000000 --- a/apps/server/src/j5/a2a/index.ts +++ /dev/null @@ -1,69 +0,0 @@ -export * from "./contracts.ts"; -export { - A2AArchiveFacts, - A2AArchiveFactsError, - A2AArchivePlacementFactsProviderError, - A2AArchivePlacementFactsProvider, - layer as archiveFactsLayer, - placementFactsLayer, -} from "./ArchiveFactsService.ts"; -export type { - A2AArchiveFactsShape, - A2AArchivePlacementFactsProviderShape, - ArchivePlacementSubtree, - OpenExchangeArchiveFact, - ThreadPreArchiveFacts, -} from "./ArchiveFactsService.ts"; -export * from "./decider.ts"; -export { - A2AHomeCommandConflictError, - A2AHomeConflictError, - A2AHomeNotFoundError, - A2AHomeRegistrar, - layer as homeRegistrarLayer, - participantIdForThread, -} from "./HomeRegistrar.ts"; -export type { - A2AHomeLookupError, - A2AHomeRegistrarShape, - A2AHomeRegistrationError, - RegisteredThreadHome, - RegisterAtCreationInput, -} from "./HomeRegistrar.ts"; -export * from "./LedgerService.ts"; -export { - A2ALifecycleCounterpartyStateError, - A2ALifecycleBridgeError, - A2ALifecycleHumanArchiveNotAllowedError, - A2ALifecycleParticipantHomeStateError, - A2ALifecycleParticipantNotFoundError, - A2ALifecycleService, - formatLifecycleNotice, -} from "./LifecycleService.ts"; -export type { A2ALifecycleError, A2ALifecycleServiceShape } from "./LifecycleService.ts"; -export * from "./Migrations.ts"; -export * from "./placementContracts.ts"; -export * from "./placementProvenance.ts"; -export { - A2AHumanInbox, - A2AHumanPersonIdError, - type A2AHumanInboxError, - type A2AHumanInboxShape, -} from "./HumanInboxService.ts"; -export { - ParticipantPlacementService, - type ParticipantPlacementServiceShape, - type PlacementError, -} from "./PlacementService.ts"; -export { - ThreadRegistration, - layer as threadRegistrationLayer, - registrationCommandId, -} from "./ThreadRegistration.ts"; -export type { RegistrableThread, ThreadRegistrationShape } from "./ThreadRegistration.ts"; -export { - A2ASilenceDetector, - A2ASilenceDetectorError, - SilenceNoticePayload, - STOPPED_NOTICE_INSTRUCTION, -} from "./SilenceDetector.ts"; diff --git a/apps/server/src/j5/a2a/mcp/codexToolApproval.ts b/apps/server/src/j5/a2a/mcp/codexToolApproval.ts index a94569f84fb10..e9c953cec42dc 100644 --- a/apps/server/src/j5/a2a/mcp/codexToolApproval.ts +++ b/apps/server/src/j5/a2a/mcp/codexToolApproval.ts @@ -1,5 +1,4 @@ import { - J5_COORDINATION_TOOLS, J5_PREAPPROVED_TOOLS, j5PreapprovedTools, type J5RuntimePolicy, @@ -11,7 +10,6 @@ const preapprovedToolConfig = (names: ReadonlyArray) => ({ }); export const J5_CODEX_T3_MCP_SERVER_CONFIG = preapprovedToolConfig(J5_PREAPPROVED_TOOLS); -export const J5_CODEX_COORDINATION_MCP_SERVER_CONFIG = preapprovedToolConfig(J5_COORDINATION_TOOLS); /** Spread into the injected `mcp_servers["t3-code"]` entry; the list is `j5PreapprovedTools`. */ export const j5CodexT3McpServerConfig = ( diff --git a/apps/server/src/j5/a2a/mcp/handlers.ts b/apps/server/src/j5/a2a/mcp/handlers.ts index 51db6db935e39..308200b94e48f 100644 --- a/apps/server/src/j5/a2a/mcp/handlers.ts +++ b/apps/server/src/j5/a2a/mcp/handlers.ts @@ -163,7 +163,7 @@ const projectProvenance = (provenance: ParticipantProvenanceView) => { * registered name: it keeps the value these ids were written with before the tools gained their * `j5_` prefix, so a retry with the same client_request_id still finds its first command. */ -export const commandIdForRequest = (input: { +const commandIdForRequest = (input: { readonly toolName: "send_message" | "clear_own_ask"; readonly providerSessionId: string; readonly requestKey: string; diff --git a/apps/server/src/j5/a2a/mcp/j5ToolPreapproval.ts b/apps/server/src/j5/a2a/mcp/j5ToolPreapproval.ts index f6e70dbd40da8..cfb4ddfcc1c9c 100644 --- a/apps/server/src/j5/a2a/mcp/j5ToolPreapproval.ts +++ b/apps/server/src/j5/a2a/mcp/j5ToolPreapproval.ts @@ -7,7 +7,7 @@ export interface J5RuntimePolicy { } /** Definition writes have their own server-side policy check, unlike progress-only tools. */ -export const J5_DEFINITION_WRITE_TOOLS: ReadonlyArray = ["j5_playbook_save"]; +const J5_DEFINITION_WRITE_TOOLS: ReadonlyArray = ["j5_playbook_save"]; /** * The t3-code tools Codex and Claude pre-approve, so the roster gate stays the only human step. diff --git a/apps/server/src/j5/a2a/mcp/orchestratorSurface.ts b/apps/server/src/j5/a2a/mcp/orchestratorSurface.ts index 84bf02b9cdf79..39239814e5b69 100644 --- a/apps/server/src/j5/a2a/mcp/orchestratorSurface.ts +++ b/apps/server/src/j5/a2a/mcp/orchestratorSurface.ts @@ -80,7 +80,7 @@ export const mapJ5OrchestratorCapabilities = ( export const J5_ORCHESTRATOR_CAPABILITIES_DESCRIPTION = "List providers, models, options, and runtime modes for `delegate_task` and `j5_spawn_agent`, and the provider, model and options this thread runs with. Short list. `search` finds others. Any catalog model works."; -export const J5OrchestratorCapabilitiesTool = Tool.make("orchestrator_capabilities", { +const J5OrchestratorCapabilitiesTool = Tool.make("orchestrator_capabilities", { description: J5_ORCHESTRATOR_CAPABILITIES_DESCRIPTION, parameters: OrchestratorMcpCapabilitiesInput, success: J5OrchestratorCapabilitiesResult, diff --git a/apps/server/src/j5/a2a/mcp/tools.ts b/apps/server/src/j5/a2a/mcp/tools.ts index 364edecd8b29f..14f1696838b03 100644 --- a/apps/server/src/j5/a2a/mcp/tools.ts +++ b/apps/server/src/j5/a2a/mcp/tools.ts @@ -178,7 +178,7 @@ export const J5ParticipantDirectoryRow = Schema.Struct({ export type J5ParticipantDirectoryRow = typeof J5ParticipantDirectoryRow.Type; /** The most rows one listing returns, and how many it returns when `limit` is omitted. */ -export const J5_LIST_PARTICIPANTS_MAX_LIMIT = 100; +const J5_LIST_PARTICIPANTS_MAX_LIMIT = 100; export const J5_LIST_PARTICIPANTS_DEFAULT_LIMIT = 50; /** @@ -363,7 +363,6 @@ export const J5ListAgentsResult = Schema.Struct({ * names stay one line each because the platform writes them into the notices whose fields the * Captain's card parses (see `crewLimits.ts`). */ -export { CREW_NAME_MAX_CHARS, CREW_REASON_MAX_CHARS, CREW_TEXT_MAX_CHARS }; const CrewName = NonEmptyString.check( Schema.isMaxLength(CREW_NAME_MAX_CHARS), Schema.isPattern(CREW_NAME_PATTERN), @@ -496,7 +495,7 @@ export const J5StopCrewResult = Schema.Struct({ ), }); -export const J5_STOP_CREW_DESCRIPTION = +const J5_STOP_CREW_DESCRIPTION = "Stop a Crew you command the way a user Stop does, seat by seat: each seat's running turn is interrupted now, turns already queued behind it, messages you sent it included, are held until a person resumes its queue or the next message reaches it (that message resumes the queue and runs after them, in order), its pull request watches end, and the tasks it delegated stop too. Nothing settles or is retired, and every seat can be messaged again afterwards. Captain-only. Reuse client_request_id to retry safely."; export const J5ArchiveResult = Schema.Literals(["archived", "already_archived"]); @@ -557,7 +556,7 @@ export type J5ArchiveCrewFailure = typeof J5ArchiveCrewFailure.Type; export const J5_SPAWN_AGENT_DESCRIPTION = "Spawn a Peer Agent: a full-citizen teammate with its own top-level thread, starting on your brief as its first turn. It joins your project unless you name another with project_id or set scratch for none, and records you as its immutable spawner; in your own project it is placed under you. It is addressable the moment this returns. In your brief, tell the new agent what it should do first and whether it should reply to you. Choose provider, model, and reasoning for the work in the brief; see orchestrator_capabilities for what's available. To run a persona from j5_list_personas, set `persona` to its id: the spawn gets that persona's instructions and runtime policy, and provider, model, and reasoning must be one of that persona's declared routes. Without a persona it runs in your permission and interaction modes, or in narrower ones you set with runtime_mode and interaction_mode. Attach files to the brief with attachments. Choose its workspace every time (see the workspace field). A new worktree is prepared after this returns, and the agent begins once it is bound, possibly while the project's setup script is still running; if preparing it fails, the agent's thread shows why, and it is not retried. Reuse client_request_id to retry the same spawn safely; reusing it with any change to the request is refused, so use a fresh one for new work."; -export const J5_LIST_AGENTS_DESCRIPTION = +const J5_LIST_AGENTS_DESCRIPTION = "List the personas in this environment: id, purpose, runtime policy, whether each can start now, and the provider, model, and reasoning it would run on. Read this before choosing a persona for j5_spawn_agent or a crew roster so the choice fits the task and the user's budget. Read-only."; export const J5_PROPOSE_CREW_DESCRIPTION = @@ -569,7 +568,7 @@ export const J5_REQUEST_CREW_MEMBER_DESCRIPTION = export const J5_STOP_AGENT_DESCRIPTION = "Stop one Peer Agent the way a user Stop does: its running turn is interrupted now, turns already queued behind it, messages you sent it included, are held until a person resumes its queue or the next message reaches it (that message resumes the queue and runs after them, in order), its pull request watches end, and the tasks it delegated stop too. The agent remains, stays readable, and can be messaged again later: stopping halts work, it retires nothing. It reaches any agent on this server, in any project. Reuse client_request_id to retry safely."; -export const J5_ARCHIVE_CREW_DESCRIPTION = +const J5_ARCHIVE_CREW_DESCRIPTION = "Retire a whole Crew you command. Crews archive only as a unit; members are never retired one by one. A clean archive completes immediately; otherwise the call refuses with the facts and a confirmation_token. Before retrying with that token, check with the user. Nothing is destroyed: worktrees, branches, and ledgers stay readable. Reuse client_request_id to retry safely."; // McpToolAccess reads the calling thread before any tool that needs one, so each of those @@ -688,7 +687,7 @@ export const J5SendMessageTool = Tool.make("j5_send_message", { .annotate(Tool.Idempotent, false) .annotate(Tool.OpenWorld, true); -export const J5ListParticipantsTool = Tool.make("j5_list_participants", { +const J5ListParticipantsTool = Tool.make("j5_list_participants", { description: A2A_LIST_TOOL_DESCRIPTION, parameters: J5ListParticipantsInput, success: J5ListParticipantsResult, @@ -745,7 +744,7 @@ export const J5RequestCrewMemberTool = Tool.make("j5_request_crew_member", { .annotate(Tool.Idempotent, false) .annotate(Tool.OpenWorld, true); -export const J5ListAgentsTool = Tool.make("j5_list_personas", { +const J5ListAgentsTool = Tool.make("j5_list_personas", { description: J5_LIST_AGENTS_DESCRIPTION, success: J5ListAgentsResult, failure: J5McpFailure, @@ -772,7 +771,7 @@ export const J5StopAgentTool = Tool.make("j5_stop_agent", { .annotate(Tool.Idempotent, false) .annotate(Tool.OpenWorld, false); -export const J5StopCrewTool = Tool.make("j5_stop_crew", { +const J5StopCrewTool = Tool.make("j5_stop_crew", { description: J5_STOP_CREW_DESCRIPTION, parameters: J5StopCrewInput, success: J5StopCrewResult, @@ -800,7 +799,7 @@ export const J5ArchiveCrewTool = Tool.make("j5_archive_crew", { .annotate(Tool.Idempotent, false) .annotate(Tool.OpenWorld, false); -export const J5ClearOwnAskTool = Tool.make("j5_clear_own_ask", { +const J5ClearOwnAskTool = Tool.make("j5_clear_own_ask", { description: A2A_CLEAR_OWN_ASK_TOOL_DESCRIPTION, parameters: J5ClearOwnAskInput, success: ClearOwnAskResult, diff --git a/apps/server/src/j5/a2a/runtimeLayer.ts b/apps/server/src/j5/a2a/runtimeLayer.ts index 9e39a4953f9de..21b1eb415db28 100644 --- a/apps/server/src/j5/a2a/runtimeLayer.ts +++ b/apps/server/src/j5/a2a/runtimeLayer.ts @@ -76,9 +76,7 @@ const agentCrewProposalLayer = agentCrewProposalNotifyingLayer.pipe( * production provides it once to the V2 runtime (which `ThreadLineage` decorates) and the * authenticated route graph reuses it. */ -export const makeJ5ThreadRegistrationLayer = ( - options: { readonly ledger?: typeof ledgerLayer } = {}, -) => { +const makeJ5ThreadRegistrationLayer = (options: { readonly ledger?: typeof ledgerLayer } = {}) => { const ledgerProvided = options.ledger ?? ledgerLayer; return Layer.merge( threadRegistrationLayer, @@ -112,7 +110,7 @@ const deliveryTransportWithPeers = deliveryTransportLayer.pipe( Layer.provide(peerHttpClient), ); -export const makeJ5A2AAuxiliaryLayer = ( +const makeJ5A2AAuxiliaryLayer = ( options: { readonly deliveryTransport?: typeof deliveryTransportWithPeers; readonly spawnWorkspace?: typeof spawnWorkspaceLayer; diff --git a/apps/server/src/j5/agents/agentPersonaArtifacts.ts b/apps/server/src/j5/agents/agentPersonaArtifacts.ts index e128842c8fac4..60569276f6726 100644 --- a/apps/server/src/j5/agents/agentPersonaArtifacts.ts +++ b/apps/server/src/j5/agents/agentPersonaArtifacts.ts @@ -85,7 +85,7 @@ const GENERIC_TEMPLATE: ReadonlyArray = [ "Open questions, risks, and anything you could not verify.", ]; -export const AGENT_HANDOFF_ROOT = "handoffs"; +const AGENT_HANDOFF_ROOT = "handoffs"; const LEADING_HEX8 = /^[0-9a-f]{8}/i; diff --git a/apps/server/src/j5/agents/agentPersonaOrchestration.ts b/apps/server/src/j5/agents/agentPersonaOrchestration.ts index 03c9ed90b0f07..102cd4865b4ff 100644 --- a/apps/server/src/j5/agents/agentPersonaOrchestration.ts +++ b/apps/server/src/j5/agents/agentPersonaOrchestration.ts @@ -64,7 +64,7 @@ const immutableRoute = (thread: PersonaThread) => `Persona thread ${thread.id} has an immutable model route.`; /** Persona threads keep their launch route; explicit model or provider changes are rejected. */ -export const agentPersonaRouteLockedError = ( +const agentPersonaRouteLockedError = ( thread: PersonaThread, commandType: string, ): string | undefined => @@ -74,7 +74,7 @@ export const agentPersonaRouteLockedError = ( : undefined; /** A message carrying a different model selection than the resolved route is rejected too. */ -export const agentPersonaModelMismatchError = ( +const agentPersonaModelMismatchError = ( thread: PersonaThread, modelSelection: ModelSelection | undefined, ): string | undefined => diff --git a/apps/server/src/j5/agents/agentPersonaRuntime.ts b/apps/server/src/j5/agents/agentPersonaRuntime.ts index aa9984009a2fc..cd315ab489a92 100644 --- a/apps/server/src/j5/agents/agentPersonaRuntime.ts +++ b/apps/server/src/j5/agents/agentPersonaRuntime.ts @@ -70,7 +70,7 @@ export const resolveAgentPersonaRuntime = Effect.fn("resolveAgentPersonaRuntime" }); /** The thread's full runtime policy: persona sandbox and instructions when assigned, the plain mode otherwise. */ -export const resolveAgentPersonaRuntimePolicy = ( +const resolveAgentPersonaRuntimePolicy = ( input: { readonly thread: OrchestrationV2AppThread; readonly cwd: string | null }, library: ReturnType, ) => diff --git a/apps/server/src/j5/analytics/ExchangeAnalytics.ts b/apps/server/src/j5/analytics/ExchangeAnalytics.ts index 2e67701c6a757..29ec5c0a49fe8 100644 --- a/apps/server/src/j5/analytics/ExchangeAnalytics.ts +++ b/apps/server/src/j5/analytics/ExchangeAnalytics.ts @@ -52,62 +52,53 @@ export class ExchangeAnalytics extends Context.Service - Layer.effect( - ExchangeAnalytics, - Effect.gen(function* () { - const analytics = yield* AnalyticsService; - const ledger = yield* A2ALedger; - const sql = yield* SqlClient.SqlClient; +export const layer = Layer.effect( + ExchangeAnalytics, + Effect.gen(function* () { + const analytics = yield* AnalyticsService; + const ledger = yield* A2ALedger; + const sql = yield* SqlClient.SqlClient; - const outcomeOf = Effect.fn("j5.analytics.exchangeOutcome")(function* ( - event: StoredCommEvent, - ) { - if (event.kind === "exchange.dropped") { - const dropped = yield* decodeDropped(event.payload); - return { outcome: dropped.disposition, cause: dropped.cause.kind }; - } - const closed = yield* decodeClosed(event.payload); - return { outcome: "closureKind" in closed ? closed.closureKind : "replied" }; - }); + const outcomeOf = Effect.fn("j5.analytics.exchangeOutcome")(function* (event: StoredCommEvent) { + if (event.kind === "exchange.dropped") { + const dropped = yield* decodeDropped(event.payload); + return { outcome: dropped.disposition, cause: dropped.cause.kind }; + } + const closed = yield* decodeClosed(event.payload); + return { outcome: "closureKind" in closed ? closed.closureKind : "replied" }; + }); - const record = Effect.fn("j5.analytics.exchangeClosed")(function* (event: StoredCommEvent) { - if (event.exchangeId === null) return; - // The ledger projects the Exchange in the commit that wrote this event. - const rows = yield* sql` + const record = Effect.fn("j5.analytics.exchangeClosed")(function* (event: StoredCommEvent) { + if (event.exchangeId === null) return; + // The ledger projects the Exchange in the commit that wrote this event. + const rows = yield* sql` SELECT sender_id, receiver_id, urgency, created_at FROM j5_a2a_exchange WHERE project_id = ${event.projectId} AND exchange_id = ${event.exchangeId} `; - if (rows[0] === undefined) return; - const exchange = yield* decodeExchangeRow(rows[0]); - yield* analytics.record("j5.exchange.closed", { - ...(yield* outcomeOf(event)), - senderKind: participantKind(exchange.sender_id), - receiverKind: participantKind(exchange.receiver_id), - urgency: exchange.urgency ?? "none", - ...durationMsBetween(exchange.created_at, event.createdAt), - }); + if (rows[0] === undefined) return; + const exchange = yield* decodeExchangeRow(rows[0]); + yield* analytics.record("j5.exchange.closed", { + ...(yield* outcomeOf(event)), + senderKind: participantKind(exchange.sender_id), + receiverKind: participantKind(exchange.receiver_id), + urgency: exchange.urgency ?? "none", + ...durationMsBetween(exchange.created_at, event.createdAt), }); + }); - const handleCommitted: ExchangeAnalyticsShape["handleCommitted"] = (event) => - event.kind === "exchange.closed" || event.kind === "exchange.dropped" - ? record(event).pipe( - Effect.catchCause((cause) => - Effect.logWarning("J5 exchange analytics skipped an Exchange", { cause }), - ), - ) - : Effect.void; - - if (daemon) { - const committed = yield* ledger.subscribeCommitted; - yield* committed.pipe(Stream.runForEach(handleCommitted), Effect.forkScoped); - } + const handleCommitted: ExchangeAnalyticsShape["handleCommitted"] = (event) => + event.kind === "exchange.closed" || event.kind === "exchange.dropped" + ? record(event).pipe( + Effect.catchCause((cause) => + Effect.logWarning("J5 exchange analytics skipped an Exchange", { cause }), + ), + ) + : Effect.void; - return ExchangeAnalytics.of({ handleCommitted }); - }), - ); + const committed = yield* ledger.subscribeCommitted; + yield* committed.pipe(Stream.runForEach(handleCommitted), Effect.forkScoped); -/** For tests, which feed `handleCommitted` themselves. */ -export const manualLayer = makeLayer(false); -export const layer = makeLayer(true); + return ExchangeAnalytics.of({ handleCommitted }); + }), +); diff --git a/apps/server/src/j5/artifacts/ArtifactRunFinalizationObserver.ts b/apps/server/src/j5/artifacts/ArtifactRunFinalizationObserver.ts index 1061de5301096..7c00609c67274 100644 --- a/apps/server/src/j5/artifacts/ArtifactRunFinalizationObserver.ts +++ b/apps/server/src/j5/artifacts/ArtifactRunFinalizationObserver.ts @@ -6,7 +6,7 @@ import * as ProjectionStore from "../../orchestration-v2/ProjectionStore.ts"; import * as RunFinalization from "../../orchestration-v2/RunFinalizationService.ts"; import { ArtifactWorkspace } from "./ArtifactWorkspace.ts"; -export function selectCurrentProposedPlan( +function selectCurrentProposedPlan( projection: Pick, runId: RunId, ): Extract | null { diff --git a/apps/server/src/j5/artifacts/ArtifactWorkspace.ts b/apps/server/src/j5/artifacts/ArtifactWorkspace.ts index 767d3bdb8c6a6..d976f8cc6502b 100644 --- a/apps/server/src/j5/artifacts/ArtifactWorkspace.ts +++ b/apps/server/src/j5/artifacts/ArtifactWorkspace.ts @@ -137,7 +137,7 @@ export interface ArtifactVersion { readonly content: string; } -export const artifactVersionedMarker = ( +const artifactVersionedMarker = ( relativePath: string, versions: ReadonlyArray>, ) => @@ -218,7 +218,7 @@ const firstHeading = (content: string) => .find((title): title is string => title !== undefined); /** Render the file from its versions, newest first. */ -export function renderArtifactVersions(input: { +function renderArtifactVersions(input: { readonly relativePath: string; readonly versions: ReadonlyArray; readonly dropped: number; diff --git a/apps/server/src/j5/cli/a2a.ts b/apps/server/src/j5/cli/a2a.ts index ef3e145e2c68c..fca39f85d107c 100644 --- a/apps/server/src/j5/cli/a2a.ts +++ b/apps/server/src/j5/cli/a2a.ts @@ -61,9 +61,9 @@ export const A2A_EXIT_CODES = { } as const; /** Documented ceiling for `--message`; larger payloads belong in a file the agent can read. */ -export const A2A_MAX_MESSAGE_BYTES = 64 * 1024; +const A2A_MAX_MESSAGE_BYTES = 64 * 1024; -export class A2ACliFailure extends Data.TaggedError("A2ACliFailure")<{ +class A2ACliFailure extends Data.TaggedError("A2ACliFailure")<{ readonly exitCode: number; readonly error: string; readonly message: string; diff --git a/apps/server/src/j5/persistence/MigrationSnapshot.ts b/apps/server/src/j5/persistence/MigrationSnapshot.ts index 7348e8f6b214e..89c096e1100f9 100644 --- a/apps/server/src/j5/persistence/MigrationSnapshot.ts +++ b/apps/server/src/j5/persistence/MigrationSnapshot.ts @@ -19,7 +19,7 @@ import { J5_A2A_MIGRATIONS_TABLE, migrationEntries } from "../a2a/Migrations.ts" * is small: three lets a person go back across the last three builds that migrated, at three * times the database's size on disk. */ -export const MIGRATION_SNAPSHOTS_KEPT = 3; +const MIGRATION_SNAPSHOTS_KEPT = 3; const UPSTREAM_MIGRATIONS_TABLE = "effect_sql_migrations"; diff --git a/apps/server/src/j5/playbooks/PlaybookCrewRelay.ts b/apps/server/src/j5/playbooks/PlaybookCrewRelay.ts index 875ae46ea28c3..93f2995674a6b 100644 --- a/apps/server/src/j5/playbooks/PlaybookCrewRelay.ts +++ b/apps/server/src/j5/playbooks/PlaybookCrewRelay.ts @@ -30,7 +30,7 @@ import { * Both layers are wanted: a re-dispatch after a crash replays the command receipt, and the fixed * message id keeps a second copy out of the thread even if a receipt were lost. */ -export const PLAYBOOK_STEP_SESSION = "j5-playbook-step"; +const PLAYBOOK_STEP_SESSION = "j5-playbook-step"; const isPlaybookError = Schema.is(PlaybookError); const operationFailed = (error: unknown) => diff --git a/apps/server/src/j5/playbooks/PlaybookStore.ts b/apps/server/src/j5/playbooks/PlaybookStore.ts index bf85135614157..0adb94c55ae1e 100644 --- a/apps/server/src/j5/playbooks/PlaybookStore.ts +++ b/apps/server/src/j5/playbooks/PlaybookStore.ts @@ -63,7 +63,7 @@ const stepSummary = ({ id, title, persona }: PlaybookStep) => persona === undefined ? { id, title } : { id, title, persona }; /** Warnings for steps whose persona the catalog lacks or has turned off, in step order. */ -export const stepPersonaWarnings = ( +const stepPersonaWarnings = ( steps: ReadonlyArray, catalog: Parameters[0], ): Array => diff --git a/apps/server/src/j5/settlementActivity.ts b/apps/server/src/j5/settlementActivity.ts index ddb0b33d2d46e..98743dd2d9d69 100644 --- a/apps/server/src/j5/settlementActivity.ts +++ b/apps/server/src/j5/settlementActivity.ts @@ -7,7 +7,7 @@ import * as DateTime from "effect/DateTime"; * (`createdBy: "agent"`, `creationSource: "mcp"`): A2A deliveries, briefs, upstream's agent sends. * Not server wakes, system notices, or an agent's scheduled task (`scheduledTaskId`). */ -export const isSettlementActivityMessage = ( +const isSettlementActivityMessage = ( message: Pick< OrchestrationV2ConversationMessage, "role" | "createdBy" | "creationSource" | "scheduledTaskId" diff --git a/apps/server/src/j5/sharing/AccessGate.ts b/apps/server/src/j5/sharing/AccessGate.ts index 451f6f701f1d4..9c91a97f867e9 100644 --- a/apps/server/src/j5/sharing/AccessGate.ts +++ b/apps/server/src/j5/sharing/AccessGate.ts @@ -189,7 +189,7 @@ const narrowedForAll: AccessRpcRule = { kind: "narrowed", unknownToo: true }; * out on purpose: whole-server lists and changes (projects, archive, usage, diagnostics, * PR lists, peers, relay) and Persona and skill writes. */ -export const ACCESS_RPC_RULES: Partial> = { +const ACCESS_RPC_RULES: Partial> = { // A connection cannot start without these; each answers in a reduced form (`GuestView`). [WS_METHODS.serverGetConfig]: narrowedForAll, [WS_METHODS.subscribeServerConfig]: narrowedForAll, diff --git a/apps/server/src/j5/sharing/CommandAdmission.ts b/apps/server/src/j5/sharing/CommandAdmission.ts index 0bb5c135c2179..044c0247803d2 100644 --- a/apps/server/src/j5/sharing/CommandAdmission.ts +++ b/apps/server/src/j5/sharing/CommandAdmission.ts @@ -59,7 +59,7 @@ const onParent = (command: { readonly parentThreadId: ThreadId }): CommandScope * Every command a narrowed Collaborator may send, by type, with where its target is. Keyed by * type so that a command upstream renames or removes fails to compile here. */ -export const NARROWED_COMMAND_SCOPES: { +const NARROWED_COMMAND_SCOPES: { readonly [K in OrchestrationV2Command["type"]]?: (command: CommandOf) => CommandScope; } = { // Starting a thread needs the project (AC14): a Collaborator on one thread starts none. diff --git a/apps/server/src/j5/sharing/GuestProjectIcons.ts b/apps/server/src/j5/sharing/GuestProjectIcons.ts index 2a8e53fdd50d8..22386ff6633f2 100644 --- a/apps/server/src/j5/sharing/GuestProjectIcons.ts +++ b/apps/server/src/j5/sharing/GuestProjectIcons.ts @@ -151,7 +151,7 @@ export const issueGuestProjectIconUrl = ( ); /** How long a guest's icon link works for, as long as upstream's own asset links. */ -export const GUEST_PROJECT_ICON_TTL_MS = 60 * 60 * 1000; +const GUEST_PROJECT_ICON_TTL_MS = 60 * 60 * 1000; /** The project a link's token was signed for, while it is in date; nothing for any other token. */ const projectOfToken = Effect.fn("j5.sharing.guestProjectIcons.projectOfToken")(function* ( diff --git a/apps/server/src/j5/sharing/GuestView.ts b/apps/server/src/j5/sharing/GuestView.ts index cd396840818f6..ada935e7784a7 100644 --- a/apps/server/src/j5/sharing/GuestView.ts +++ b/apps/server/src/j5/sharing/GuestView.ts @@ -151,7 +151,7 @@ const reduceProviders = (providers: ServerConfig["providers"], skillsShown: Skil * The configuration a Viewer's client is given. Built field by field, so a field upstream adds * later is left out until it is listed here. */ -export const reduceServerConfig = ( +const reduceServerConfig = ( config: ServerConfig, skillsShown: SkillsShown = NO_SKILLS, ): ServerConfig => ({ diff --git a/apps/server/src/j5/sharing/LinkHttp.ts b/apps/server/src/j5/sharing/LinkHttp.ts index fd152e2b2d393..530923b32ae00 100644 --- a/apps/server/src/j5/sharing/LinkHttp.ts +++ b/apps/server/src/j5/sharing/LinkHttp.ts @@ -18,7 +18,7 @@ import { Links } from "./Links.ts"; import { PAIRED_AS_SOMEONE_ELSE_REFUSAL } from "./PairingIntents.ts"; /** What someone joining is told when the name they typed is someone else's (AC42, AC44). */ -export const LINK_NAME_TAKEN = +const LINK_NAME_TAKEN = "Someone on this server already has that name. If it is yours, open the link on the device you paired before, or ask for a link for this device."; const decodeDescribe = Schema.decodeUnknownEffect(LinkTokenRequest); diff --git a/apps/server/src/j5/sharing/McpApproval.ts b/apps/server/src/j5/sharing/McpApproval.ts index 6d88e2d384975..3e9894655e3c1 100644 --- a/apps/server/src/j5/sharing/McpApproval.ts +++ b/apps/server/src/j5/sharing/McpApproval.ts @@ -32,7 +32,7 @@ const KEPT_MS = 10 * 60_000; * The approver is read before upstream spends a pairing code: the person the code was made for, * or the person whose browser approves. */ -export const layerGatedMcpOAuth = Layer.effect( +const layerGatedMcpOAuth = Layer.effect( McpOAuth.McpOAuth, Effect.gen(function* () { const inner = yield* McpOAuth.McpOAuth; diff --git a/apps/server/src/j5/sharing/PairingIntents.ts b/apps/server/src/j5/sharing/PairingIntents.ts index d5dfbbbc44483..86a3e72727f10 100644 --- a/apps/server/src/j5/sharing/PairingIntents.ts +++ b/apps/server/src/j5/sharing/PairingIntents.ts @@ -389,8 +389,9 @@ const make: Layer.Layer = - make.pipe(Layer.provide(readChangesLayer)); +const layer: Layer.Layer = make.pipe( + Layer.provide(readChangesLayer), +); /** * People and the record of whose each device is, for upstream's auth layer to be built over: diff --git a/apps/server/src/j5/sharing/PersonAccess.ts b/apps/server/src/j5/sharing/PersonAccess.ts index 206bbd7697f19..876c2d199da50 100644 --- a/apps/server/src/j5/sharing/PersonAccess.ts +++ b/apps/server/src/j5/sharing/PersonAccess.ts @@ -35,7 +35,7 @@ import { ReadChanges, layer as readChangesLayer } from "../a2a/ReadChanges.ts"; * permissions upstream issued it for its purpose. MCP clients are approved only by an Owner, and * lowering or removing an Owner refuses an approval still waiting (`Access.issueMcpClient`). */ -export const isServiceSubject = (subject: string) => +const isServiceSubject = (subject: string) => subject.startsWith("peer:") || subject.startsWith("machine:") || subject === "mcp-client" || diff --git a/apps/server/src/j5/sharing/SharedConversation.ts b/apps/server/src/j5/sharing/SharedConversation.ts index 3562b1989edcc..e2c71cafa407b 100644 --- a/apps/server/src/j5/sharing/SharedConversation.ts +++ b/apps/server/src/j5/sharing/SharedConversation.ts @@ -66,7 +66,7 @@ import { scheduledLine } from "./scheduledRuns.ts"; * first line of the person's own, and their text always follows it, so text a person types to * look like this line, or like a note, sits below their real one. */ -export const authorLine = (author: Author, editedBy: Author | null = null) => +const authorLine = (author: Author, editedBy: Author | null = null) => editedBy === null ? `[Message from ${authorLabel(author)}]` : `[Message from ${authorLabel(author)}, edited by ${authorLabel(editedBy)}]`; @@ -77,7 +77,7 @@ export const authorLine = (author: Author, editedBy: Author | null = null) => * it into a message, on others it goes back as the result of the agent's tool call. Either way * the agent reads the answer's words, so its author goes on the words. */ -export const answerLine = (author: Author) => `[Answer from ${authorLabel(author)}]`; +const answerLine = (author: Author) => `[Answer from ${authorLabel(author)}]`; /** * A question's answers with their author on each: at the start of the text, or of the first @@ -127,7 +127,7 @@ interface AuthorRow { * The event upstream logs when a prompt is answered. Typed against upstream's own event union, so * a rename there fails to compile here. */ -export const PROMPT_SETTLED_EVENT = +const PROMPT_SETTLED_EVENT = "runtime-request.updated" satisfies OrchestrationV2StoredEvent["event"]["type"]; const QUEUED = "queued" satisfies OrchestrationV2Run["status"]; diff --git a/apps/server/src/j5/skills/skillCatalogInstaller.ts b/apps/server/src/j5/skills/skillCatalogInstaller.ts index 403c0a64fe8c9..0f95fa6103a72 100644 --- a/apps/server/src/j5/skills/skillCatalogInstaller.ts +++ b/apps/server/src/j5/skills/skillCatalogInstaller.ts @@ -356,7 +356,7 @@ export async function saveState(stateDir: string, state: CatalogState) { await writeSkillStateAtomically(stateFilePath(stateDir), `${JSON.stringify(state, null, 2)}\n`); } -export function reconcileLinks({ +function reconcileLinks({ result, previousLinks, }: { @@ -382,7 +382,7 @@ export class IncompleteApplyError extends Error { } } -export function toApplyResult({ +function toApplyResult({ explicitGroups, plan, result, diff --git a/apps/server/src/j5/skills/skillLinks.ts b/apps/server/src/j5/skills/skillLinks.ts index 6e1079d5771f5..8e7f7cc5ab326 100644 --- a/apps/server/src/j5/skills/skillLinks.ts +++ b/apps/server/src/j5/skills/skillLinks.ts @@ -239,9 +239,7 @@ async function linkStatus(link: RecordedLink): Promise> { +async function loadManagedSkillLinks(stateDir: string): Promise> { const contents = await NodeFSP.readFile( NodePath.join(stateDir, "skill-links.json"), "utf8", diff --git a/apps/server/src/j5/test-support/threadLaunchHarness.ts b/apps/server/src/j5/test-support/threadLaunchHarness.ts index dd21cb4843090..76a0beabfda27 100644 --- a/apps/server/src/j5/test-support/threadLaunchHarness.ts +++ b/apps/server/src/j5/test-support/threadLaunchHarness.ts @@ -42,7 +42,7 @@ export const modelSelection = { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.1-codex", } as const; -export const project = { +const project = { id: projectId, title: "Project", workspaceRoot: "/repo", diff --git a/apps/server/src/mcp/McpInvocationContext.ts b/apps/server/src/mcp/McpInvocationContext.ts index bd837addbf439..243f5488cd743 100644 --- a/apps/server/src/mcp/McpInvocationContext.ts +++ b/apps/server/src/mcp/McpInvocationContext.ts @@ -12,7 +12,7 @@ import * as Context from "effect/Context"; import * as Effect from "effect/Effect"; import * as Fiber from "effect/Fiber"; -export const ALL_MCP_CAPABILITIES = [ +const ALL_MCP_CAPABILITIES = [ "preview", "orchestration", "worktree", diff --git a/apps/server/src/mcp/toolkits/artifacts/tools.ts b/apps/server/src/mcp/toolkits/artifacts/tools.ts index 466ae7ee6ec0a..c759f41b1b250 100644 --- a/apps/server/src/mcp/toolkits/artifacts/tools.ts +++ b/apps/server/src/mcp/toolkits/artifacts/tools.ts @@ -23,7 +23,7 @@ const dependencies = [ /** An artifact refusal, or McpToolAccess's refusal of a caller that is not a live thread. */ const failure = Schema.Union([ArtifactMcpFailure, OrchestratorMcpFailure]); -export const ListArtifactsTool = Tool.make("j5_list_artifacts", { +const ListArtifactsTool = Tool.make("j5_list_artifacts", { description: "List durable planning artifacts shared by every thread and agent in the current project.", success: ArtifactListResponse, @@ -36,7 +36,7 @@ export const ListArtifactsTool = Tool.make("j5_list_artifacts", { .annotate(Tool.Destructive, false) .annotate(Tool.Idempotent, true); -export const ReadArtifactTool = Tool.make("j5_read_artifact", { +const ReadArtifactTool = Tool.make("j5_read_artifact", { description: "Read one project artifact by its path relative to artifacts/, such as plan.md or diagrams/flow.svg.", parameters: ArtifactReadInput, @@ -50,7 +50,7 @@ export const ReadArtifactTool = Tool.make("j5_read_artifact", { .annotate(Tool.Destructive, false) .annotate(Tool.Idempotent, true); -export const WriteArtifactTool = Tool.make("j5_write_artifact", { +const WriteArtifactTool = Tool.make("j5_write_artifact", { description: "Create or replace a durable, user-consumable planning artifact shared across the current project's threads and agents. Use this for plans, specifications, diagrams, and research notes (not source code, build output, logs, scratch files, or ordinary repository documentation). The path is relative to artifacts/ and content must be UTF-8 text; HTML, Markdown, Mermaid, and SVG are supported. Paths under handoffs/ keep history: writing an existing handoff adds your content as a new version at the top of the same file instead of replacing it, so j5_read_artifact on such a path returns a versions header followed by every kept version, newest first.", parameters: ArtifactWriteInput, diff --git a/apps/server/src/orchestration-v2/ThreadLaunchService.ts b/apps/server/src/orchestration-v2/ThreadLaunchService.ts index 1bbc77c9b33ce..e7993696dbb0f 100644 --- a/apps/server/src/orchestration-v2/ThreadLaunchService.ts +++ b/apps/server/src/orchestration-v2/ThreadLaunchService.ts @@ -204,7 +204,7 @@ function failureDetail(error: unknown): string { return `Workspace preparation failed: ${error instanceof Error ? error.message : String(error)}`; } -export const make = Effect.gen(function* () { +const make = Effect.gen(function* () { const personaLibrary = yield* makeAgentPersonaLibrary; const projects = yield* ProjectService.ProjectService; const setupTracker = yield* WorktreeSetupTracker.WorktreeSetupTracker; diff --git a/apps/web/src/j5/a2a/HumanInboxPage.tsx b/apps/web/src/j5/a2a/HumanInboxPage.tsx index 1b8f6ba0c199f..0ebbf09a1f344 100644 --- a/apps/web/src/j5/a2a/HumanInboxPage.tsx +++ b/apps/web/src/j5/a2a/HumanInboxPage.tsx @@ -451,7 +451,7 @@ function AnsweredBy({ item }: { readonly item: HumanInboxItem }) { return line === null ? null : <> · {line}; } -export async function refreshHumanInboxes(environmentId?: EnvironmentId, force = false) { +async function refreshHumanInboxes(environmentId?: EnvironmentId, force = false) { const options = { force, ...(environmentId === undefined ? {} : { environmentId }) }; const results = await Promise.all([ refreshJ5Sources(openInboxSourcesAtom, openInboxQueryAtom, options), diff --git a/apps/web/src/j5/agents/agentDraftState.ts b/apps/web/src/j5/agents/agentDraftState.ts index 65f9de624c9fd..927ed90242746 100644 --- a/apps/web/src/j5/agents/agentDraftState.ts +++ b/apps/web/src/j5/agents/agentDraftState.ts @@ -24,8 +24,7 @@ export const selectDraftAgent = (draftKey: string, personaId: string | null) => export const clearDraftAgent = (draftKey: string) => selectDraftAgent(draftKey, null); -export const readDraftAgentPersonaId = (draftKey: string): string | null => - snapshot[draftKey] ?? null; +const readDraftAgentPersonaId = (draftKey: string): string | null => snapshot[draftKey] ?? null; export function useDraftAgentPersonaId(draftKey: string | null): string | null { return useSyncExternalStore(subscribe, () => diff --git a/apps/web/src/j5/fleet/fleet.logic.ts b/apps/web/src/j5/fleet/fleet.logic.ts index bfa869b3c0a89..c90f934569357 100644 --- a/apps/web/src/j5/fleet/fleet.logic.ts +++ b/apps/web/src/j5/fleet/fleet.logic.ts @@ -176,7 +176,7 @@ export interface FleetSections { +function* fleetNodeAgents(node: FleetNode): Generator { yield node.row.agent; for (const crew of node.crews) for (const member of crew.members) yield* fleetNodeAgents(member); for (const child of node.children) yield* fleetNodeAgents(child); @@ -188,7 +188,7 @@ export function* fleetNodeAgents(node: FleetNode): Generator { * and an agent the client cannot see is not assumed done. Idle is not settled; nothing is inferred * from silence. */ -export const isSettledFleetNode = ( +const isSettledFleetNode = ( node: FleetNode, classify: (agent: FleetAgent) => CrewSeatState, ): boolean => { diff --git a/apps/web/src/j5/highlights/seenHighlights.ts b/apps/web/src/j5/highlights/seenHighlights.ts index 1b9bb20caba84..1bc29b55a0b9e 100644 --- a/apps/web/src/j5/highlights/seenHighlights.ts +++ b/apps/web/src/j5/highlights/seenHighlights.ts @@ -12,7 +12,7 @@ import { isElectron } from "../../env"; // unseenHighlights reads that as "show everything" once first run is finished. const KEY = "j5:highlights:seen"; -export const highlightClient = isElectron ? "desktop" : "web"; +const highlightClient = isElectron ? "desktop" : "web"; export const clientHighlights = highlightsForClient(HIGHLIGHTS, highlightClient); const listeners = new Set<() => void>(); diff --git a/apps/web/src/j5/logicalProjects.ts b/apps/web/src/j5/logicalProjects.ts index 8de6afaa411ae..785785ef38e5a 100644 --- a/apps/web/src/j5/logicalProjects.ts +++ b/apps/web/src/j5/logicalProjects.ts @@ -21,7 +21,7 @@ export interface LogicalProjectGroup { * Returns undefined while the project has not loaded or when it is gone, so the caller can fall * back to the title the read carries. */ -export function createLogicalProjectLookup( +function createLogicalProjectLookup( groups: ReadonlyArray, ) { const groupByProject = new Map(); diff --git a/apps/web/src/j5/notifications/completionSound.ts b/apps/web/src/j5/notifications/completionSound.ts index 65c8fe886b224..2d6b0ef4f6cf2 100644 --- a/apps/web/src/j5/notifications/completionSound.ts +++ b/apps/web/src/j5/notifications/completionSound.ts @@ -1,7 +1,7 @@ import { completionSoundStorage, type CompletionSound } from "./completionSoundStorage"; export const COMPLETION_SOUND_MAX_BYTES = 5 * 1024 * 1024; -export const COMPLETION_SOUND_MAX_SECONDS = 30; +const COMPLETION_SOUND_MAX_SECONDS = 30; export async function validateCompletionSound( file: File, diff --git a/apps/web/src/j5/sharing/PersonAvatar.tsx b/apps/web/src/j5/sharing/PersonAvatar.tsx index 902c7cb184ec0..630448934eca7 100644 --- a/apps/web/src/j5/sharing/PersonAvatar.tsx +++ b/apps/web/src/j5/sharing/PersonAvatar.tsx @@ -7,7 +7,7 @@ const SWATCHES = PROJECT_ICON_COLORS.filter((color) => color.value !== "gray").m ); /** The same name is always the same colour, on every client. */ -export function avatarSwatch(name: string): string { +function avatarSwatch(name: string): string { let hash = 0; for (const char of name.trim().toLowerCase()) hash = (hash * 31 + char.codePointAt(0)!) | 0; return SWATCHES[Math.abs(hash) % SWATCHES.length]!; diff --git a/apps/web/src/j5/sharing/ShareLinkPanel.tsx b/apps/web/src/j5/sharing/ShareLinkPanel.tsx index 1b90db7feffe5..0de4502918453 100644 --- a/apps/web/src/j5/sharing/ShareLinkPanel.tsx +++ b/apps/web/src/j5/sharing/ShareLinkPanel.tsx @@ -34,7 +34,7 @@ import { * server advertises; any other client knows only the one it reached the server at. Nothing is * opened to make a link work (People and access AC38). */ -export function useLinkRoutes(environmentId: EnvironmentId): ReadonlyArray { +function useLinkRoutes(environmentId: EnvironmentId): ReadonlyArray { const primaryEnvironmentId = usePrimaryEnvironmentId(); const advertised = useEnvironmentQuery( isElectron && environmentId === primaryEnvironmentId ? desktopNetworkAccessStateAtom : null, diff --git a/apps/web/src/j5/sharing/access.ts b/apps/web/src/j5/sharing/access.ts index 4cf7241784a4d..0e62c64ddb446 100644 --- a/apps/web/src/j5/sharing/access.ts +++ b/apps/web/src/j5/sharing/access.ts @@ -71,7 +71,7 @@ export function useSettledConnectionAccess(environmentId: EnvironmentId | null): const NO_LEVEL = Atom.make(null); /** The level this connection's person holds over a thread; `null` for none or not yet known. */ -export function useThreadLevel( +function useThreadLevel( environmentId: EnvironmentId | null, threadId: ThreadId | null, ): PersonLevel | null { @@ -321,11 +321,6 @@ export function useIsOwnerSomewhere(): boolean { return useOwnerSomewhere() !== false; } -/** Whether the person owns this server; see `useOwnedEnvironmentIds`. */ -export function useIsOwner(environmentId: EnvironmentId | null): boolean { - return isOwnerAccess(useConnectionAccess(environmentId)) && environmentId !== null; -} - /** What J5's Skills page says to someone who owns no connected server. */ export const SKILLS_FOR_OWNERS = "Skills are managed by a server's Owners."; diff --git a/apps/web/src/j5/sharing/sharedTimeline.logic.ts b/apps/web/src/j5/sharing/sharedTimeline.logic.ts index e5319fd2ae14d..12e7430ec6370 100644 --- a/apps/web/src/j5/sharing/sharedTimeline.logic.ts +++ b/apps/web/src/j5/sharing/sharedTimeline.logic.ts @@ -107,7 +107,7 @@ export function isSettledPrompt(toolData: unknown): toolData is { * start of the first of the options someone chose. Any other value, and any value that does not * begin with the mark, is returned as it is. */ -export function answerWithoutPrefix(answer: unknown, storedPrefix: string): unknown { +function answerWithoutPrefix(answer: unknown, storedPrefix: string): unknown { if (storedPrefix === "") return answer; const strip = (text: string) => text.startsWith(storedPrefix) ? text.slice(storedPrefix.length) : text; diff --git a/apps/web/src/j5/skills/SkillLinksPanel.tsx b/apps/web/src/j5/skills/SkillLinksPanel.tsx index 7766a888696d7..77be1194be3bc 100644 --- a/apps/web/src/j5/skills/SkillLinksPanel.tsx +++ b/apps/web/src/j5/skills/SkillLinksPanel.tsx @@ -206,7 +206,7 @@ export function SkillLinksPanel(props: Props) { ); } -export function LinkSkillDialog( +function LinkSkillDialog( props: Props & { readonly selection: SkillLinkSelection; readonly onLinked: (message: string) => void; diff --git a/apps/web/src/j5/threads/useThreadRowReads.ts b/apps/web/src/j5/threads/useThreadRowReads.ts index d9644ee495c35..069425b32b8b1 100644 --- a/apps/web/src/j5/threads/useThreadRowReads.ts +++ b/apps/web/src/j5/threads/useThreadRowReads.ts @@ -17,7 +17,7 @@ import { requestSpawnedChildren } from "./SpawnedChildrenClient"; * known: these reads are the server's own (People and access AC23), and the server refuses them. * Nothing waits for that answer, so everyone else's rows are read at once. */ -export const threadReadConnectionsAtom = Atom.make((get) => { +const threadReadConnectionsAtom = Atom.make((get) => { const connections = new Map(); for (const id of get(environmentCatalog.catalogValueAtom).entries.keys()) { const state = Option.getOrNull(AsyncResult.value(get(environmentCatalog.stateAtom(id)))); diff --git a/apps/web/src/rightPanelStore.ts b/apps/web/src/rightPanelStore.ts index e2c61fb4f309e..5f60f1cd0c933 100644 --- a/apps/web/src/rightPanelStore.ts +++ b/apps/web/src/rightPanelStore.ts @@ -12,7 +12,7 @@ import { resolveStorage } from "./lib/storage"; import type { ThreadPanelPresentation } from "./rightPanelLayout"; import type { ChatFileAttachment } from "./types"; -export const RIGHT_PANEL_KINDS = [ +const RIGHT_PANEL_KINDS = [ "artifacts", "diff", "files", diff --git a/knip.jsonc b/knip.jsonc index ab2c0b96c8ecd..c7c05abe5448b 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -4,6 +4,18 @@ "rules": { "types": "off", "nsTypes": "off" }, // These executables are supplied by the OS or installed separately from npm. "ignoreBinaries": ["eas", "file", "mkfifo", "pkill", "pkg-config", "plutil", "sips"], + // J5: upstream code whose only callers J5 removed or replaced. Left as upstream wrote it so + // advances merge cleanly (FORK.md case 94). + "ignoreFiles": [ + "apps/mobile/src/components/T3Wordmark.tsx", + "apps/web/src/components/T3Wordmark.tsx", + ], + "ignoreIssues": { + "apps/server/src/cli/thread.ts": ["exports"], + "apps/web/src/hostedPairing.ts": ["exports"], + "apps/web/src/state/npmRelease.ts": ["exports"], + "packages/shared/src/t3ProjectFile.ts": ["exports"], + }, "workspaces": { ".": { // Keep vendored reference repositories outside the root project. @@ -25,6 +37,8 @@ "entry": [ // These fixture scripts are injected into a browser page by path. "fixtures/*/*.js", + // J5: run by hand with node. + "j5/migrate-codex-fixtures.mjs", "knip-schemas.ts", "mobile-native-client.ts", "setup-worktree.ts", @@ -48,6 +62,9 @@ "scripts/update-test-shard-weights.ts", "scripts/verify-background-live.ts", "src/provider/testFixtures/*.mjs", + // J5: scripts/j5/*.sh run these by path. + "src/j5/fleet-load.ts", + "src/j5/a2a/test-support/devDeliverySeedRunner.ts", // graphqlgen reads its config. "graphql.config.ts", ], diff --git a/packages/client-runtime/src/j5/agentPersonas.ts b/packages/client-runtime/src/j5/agentPersonas.ts index 033a79b3c6a15..e98bd97778021 100644 --- a/packages/client-runtime/src/j5/agentPersonas.ts +++ b/packages/client-runtime/src/j5/agentPersonas.ts @@ -203,7 +203,7 @@ const ROUTE_FAILURE_TEXT: Readonly> }; /** "Primary · Codex gpt-5.6-terra: model is not offered…" for each rejected route. */ -export function agentPersonaBlockedReasons( +function agentPersonaBlockedReasons( attempts: ReadonlyArray, ): ReadonlyArray { return attempts.map((attempt) => { @@ -358,7 +358,7 @@ export async function importAgentPersonasWithConfirmation( export const AGENT_PERSONA_IMPORT_CONFIRMATION_MESSAGE = "Turn off agents you don’t want to replace."; -export const AGENT_PERSONA_ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/; +const AGENT_PERSONA_ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/; /** Suggest a stable ID from a display name: lowercase, hyphenated, starting with a letter. */ export function agentPersonaIdFromName(name: string): string { diff --git a/packages/client-runtime/src/j5/playbooks.ts b/packages/client-runtime/src/j5/playbooks.ts index b77d49f6305ee..083238903eecc 100644 --- a/packages/client-runtime/src/j5/playbooks.ts +++ b/packages/client-runtime/src/j5/playbooks.ts @@ -24,8 +24,8 @@ import { defaultAgentPersonaModelRoute } from "./agentPersonas.ts"; import type { StartThreadTurnInput } from "../operations/commands.ts"; import type { EnvironmentProject, EnvironmentThreadShell } from "../state/shell.ts"; -export const PLAYBOOK_AUTHOR_ID = "playbook-author"; -export const PLAYBOOK_AUTHOR_INSTRUCTIONS = `You are Playbook Author. Help the user turn a repeatable task into a small, clear agent-led playbook shared across this environment. +const PLAYBOOK_AUTHOR_ID = "playbook-author"; +const PLAYBOOK_AUTHOR_INSTRUCTIONS = `You are Playbook Author. Help the user turn a repeatable task into a small, clear agent-led playbook shared across this environment. 1. Start by asking what the playbook should accomplish. Clarify the desired result, inputs, constraints, and evidence of success one focused question at a time. Use details already provided instead of asking again. 2. Inspect existing definitions with j5_playbook_list and j5_playbook_read, and relevant workspace guidance. Propose the smallest useful sequence of steps, then write or refine the definition once the user's intent is clear. Ask before replacing an unrelated existing definition; preserve stable step IDs when editing. @@ -253,7 +253,7 @@ type PlaybookSuggestionInput = { name: string; title: string; issue: { message: type PlaybookTriggerRange = { rangeStart: number; rangeEnd: number }; /** `@playbook:` and `/playbook` share one trigger kind; the text at `rangeStart` tells them apart. */ -export const isPlaybookMention = (text: string, trigger: PlaybookTriggerRange) => +const isPlaybookMention = (text: string, trigger: PlaybookTriggerRange) => text.startsWith(PLAYBOOK_MENTION_PREFIX, trigger.rangeStart); /** diff --git a/packages/client-runtime/src/j5/scopedThreadReadStore.ts b/packages/client-runtime/src/j5/scopedThreadReadStore.ts index 63487e4ce3618..706d322e135fa 100644 --- a/packages/client-runtime/src/j5/scopedThreadReadStore.ts +++ b/packages/client-runtime/src/j5/scopedThreadReadStore.ts @@ -16,7 +16,7 @@ interface EnvironmentReads { } /** Every J5 per-thread read caps a request at 500 ids; batches stay well under it. */ -export const THREAD_READ_BATCH_SIZE = 200; +const THREAD_READ_BATCH_SIZE = 200; /** * A per-thread read model filled by batched reads per environment; a read from a replaced diff --git a/packages/client-runtime/src/j5/sharing.ts b/packages/client-runtime/src/j5/sharing.ts index e42bbd1714e04..f653638ce9685 100644 --- a/packages/client-runtime/src/j5/sharing.ts +++ b/packages/client-runtime/src/j5/sharing.ts @@ -29,7 +29,7 @@ import { export type KnownConnectionAccess = ConnectionAccess | null; /** The level the person holds at server scope, if any. */ -export const serverLevelOf = (access: KnownConnectionAccess): PersonLevel | null => +const serverLevelOf = (access: KnownConnectionAccess): PersonLevel | null => access?.kind === "person" ? highestLevel( access.levels.flatMap((held) => (held.scope.kind === "server" ? [held.level] : [])), diff --git a/packages/client-runtime/src/j5/userMessagePresentation.ts b/packages/client-runtime/src/j5/userMessagePresentation.ts index 8658f71201fa8..ec421f3ef0191 100644 --- a/packages/client-runtime/src/j5/userMessagePresentation.ts +++ b/packages/client-runtime/src/j5/userMessagePresentation.ts @@ -112,7 +112,7 @@ const SPAWN_BRIEF_MESSAGE_ID_PATTERN = /^message:j5:a2a:mcp:[^:]+:spawn-brief:/; export const isJ5DeliveryMessage = (message: J5UserMessageInput) => message.role === "user" && String(message.id ?? "").startsWith(J5_A2A_DELIVERY_MESSAGE_PREFIX); -export const isJ5SpawnBriefMessage = (message: J5UserMessageInput) => +const isJ5SpawnBriefMessage = (message: J5UserMessageInput) => message.role === "user" && SPAWN_BRIEF_MESSAGE_ID_PATTERN.test(String(message.id ?? "")); // J5's tools gained a `j5_` prefix. Stored deliveries keep the name they were written with, so diff --git a/packages/contracts/src/j5.ts b/packages/contracts/src/j5.ts index 897e8af538337..f818b6c637713 100644 --- a/packages/contracts/src/j5.ts +++ b/packages/contracts/src/j5.ts @@ -1157,7 +1157,7 @@ export const OpenInboxCountRequest = Schema.Struct({}); export type OpenInboxCountRequest = typeof OpenInboxCountRequest.Type; /** The sidebar asks about the rows it shows, in batches no larger than this. */ -export const THREAD_HOME_READ_MAX_THREADS = 500; +const THREAD_HOME_READ_MAX_THREADS = 500; export const ThreadHomesRequest = Schema.Struct({ threadIds: Schema.Array(ThreadId).check(Schema.isMaxLength(THREAD_HOME_READ_MAX_THREADS)), }); diff --git a/packages/contracts/src/j5/agentPersona.ts b/packages/contracts/src/j5/agentPersona.ts index 4fcd0a7fe820c..2890935c5d0d4 100644 --- a/packages/contracts/src/j5/agentPersona.ts +++ b/packages/contracts/src/j5/agentPersona.ts @@ -190,7 +190,7 @@ export const AgentPersonaEditableDetails = Schema.Struct({ definitionDigest: Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/)), modelRoute: Schema.Tuple([AgentPersonaModelTarget, AgentPersonaModelTarget]), }); -export const AGENT_PERSONA_INSTRUCTIONS_MAX_LENGTH = 32768; +const AGENT_PERSONA_INSTRUCTIONS_MAX_LENGTH = 32768; const AgentPersonaInstructions = Schema.String.check( Schema.isMinLength(1), Schema.isMaxLength(AGENT_PERSONA_INSTRUCTIONS_MAX_LENGTH), @@ -378,7 +378,7 @@ export const AgentPersonaLibrarySources = Schema.Struct({ folders: Schema.Array(AgentPersonaLibraryFolder), }); export type AgentPersonaLibrarySources = typeof AgentPersonaLibrarySources.Type; -export const AGENT_PERSONA_LIBRARY_MAX_FOLDERS = 32; +const AGENT_PERSONA_LIBRARY_MAX_FOLDERS = 32; export const AgentPersonaLibraryFoldersInput = Schema.Struct({ folders: Schema.Array(TrimmedNonEmptyString.check(Schema.isMaxLength(4096))).check( Schema.isMaxLength(AGENT_PERSONA_LIBRARY_MAX_FOLDERS), @@ -530,27 +530,21 @@ export const J5AgentPersonaRpcSchemas = { const catalogErrors = Schema.Union([EnvironmentAuthorizationError, AgentPersonaCatalogError]); -export const WsJ5GetAgentPersonaCatalogRpc = Rpc.make( - J5_AGENT_PERSONA_WS_METHODS.getAgentPersonaCatalog, - { - payload: J5AgentPersonaRpcSchemas.getAgentPersonaCatalog.input, - success: J5AgentPersonaRpcSchemas.getAgentPersonaCatalog.output, - error: catalogErrors, - }, -); -export const WsJ5ImportAgentPersonasRpc = Rpc.make( - J5_AGENT_PERSONA_WS_METHODS.importAgentPersonas, - { - payload: J5AgentPersonaRpcSchemas.importAgentPersonas.input, - success: J5AgentPersonaRpcSchemas.importAgentPersonas.output, - error: Schema.Union([ - EnvironmentAuthorizationError, - AgentPersonaCatalogError, - AgentPersonaImportConflictError, - ]), - }, -); -export const WsJ5ListAgentPersonaImportFilesRpc = Rpc.make( +const WsJ5GetAgentPersonaCatalogRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.getAgentPersonaCatalog, { + payload: J5AgentPersonaRpcSchemas.getAgentPersonaCatalog.input, + success: J5AgentPersonaRpcSchemas.getAgentPersonaCatalog.output, + error: catalogErrors, +}); +const WsJ5ImportAgentPersonasRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.importAgentPersonas, { + payload: J5AgentPersonaRpcSchemas.importAgentPersonas.input, + success: J5AgentPersonaRpcSchemas.importAgentPersonas.output, + error: Schema.Union([ + EnvironmentAuthorizationError, + AgentPersonaCatalogError, + AgentPersonaImportConflictError, + ]), +}); +const WsJ5ListAgentPersonaImportFilesRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.listAgentPersonaImportFiles, { payload: J5AgentPersonaRpcSchemas.listAgentPersonaImportFiles.input, @@ -558,7 +552,7 @@ export const WsJ5ListAgentPersonaImportFilesRpc = Rpc.make( error: catalogErrors, }, ); -export const WsJ5ReadAgentPersonaImportFilesRpc = Rpc.make( +const WsJ5ReadAgentPersonaImportFilesRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.readAgentPersonaImportFiles, { payload: J5AgentPersonaRpcSchemas.readAgentPersonaImportFiles.input, @@ -566,7 +560,7 @@ export const WsJ5ReadAgentPersonaImportFilesRpc = Rpc.make( error: catalogErrors, }, ); -export const WsJ5EditImportedAgentPersonaRpc = Rpc.make( +const WsJ5EditImportedAgentPersonaRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.editImportedAgentPersona, { payload: J5AgentPersonaRpcSchemas.editImportedAgentPersona.input, @@ -574,7 +568,7 @@ export const WsJ5EditImportedAgentPersonaRpc = Rpc.make( error: catalogErrors, }, ); -export const WsJ5SetImportedAgentPersonaEnabledRpc = Rpc.make( +const WsJ5SetImportedAgentPersonaEnabledRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.setImportedAgentPersonaEnabled, { payload: J5AgentPersonaRpcSchemas.setImportedAgentPersonaEnabled.input, @@ -582,7 +576,7 @@ export const WsJ5SetImportedAgentPersonaEnabledRpc = Rpc.make( error: catalogErrors, }, ); -export const WsJ5RemoveImportedAgentPersonaRpc = Rpc.make( +const WsJ5RemoveImportedAgentPersonaRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.removeImportedAgentPersona, { payload: J5AgentPersonaRpcSchemas.removeImportedAgentPersona.input, @@ -590,7 +584,7 @@ export const WsJ5RemoveImportedAgentPersonaRpc = Rpc.make( error: catalogErrors, }, ); -export const WsJ5RemoveSourceAgentPersonaRpc = Rpc.make( +const WsJ5RemoveSourceAgentPersonaRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.removeSourceAgentPersona, { payload: J5AgentPersonaRpcSchemas.removeSourceAgentPersona.input, @@ -598,12 +592,12 @@ export const WsJ5RemoveSourceAgentPersonaRpc = Rpc.make( error: catalogErrors, }, ); -export const WsJ5RemoveAgentPersonaRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.removeAgentPersona, { +const WsJ5RemoveAgentPersonaRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.removeAgentPersona, { payload: J5AgentPersonaRpcSchemas.removeAgentPersona.input, success: J5AgentPersonaRpcSchemas.removeAgentPersona.output, error: catalogErrors, }); -export const WsJ5RestoreSourceAgentPersonaRpc = Rpc.make( +const WsJ5RestoreSourceAgentPersonaRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.restoreSourceAgentPersona, { payload: J5AgentPersonaRpcSchemas.restoreSourceAgentPersona.input, @@ -612,28 +606,25 @@ export const WsJ5RestoreSourceAgentPersonaRpc = Rpc.make( }, ); -export const WsJ5CreateAgentPersonaRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.createAgentPersona, { +const WsJ5CreateAgentPersonaRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.createAgentPersona, { payload: J5AgentPersonaRpcSchemas.createAgentPersona.input, success: J5AgentPersonaRpcSchemas.createAgentPersona.output, error: catalogErrors, }); -export const WsJ5ReadAgentPersonaRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.readAgentPersona, { +const WsJ5ReadAgentPersonaRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.readAgentPersona, { payload: J5AgentPersonaRpcSchemas.readAgentPersona.input, success: J5AgentPersonaRpcSchemas.readAgentPersona.output, error: catalogErrors, }); -export const WsJ5GetAgentPersonaUsageRpc = Rpc.make( - J5_AGENT_PERSONA_WS_METHODS.getAgentPersonaUsage, - { - payload: J5AgentPersonaRpcSchemas.getAgentPersonaUsage.input, - success: J5AgentPersonaRpcSchemas.getAgentPersonaUsage.output, - error: catalogErrors, - }, -); +const WsJ5GetAgentPersonaUsageRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.getAgentPersonaUsage, { + payload: J5AgentPersonaRpcSchemas.getAgentPersonaUsage.input, + success: J5AgentPersonaRpcSchemas.getAgentPersonaUsage.output, + error: catalogErrors, +}); -export const WsJ5GetAgentPersonaLibrarySourcesRpc = Rpc.make( +const WsJ5GetAgentPersonaLibrarySourcesRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.getAgentPersonaLibrarySources, { payload: J5AgentPersonaRpcSchemas.getAgentPersonaLibrarySources.input, @@ -642,7 +633,7 @@ export const WsJ5GetAgentPersonaLibrarySourcesRpc = Rpc.make( }, ); -export const WsJ5SetAgentPersonaLibraryFoldersRpc = Rpc.make( +const WsJ5SetAgentPersonaLibraryFoldersRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.setAgentPersonaLibraryFolders, { payload: J5AgentPersonaRpcSchemas.setAgentPersonaLibraryFolders.input, @@ -651,22 +642,19 @@ export const WsJ5SetAgentPersonaLibraryFoldersRpc = Rpc.make( }, ); -export const WsJ5SetAgentPersonaEnabledRpc = Rpc.make( - J5_AGENT_PERSONA_WS_METHODS.setAgentPersonaEnabled, - { - payload: J5AgentPersonaRpcSchemas.setAgentPersonaEnabled.input, - success: J5AgentPersonaRpcSchemas.setAgentPersonaEnabled.output, - error: catalogErrors, - }, -); +const WsJ5SetAgentPersonaEnabledRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.setAgentPersonaEnabled, { + payload: J5AgentPersonaRpcSchemas.setAgentPersonaEnabled.input, + success: J5AgentPersonaRpcSchemas.setAgentPersonaEnabled.output, + error: catalogErrors, +}); -export const WsJ5GetAgentHandoffsRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.getAgentHandoffs, { +const WsJ5GetAgentHandoffsRpc = Rpc.make(J5_AGENT_PERSONA_WS_METHODS.getAgentHandoffs, { payload: J5AgentPersonaRpcSchemas.getAgentHandoffs.input, success: J5AgentPersonaRpcSchemas.getAgentHandoffs.output, error: catalogErrors, }); -export const WsJ5SubscribeAgentHandoffRefreshesRpc = Rpc.make( +const WsJ5SubscribeAgentHandoffRefreshesRpc = Rpc.make( J5_AGENT_PERSONA_WS_METHODS.subscribeAgentHandoffRefreshes, { payload: J5AgentPersonaRpcSchemas.subscribeAgentHandoffRefreshes.input, diff --git a/packages/contracts/src/j5/artifacts.ts b/packages/contracts/src/j5/artifacts.ts index 6b0aadd6fbf65..87f17046f0ac7 100644 --- a/packages/contracts/src/j5/artifacts.ts +++ b/packages/contracts/src/j5/artifacts.ts @@ -36,15 +36,12 @@ export const J5_ARTIFACT_WS_METHODS = { deleteAllArtifacts: "j5.artifacts.deleteAll", } as const; -export const WsJ5SubscribeArtifactChangesRpc = Rpc.make( - J5_ARTIFACT_WS_METHODS.subscribeArtifactChanges, - { - payload: ArtifactWatchInput, - success: ArtifactChangeEvent, - error: Schema.Union([ArtifactWatchError, EnvironmentAuthorizationError]), - stream: true, - }, -); +const WsJ5SubscribeArtifactChangesRpc = Rpc.make(J5_ARTIFACT_WS_METHODS.subscribeArtifactChanges, { + payload: ArtifactWatchInput, + success: ArtifactChangeEvent, + error: Schema.Union([ArtifactWatchError, EnvironmentAuthorizationError]), + stream: true, +}); export const J5ArtifactRpcGroup = RpcGroup.make( WsJ5SubscribeArtifactChangesRpc, diff --git a/packages/contracts/src/j5/peerPoll.ts b/packages/contracts/src/j5/peerPoll.ts index cd57c5694acc9..54d3a57a21468 100644 --- a/packages/contracts/src/j5/peerPoll.ts +++ b/packages/contracts/src/j5/peerPoll.ts @@ -4,7 +4,7 @@ * runs, so a peer is online while it polled within this window, and offline * since its last poll after that. */ -export const PEER_ONLINE_WINDOW_MS = 2 * 60_000; +const PEER_ONLINE_WINDOW_MS = 2 * 60_000; /** Online, offline since, or never polled, for a peer in poll mode; null for one that sends directly. */ export const peerPollState = ( diff --git a/packages/contracts/src/j5/skillCatalog.ts b/packages/contracts/src/j5/skillCatalog.ts index 27d69ae15fd26..e7e4aaace94e6 100644 --- a/packages/contracts/src/j5/skillCatalog.ts +++ b/packages/contracts/src/j5/skillCatalog.ts @@ -127,16 +127,13 @@ export const J5SkillCatalogRpcSchemas = { const skillCatalogErrors = Schema.Union([EnvironmentAuthorizationError, SkillCatalogError]); -export const WsJ5GetSkillCatalogStatusRpc = Rpc.make( - J5_SKILL_CATALOG_WS_METHODS.getSkillCatalogStatus, - { - payload: J5SkillCatalogRpcSchemas.getSkillCatalogStatus.input, - success: J5SkillCatalogRpcSchemas.getSkillCatalogStatus.output, - error: skillCatalogErrors, - }, -); +const WsJ5GetSkillCatalogStatusRpc = Rpc.make(J5_SKILL_CATALOG_WS_METHODS.getSkillCatalogStatus, { + payload: J5SkillCatalogRpcSchemas.getSkillCatalogStatus.input, + success: J5SkillCatalogRpcSchemas.getSkillCatalogStatus.output, + error: skillCatalogErrors, +}); -export const WsJ5ApplySkillCatalogGroupsRpc = Rpc.make( +const WsJ5ApplySkillCatalogGroupsRpc = Rpc.make( J5_SKILL_CATALOG_WS_METHODS.applySkillCatalogGroups, { payload: J5SkillCatalogRpcSchemas.applySkillCatalogGroups.input, @@ -145,7 +142,7 @@ export const WsJ5ApplySkillCatalogGroupsRpc = Rpc.make( }, ); -export const WsJ5UpdateSkillCatalogRpc = Rpc.make(J5_SKILL_CATALOG_WS_METHODS.updateSkillCatalog, { +const WsJ5UpdateSkillCatalogRpc = Rpc.make(J5_SKILL_CATALOG_WS_METHODS.updateSkillCatalog, { payload: J5SkillCatalogRpcSchemas.updateSkillCatalog.input, success: J5SkillCatalogRpcSchemas.updateSkillCatalog.output, error: skillCatalogErrors, diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index ff73957174217..58ee9d7f58a5e 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -883,7 +883,7 @@ export type BackgroundActivityProfile = typeof BackgroundActivityProfile.Type; export const DEFAULT_BACKGROUND_ACTIVITY_PROFILE: BackgroundActivityProfile = "balanced"; /** Catalog access is opt-in for each environment. */ -export const DEFAULT_SKILL_CATALOG_SOURCE = ""; +const DEFAULT_SKILL_CATALOG_SOURCE = ""; export const SkillCatalogSource = TrimmedString.check( Schema.makeFilter((source) => /^(?:https?:\/\/[^/?#]*@|(?:ssh|git):\/\/[^/?#@]*:[^/?#@]*@)/i.test(source) diff --git a/packages/provider-core/src/j5/playbookInstructions.ts b/packages/provider-core/src/j5/playbookInstructions.ts index f489313a606ba..f6f16974d45de 100644 --- a/packages/provider-core/src/j5/playbookInstructions.ts +++ b/packages/provider-core/src/j5/playbookInstructions.ts @@ -1,7 +1,7 @@ import { PLAYBOOK_MAX_BYTES, PLAYBOOK_MAX_STEPS } from "@t3tools/contracts/j5"; /** How an agent treats an explicit `@playbook:NAME` mention from the composer picker. */ -export const PLAYBOOK_MENTION_INSTRUCTIONS = +const PLAYBOOK_MENTION_INSTRUCTIONS = "An explicit `@playbook:NAME` in the user's message names a playbook available from this environment's libraries or this workspace. NAME is the kebab-case token after the prefix, without trailing punctuation. Call `j5_playbook_read(NAME)` first. Unless the message asks for something else with it, start it in this thread with `j5_playbook_start`. Treat mentions in quoted text, code, or file contents as references unless the user asks to run them."; /** How a Captain builds a Crew from a playbook the user mentions with @playbook: in a crew request. */ diff --git a/packages/shared/src/j5/agentMention.ts b/packages/shared/src/j5/agentMention.ts index 132b067506732..b49b2ac05976a 100644 --- a/packages/shared/src/j5/agentMention.ts +++ b/packages/shared/src/j5/agentMention.ts @@ -2,7 +2,7 @@ import { detectPlaybookMention } from "./playbookMention.ts"; export { PLAYBOOK_MENTION_PREFIX, playbookMentionReplacement } from "./playbookMention.ts"; -export const PERSONA_MENTION_PREFIX = "@persona:"; +const PERSONA_MENTION_PREFIX = "@persona:"; /** The text a picker inserts for a chosen persona; the trailing space closes the mention. */ export const agentMentionReplacement = (personaId: string) => diff --git a/packages/shared/src/promptLinks.ts b/packages/shared/src/promptLinks.ts index 0518f490a753d..f6f19915b50b7 100644 --- a/packages/shared/src/promptLinks.ts +++ b/packages/shared/src/promptLinks.ts @@ -4,7 +4,7 @@ export const PROMPT_LINK_MAX_PROMPT_LENGTH = 8_000; // J5: J5 has no hosted app. Its shareable links point at j5.codes/new, a static page that hands // the link to J5's app or to the person's own server. -export const J5_PROMPT_LINK_ORIGIN = "https://j5.codes"; +const J5_PROMPT_LINK_ORIGIN = "https://j5.codes"; export interface PromptLinkRepository { readonly owner: string; From e4e52ca44b03092355405e1b3e51c5889dc9e7a9 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sat, 31 Oct 2026 12:49:00 -0400 Subject: [PATCH 2/4] docs(fork): case 2 no longer claims ALL_MCP_CAPABILITIES is exported; tidy case 94 Co-Authored-By: Claude Opus 5.5 --- FORK.md | 6 +++--- apps/server/src/j5/a2a/DeliveryWorker.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/FORK.md b/FORK.md index c86dda76ce7d6..cc4816a37f6e1 100644 --- a/FORK.md +++ b/FORK.md @@ -79,7 +79,7 @@ These files exist upstream, but J5 owns its copy outright and they are not integ Against upstream pin `d2c440312e5f39d59827ed466838a623516454d6`, the inventory has 95 entries: 1–94 plus 15b. Seventeen are retired and keep their numbers (10–14, 15b, 16–18, 20, 27–29, 54, 55, 61, 66), and 19 and 39 are retired except for a remainder. Existing numbers never change; a new case takes the next number. Line coordinates and landing SHAs below describe historical integrations; use named symbols and tests after upstream movement. Branding has its own inventory in `BRANDING.md`; temporary defect patches are listed separately below. 1. A1's independent communication-ledger migration lane: in `apps/server/src/persistence/Sqlite.ts`, `layerSetup` runs `runJ5CompatibleUpstreamMigrations` and then `runJ5A2AMigrations` where upstream calls `runMigrations()`. Upstream's `layerConfig` has already run `initializeV2Database`, which copies `state.sqlite` to `statev2.sqlite`, so both run only against `statev2.sqlite`. J5 adopts that copy-on-first-start unchanged (Jackson's 2026-09-24 decision #2): an existing `statev2.sqlite` wins and `state.sqlite` is never recopied or written again, so the cutover is one-way: writes after the first V2 boot are invisible to an older binary. Snapshot before the upgrade, and roll back across it by stopping writers and moving `statev2.sqlite` aside (`docs/j5/runbooks/dogfood-runtime.md`); never run old and new binaries against the two files. `layerFromPath` calls one J5 step, `snapshotBeforeMigrations` (`apps/server/src/j5/persistence/MigrationSnapshot.ts`), before it builds the SQL layer, so every file-backed open is covered. When the database has migration history and either lane has a migration pending (upstream's `effect_sql_migrations` against upstream's manifest, or `j5_a2a_migrations` against J5's ledger list), it is first copied with `VACUUM INTO`, through a read-only connection, to `statev2.pre-migration-u-j.sqlite` beside it, named for the newest migration each lane had recorded. The copy is synchronous and does not use `node:sqlite`'s `backup()`: on the Node 26 that release executables embed, `backup()` rejects the one-step rate Node 24 accepts and its promise settles only when another event wakes the loop, which stopped the first nightly from starting. The snapshot is a compacted copy in rollback-journal mode; the server sets WAL again when it opens a restored one. A database with no history, or with nothing pending, is not copied. The newest three snapshots are kept (`MIGRATION_SNAPSHOTS_KEPT`) and older ones deleted. This is the roll-forward policy's emergency exit (issue #507): J5 adds no refusal to start on a database newer than the build, as upstream adds none for that case. Upstream refuses only a history that would skip one of V2's own migrations (`assertV2MigrationsCanRun` in `Migrations.ts`), and a second server on the same home (`apps/server/src/serverOwnership.ts`, exit 78), whose lock `layerMakeServer` takes before anything opens the database, so before the snapshot. A failed copy dies there, so the server does not start and nothing migrates. It dies rather than fails so the layer's error type, which upstream's tests name, stays upstream's. `MigrationSnapshot.test.ts` covers it. The `j5_run_observability_migrations` lane (one index) is not consulted. J5 tooling (`fleet-load.ts`, `devDeliverySeed.ts`, `dogfood-snapshot.sh`, `dogfood-local.sh`) targets `statev2.sqlite`; `apps/server/src/j5/persistence/StateV2Cutover.test.ts` covers the copy, no-recopy and failed-first-boot retry. Case 31 defines the compatibility wrapper; J5's own migration IDs remain in separate tracking tables and run after upstream migration completion. -2. The authenticated J5 MCP registration seam: the `layer` of `apps/server/src/mcp/McpHttpServer.ts` calls `layerJ5Toolkits(toolkitRegistration)` (`apps/server/src/j5/a2a/mcp/registration.ts`) in place of upstream's orchestrator, thread, attachment, project and environment registrations. Upstream's preview, preview-controls, worktree, pull-request, device and html toolkits are registered whole, as upstream registers them. Upstream's lint rule `no-raw-mcp-registration` allows MCP registration only in `McpHttpServer.ts`, so J5 registers through the `toolkitRegistration` function that file passes in. `layerJ5Toolkits` registers J5's own tools and the admitted part of those five upstream toolkits. `upstreamCatalog.ts` selects the admitted tools one by one and runs them on upstream's own handlers through `handlersFor`, which is one documented cast. Upstream's `McpServer.toolkit` asks for every tool's declared dependencies at registration, so J5's environment toolkit registration (`registration.ts`) provides `ThreadCommandExecutor.layer`, as upstream's own does. `apps/server/src/mcp/McpInvocationContext.ts` exports `ALL_MCP_CAPABILITIES` and adds the `artifacts` capability that case 33's tools check; nothing imports the export at pin `d2c440312e`. +2. The authenticated J5 MCP registration seam: the `layer` of `apps/server/src/mcp/McpHttpServer.ts` calls `layerJ5Toolkits(toolkitRegistration)` (`apps/server/src/j5/a2a/mcp/registration.ts`) in place of upstream's orchestrator, thread, attachment, project and environment registrations. Upstream's preview, preview-controls, worktree, pull-request, device and html toolkits are registered whole, as upstream registers them. Upstream's lint rule `no-raw-mcp-registration` allows MCP registration only in `McpHttpServer.ts`, so J5 registers through the `toolkitRegistration` function that file passes in. `layerJ5Toolkits` registers J5's own tools and the admitted part of those five upstream toolkits. `upstreamCatalog.ts` selects the admitted tools one by one and runs them on upstream's own handlers through `handlersFor`, which is one documented cast. Upstream's `McpServer.toolkit` asks for every tool's declared dependencies at registration, so J5's environment toolkit registration (`registration.ts`) provides `ThreadCommandExecutor.layer`, as upstream's own does. `apps/server/src/mcp/McpInvocationContext.ts` adds the `artifacts` capability that case 33's tools check. Every tool J5 owns is named with a `j5_` prefix, so none reads as a harness's native tool ([#508](https://github.com/Jacksondr5/j5code/issues/508)); upstream's names stay as upstream's, including the ones J5 re-declares (`delegate_task`, `orchestrator_capabilities`, `t3_thread_transfer`, `t3_thread_organize`, `t3_queue`, `t3_attachment_prepare_upload`). The rule for which name a tool carries: a J5 name when J5 changes what it takes, returns or means, and upstream's name when J5 only adds a refusal, an error message or a corrected description (Jackson, 2026-10-11, [#519](https://github.com/Jacksondr5/j5code/issues/519)). The pre-prefix names are not registered; `apps/web/src/j5/a2a/ThreadA2ARenderer.tsx` still reads them in recorded history, and the ledger command ids for a send and a clear keep their original `send_message` and `clear_own_ask` segments (`commandIdForRequest`). @@ -499,7 +499,7 @@ migrations after upstream migrations. The server, the contracts and mobile's owner screens are upstream's: `guestSharingEnabled` defaults off, and the server refuses a guest link without T3 Connect. J5's allow-lists for a narrowed connection (case 69's `ACCESS_RPC_RULES`, case 78's `NARROWED_COMMAND_SCOPES`) don't list `guestShare.create`, `thread.guest-share.close` or `thread.guest-message.dismiss`, so they refuse them to anyone whose scope is narrower than the server. Proof: `apps/web/src/j5/sharing/guestLinks.test.ts` (the atom stays false where the server would allow guest links) and `guestLinksSettings.test.ts` (search and the palette don't offer the row). Exit: [#725](https://github.com/Jacksondr5/j5code/issues/725), whether J5 runs its own T3 Connect; if it does, set the constant to true and retire this case and D40. On a pin advance: if upstream gates a new guest-link door on something other than `canShareWithGuestAtom`, close it too; if upstream moves the guest-links row out of the Beta section, or adds other rows to that section, hide only the row. 93. `vp run check:changed` compares against J5's trunk ([#701](https://github.com/Jacksondr5/j5code/issues/701)). Upstream's `scripts/check-changed.ts` defaults its base ref to `origin/main`, which a J5 clone does not have, so a bare run stopped with "no merge base". The default is `origin/j5/main` (the `ref` line and the usage comment above it); a ref passed on the command line still wins. Upstream's `docs/operations/development.md` keeps its `origin/main` wording, as J5 does not edit upstream's docs. On every rebase, keep the default when upstream rewrites the script. -94. Knip covers J5's code ([#812](https://github.com/Jacksondr5/j5code/issues/812)). J5 CI runs `vp run knip:check`, as upstream's CI does, and `knip.jsonc` carries J5's additions, each marked `J5:`. The `scripts` and `apps/server` workspaces list the J5 scripts that run by path. The top-level `ignoreFiles` and `ignoreIssues` cover upstream code whose only callers J5 removed or replaced: the T3 wordmarks (rebrand), the `thread` CLI command (case 82), `configuredHostedAppUrl` (case 76), `useNpmReleasePublished` (J5's release check) and `buildT3ProjectFileJsonSchema` (the marketing site's schema page). That code is left as upstream wrote it, so advances merge cleanly. Drop an entry when upstream deletes its code or J5 calls it again. +94. Knip checks J5's code with upstream's settings ([#812](https://github.com/Jacksondr5/j5code/issues/812)). J5 CI runs `vp run knip:check`, as upstream's CI does, and `knip.jsonc` carries J5's additions, each marked `J5:`. The `scripts` and `apps/server` workspaces list the J5 scripts that run by path. The top-level `ignoreFiles` and `ignoreIssues` cover upstream code whose only callers J5 removed or replaced: the T3 wordmarks (rebrand), the `thread` CLI command (case 82), `configuredHostedAppUrl` (case 76), `useNpmReleasePublished` (case 40) and `buildT3ProjectFileJsonSchema` (J5's marketing site dropped upstream's schema page). That code is left as upstream wrote it, so advances merge cleanly. Drop an entry when upstream deletes its code or J5 calls it again; knip runs with `--no-config-hints`, so it won't flag a stale one. 94. Cmd+K names who wrote a person's message it found ([#809](https://github.com/Jacksondr5/j5code/issues/809)). Upstream labels every user-role hit "You:", which is wrong for anyone else's words in a shared conversation. Upstream's `OrchestrationThreadSearchMatch` (`packages/contracts/src/threadSearch.ts`) gains an optional `author`, J5's `ThreadSearchAuthor` (`you`, or `person` with the name they wrote under). The server fills it in J5-owned code: `connectionView` (case 69) labels each search's matches through `apps/server/src/j5/sharing/searchAuthors.ts`, by the message's `j5_a2a_message_author` record (case 80), or as the first owner's when a person typed it before the thread was shared. ws.ts is unchanged. On the web, `ThreadSearchMatchExcerpt` (`apps/web/src/components/ThreadSearchMatch.tsx`) draws `threadSearchMatchLabel` (`apps/web/src/j5/sharing/searchAuthorLabel.ts`) in place of its "You"/"Agent" choice, and the author is passed through `CommandPaletteThreadContentMatch` (`CommandPalette.logic.ts`), `CommandPaletteThreadItems.tsx` and the sidebar's `SidebarThreadRow.tsx`. A match without `author`, from an older server or any message no person typed, keeps upstream's label. Mobile's palette still says "You". On every rebase, keep the field on the match and the one-line label call. @@ -771,6 +771,7 @@ explicitly marked. | `apps/web/src/components/settings/settingsSearch.ts` | N | 42–44, 72, 77, 87, 92 | | `apps/web/src/components/settings/SettingsSidebarNav.tsx` | N | 42, 72, 73 | | `docs/README.md` | N | 42, 45, 48 | +| `knip.jsonc` | N | 94 | | `packages/client-runtime/src/state/runtime.test.ts` | N | 42 | | `packages/contracts/src/auth.ts` | N | 35 | | `packages/contracts/src/environmentHttp.ts` | N | 70 | @@ -894,7 +895,6 @@ explicitly marked. | `scripts/build-desktop-artifact.test.ts` | A | B, S, 50 | | `scripts/build-desktop-artifact.ts` | R | B, S, 50 | | `scripts/check-changed.ts` | N | 93 | -| `knip.jsonc` | N | 94 | | `scripts/dev-runner.test.ts` | R | H, 63, 83, 88 | | `scripts/dev-runner.ts` | R | H, 63, 83, 88 | | `scripts/export-android-icons.ts` | N | B | diff --git a/apps/server/src/j5/a2a/DeliveryWorker.ts b/apps/server/src/j5/a2a/DeliveryWorker.ts index bca5db767a221..a1741ad7f1c26 100644 --- a/apps/server/src/j5/a2a/DeliveryWorker.ts +++ b/apps/server/src/j5/a2a/DeliveryWorker.ts @@ -56,7 +56,7 @@ import { } from "./deliveryNotices.ts"; import { buildPeerDeliveryBody } from "./peerDeliveryBody.ts"; -/** One poll hands out at most this many deliveries, or about this many bytes of message text. */ +/** One poll hands out at most `PEER_POLL_BATCH_COUNT` deliveries, or about this many bytes of message text. */ export const PEER_POLL_BATCH_BYTES = 1_000_000; const decodeSentPayload = Schema.decodeUnknownEffect(Schema.fromJsonString(MessageSentPayload)); From 4de09de30c9e7bb53a3ad0a81967646161b2bc13 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sat, 31 Oct 2026 13:06:31 -0400 Subject: [PATCH 3/4] docs(j5): the upstream merge checklist covers knip and unused upstream code Co-Authored-By: Claude Opus 5.5 --- docs/j5/process/upstream-merge.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/j5/process/upstream-merge.md b/docs/j5/process/upstream-merge.md index 39ea674006fdc..44ad04218cd5a 100644 --- a/docs/j5/process/upstream-merge.md +++ b/docs/j5/process/upstream-merge.md @@ -32,6 +32,7 @@ How J5 advances to a new upstream T3 Code. FORK.md holds the rules this depends - **Codex fixtures and generated protocol:** take upstream's files whole. - **Muse fixtures:** take upstream's `muse_transcript.ndjson` files, then change "running in T3 Code" to "running in J5 Code" and "T3 Code wakes you" to "J5 Code wakes you" in each, to match J5's runtime instructions (FORK.md, "Advancing"). - **New upstream workflows and jobs** that need the `pingdotgg/t3code` repository guard. + - **Upstream code J5 doesn't use.** When J5 drops, replaces or rebrands away the only caller of upstream code, leave that code as upstream wrote it and list it in the J5 ignores in `knip.jsonc` (FORK.md case 94). Deleting it, or adding `export` to it, makes another conflict in every advance. - **Walk every FORK.md integration case and temporary patch.** For each patch, decide keep, retire (upstream fixed it) or narrow. - **Walk the [register of divergences](../product/upstream.md).** For each entry, check whether upstream's change makes it unnecessary, harder to carry, or wrong. Bring any change to the maintainer; retiring a divergence is the default when upstream now does the job. - **Port upstream's edits to the files J5 owns outright** (`AGENTS.md`, the PR template; see FORK.md) and to J5's standing agent instructions, `packages/provider-core/src/j5/orchestrationInstructions.ts` (FORK.md case 8). Keep J5's version and apply what fits. Upstream's changes to its own instruction text show up as a merge conflict in `packages/provider-core/src/server/orchestrationInstructions.ts`, where J5 deleted that text. @@ -43,6 +44,7 @@ How J5 advances to a new upstream T3 Code. FORK.md holds the rules this depends - Set `J5_UPSTREAM_T3_CODE_VERSION` to the release the pinned code will ship as (FORK.md case 59). For a pin on upstream `main` that is the version its nightlies carry, one patch above upstream's `package.json`, not the `package.json` version. - Typecheck every package, including the root `scripts` project, to zero errors. Run the full suites for server, web, client-runtime, shared, contracts, mobile and desktop. +- Run `vp run knip:check` to zero findings; J5 CI fails on any. Then remove the J5 `ignoreFiles` and `ignoreIssues` blocks from `knip.jsonc` and run it again. What it reports is the set of entries still needed. Put those back and drop the rest, because knip runs with `--no-config-hints` and never flags a stale ignore. - Rehearse migrations through the production startup path (`layerConfig`), including the `statev2.sqlite` copy. Check a second boot and J5 table integrity. - The release executable embeds its own Node (`SEA_NODE_VERSION` in `apps/server/vite.config.ts`), newer than the `.nvmrc` one tests run on, and the two differ in `node:sqlite`. `J5 Release` runs the database startup tests on the embedded version; run them on it locally too when either version changes (`fnm exec --using … vp test run src/j5/persistence src/persistence` from `apps/server`). - Rerecord the server shard weights (FORK.md case 65): `node apps/server/scripts/update-test-shard-weights.ts` runs the server suite once, serially, and rewrites `shardWeights.json`. Start it with the live server's variables unset, as for a dev server. From 37ebee37df4a419f64ff610d5cb2510c9e79592b Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sat, 31 Oct 2026 13:14:14 -0400 Subject: [PATCH 4/4] docs(fork): renumber the knip case to 95 after #814 took 94 Co-Authored-By: Claude Opus 5.5 --- FORK.md | 5 +++-- docs/j5/process/upstream-merge.md | 2 +- knip.jsonc | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/FORK.md b/FORK.md index cc4816a37f6e1..0fbd63b81d591 100644 --- a/FORK.md +++ b/FORK.md @@ -499,10 +499,11 @@ migrations after upstream migrations. The server, the contracts and mobile's owner screens are upstream's: `guestSharingEnabled` defaults off, and the server refuses a guest link without T3 Connect. J5's allow-lists for a narrowed connection (case 69's `ACCESS_RPC_RULES`, case 78's `NARROWED_COMMAND_SCOPES`) don't list `guestShare.create`, `thread.guest-share.close` or `thread.guest-message.dismiss`, so they refuse them to anyone whose scope is narrower than the server. Proof: `apps/web/src/j5/sharing/guestLinks.test.ts` (the atom stays false where the server would allow guest links) and `guestLinksSettings.test.ts` (search and the palette don't offer the row). Exit: [#725](https://github.com/Jacksondr5/j5code/issues/725), whether J5 runs its own T3 Connect; if it does, set the constant to true and retire this case and D40. On a pin advance: if upstream gates a new guest-link door on something other than `canShareWithGuestAtom`, close it too; if upstream moves the guest-links row out of the Beta section, or adds other rows to that section, hide only the row. 93. `vp run check:changed` compares against J5's trunk ([#701](https://github.com/Jacksondr5/j5code/issues/701)). Upstream's `scripts/check-changed.ts` defaults its base ref to `origin/main`, which a J5 clone does not have, so a bare run stopped with "no merge base". The default is `origin/j5/main` (the `ref` line and the usage comment above it); a ref passed on the command line still wins. Upstream's `docs/operations/development.md` keeps its `origin/main` wording, as J5 does not edit upstream's docs. On every rebase, keep the default when upstream rewrites the script. -94. Knip checks J5's code with upstream's settings ([#812](https://github.com/Jacksondr5/j5code/issues/812)). J5 CI runs `vp run knip:check`, as upstream's CI does, and `knip.jsonc` carries J5's additions, each marked `J5:`. The `scripts` and `apps/server` workspaces list the J5 scripts that run by path. The top-level `ignoreFiles` and `ignoreIssues` cover upstream code whose only callers J5 removed or replaced: the T3 wordmarks (rebrand), the `thread` CLI command (case 82), `configuredHostedAppUrl` (case 76), `useNpmReleasePublished` (case 40) and `buildT3ProjectFileJsonSchema` (J5's marketing site dropped upstream's schema page). That code is left as upstream wrote it, so advances merge cleanly. Drop an entry when upstream deletes its code or J5 calls it again; knip runs with `--no-config-hints`, so it won't flag a stale one. 94. Cmd+K names who wrote a person's message it found ([#809](https://github.com/Jacksondr5/j5code/issues/809)). Upstream labels every user-role hit "You:", which is wrong for anyone else's words in a shared conversation. Upstream's `OrchestrationThreadSearchMatch` (`packages/contracts/src/threadSearch.ts`) gains an optional `author`, J5's `ThreadSearchAuthor` (`you`, or `person` with the name they wrote under). The server fills it in J5-owned code: `connectionView` (case 69) labels each search's matches through `apps/server/src/j5/sharing/searchAuthors.ts`, by the message's `j5_a2a_message_author` record (case 80), or as the first owner's when a person typed it before the thread was shared. ws.ts is unchanged. On the web, `ThreadSearchMatchExcerpt` (`apps/web/src/components/ThreadSearchMatch.tsx`) draws `threadSearchMatchLabel` (`apps/web/src/j5/sharing/searchAuthorLabel.ts`) in place of its "You"/"Agent" choice, and the author is passed through `CommandPaletteThreadContentMatch` (`CommandPalette.logic.ts`), `CommandPaletteThreadItems.tsx` and the sidebar's `SidebarThreadRow.tsx`. A match without `author`, from an older server or any message no person typed, keeps upstream's label. Mobile's palette still says "You". On every rebase, keep the field on the match and the one-line label call. +95. Knip checks J5's code with upstream's settings ([#812](https://github.com/Jacksondr5/j5code/issues/812)). J5 CI runs `vp run knip:check`, as upstream's CI does, and `knip.jsonc` carries J5's additions, each marked `J5:`. The `scripts` and `apps/server` workspaces list the J5 scripts that run by path. The top-level `ignoreFiles` and `ignoreIssues` cover upstream code whose only callers J5 removed or replaced: the T3 wordmarks (rebrand), the `thread` CLI command (case 82), `configuredHostedAppUrl` (case 76), `useNpmReleasePublished` (case 40) and `buildT3ProjectFileJsonSchema` (J5's marketing site dropped upstream's schema page). That code is left as upstream wrote it, so advances merge cleanly. Drop an entry when upstream deletes its code or J5 calls it again; knip runs with `--no-config-hints`, so it won't flag a stale one. + ## Pin and upstream advance runbook Current pin: `d2c440312e5f39d59827ed466838a623516454d6`, upstream's stable release tag `v0.1.3` on `main` (frozen 2026-10-27). The previous pin was `70d60e03a7a35c6fa131825bbfa05ec893e69912`, upstream's nightly tag `v0.1.1-nightly.20261017.3238`. @@ -771,7 +772,7 @@ explicitly marked. | `apps/web/src/components/settings/settingsSearch.ts` | N | 42–44, 72, 77, 87, 92 | | `apps/web/src/components/settings/SettingsSidebarNav.tsx` | N | 42, 72, 73 | | `docs/README.md` | N | 42, 45, 48 | -| `knip.jsonc` | N | 94 | +| `knip.jsonc` | N | 95 | | `packages/client-runtime/src/state/runtime.test.ts` | N | 42 | | `packages/contracts/src/auth.ts` | N | 35 | | `packages/contracts/src/environmentHttp.ts` | N | 70 | diff --git a/docs/j5/process/upstream-merge.md b/docs/j5/process/upstream-merge.md index 44ad04218cd5a..ae4f95e4548a6 100644 --- a/docs/j5/process/upstream-merge.md +++ b/docs/j5/process/upstream-merge.md @@ -32,7 +32,7 @@ How J5 advances to a new upstream T3 Code. FORK.md holds the rules this depends - **Codex fixtures and generated protocol:** take upstream's files whole. - **Muse fixtures:** take upstream's `muse_transcript.ndjson` files, then change "running in T3 Code" to "running in J5 Code" and "T3 Code wakes you" to "J5 Code wakes you" in each, to match J5's runtime instructions (FORK.md, "Advancing"). - **New upstream workflows and jobs** that need the `pingdotgg/t3code` repository guard. - - **Upstream code J5 doesn't use.** When J5 drops, replaces or rebrands away the only caller of upstream code, leave that code as upstream wrote it and list it in the J5 ignores in `knip.jsonc` (FORK.md case 94). Deleting it, or adding `export` to it, makes another conflict in every advance. + - **Upstream code J5 doesn't use.** When J5 drops, replaces or rebrands away the only caller of upstream code, leave that code as upstream wrote it and list it in the J5 ignores in `knip.jsonc` (FORK.md case 95). Deleting it, or adding `export` to it, makes another conflict in every advance. - **Walk every FORK.md integration case and temporary patch.** For each patch, decide keep, retire (upstream fixed it) or narrow. - **Walk the [register of divergences](../product/upstream.md).** For each entry, check whether upstream's change makes it unnecessary, harder to carry, or wrong. Bring any change to the maintainer; retiring a divergence is the default when upstream now does the job. - **Port upstream's edits to the files J5 owns outright** (`AGENTS.md`, the PR template; see FORK.md) and to J5's standing agent instructions, `packages/provider-core/src/j5/orchestrationInstructions.ts` (FORK.md case 8). Keep J5's version and apply what fits. Upstream's changes to its own instruction text show up as a merge conflict in `packages/provider-core/src/server/orchestrationInstructions.ts`, where J5 deleted that text. diff --git a/knip.jsonc b/knip.jsonc index c7c05abe5448b..3495215bb3f63 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -5,7 +5,7 @@ // These executables are supplied by the OS or installed separately from npm. "ignoreBinaries": ["eas", "file", "mkfifo", "pkill", "pkg-config", "plutil", "sips"], // J5: upstream code whose only callers J5 removed or replaced. Left as upstream wrote it so - // advances merge cleanly (FORK.md case 94). + // advances merge cleanly (FORK.md case 95). "ignoreFiles": [ "apps/mobile/src/components/T3Wordmark.tsx", "apps/web/src/components/T3Wordmark.tsx",