Skip to content

Commit 5542524

Browse files
Merge remote-tracking branch 'origin/main' into feat/agent-github-reads
# Conflicts: # apps/server/src/provider/agentContextBudget.json
2 parents 31d2e36 + 0e99148 commit 5542524

47 files changed

Lines changed: 2599 additions & 425 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/server/src/auth/RpcAuthorization.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ describe("RPC authorization scopes", () => {
7878
}
7979
});
8080

81+
it("lets read-only clients see skills library status but not move skill folders", () => {
82+
expect(requiredScopeForRpcMethod(WS_METHODS.serverGetSkillsLibraryStatus)).toBe(
83+
AuthOrchestrationReadScope,
84+
);
85+
expect(requiredScopeForRpcMethod(WS_METHODS.serverRefreshSkillsLibrary)).toBe(
86+
AuthSettingsWriteScope,
87+
);
88+
});
89+
8190
it("treats the project Loom as a thread read", () => {
8291
expect(requiredScopeForRpcMethod(WS_METHODS.projectReadLoomWindow)).toBe(
8392
AuthOrchestrationReadScope,

‎apps/server/src/auth/RpcAuthorization.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const RPC_REQUIRED_SCOPES = {
7676
[WS_METHODS.serverProbe]: AuthOrchestrationReadScope,
7777
[WS_METHODS.serverGetConfig]: AuthOrchestrationReadScope,
7878
[WS_METHODS.serverRefreshProviders]: AuthOrchestrationReadScope,
79+
[WS_METHODS.serverGetSkillsLibraryStatus]: AuthOrchestrationReadScope,
7980
[WS_METHODS.serverUpdateProvider]: AuthProvidersManageScope,
8081
[WS_METHODS.providerAuthStart]: AuthProvidersManageScope,
8182
[WS_METHODS.providerConsumeResetCredit]: AuthProvidersManageScope,

‎apps/server/src/environment/ServerEnvironment.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ export const make = Effect.gen(function* () {
245245
storageCleanupRun: true,
246246
databaseStorage: true,
247247
otlpEndpointCheck: true,
248+
skillsLibrary: true,
248249
projectWorktreeCleanup: true,
249250
settledWorktreeCleanup: true,
250251
worktreesDirectory: true,

‎apps/server/src/mcp/toolkits/core.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import * as McpToolAccessTestkit from "../McpToolAccess.testkit.ts";
5858
import * as AnalyticsService from "../../telemetry/AnalyticsService.ts";
5959
import { dispatchFailure } from "../threadAccess.ts";
6060
import * as EnvironmentHandlers from "./environment/handlers.ts";
61+
import { EnvironmentToolkit } from "./environment/tools.ts";
6162
import * as AttachmentHandlers from "./attachment/handlers.ts";
6263
import * as PeerForwarding from "../../peer/PeerForwarding.ts";
6364
import * as PeerLinkRequests from "../../peer/PeerLinkRequests.ts";
@@ -490,6 +491,7 @@ it.effect("keeps unexpected handler defects private through the production regis
490491
it("keeps MCP preference output allowlisted and Unicode-bounded", () => {
491492
const settings = {
492493
...DEFAULT_SERVER_SETTINGS,
494+
skillsLibraryEnabled: true,
493495
privateCredential: "must-not-escape",
494496
sourceControlWritingStyle: {
495497
...DEFAULT_SERVER_SETTINGS.sourceControlWritingStyle,
@@ -499,10 +501,15 @@ it("keeps MCP preference output allowlisted and Unicode-bounded", () => {
499501
const result = EnvironmentHandlers.preferences(settings);
500502
expect(result).not.toHaveProperty("privateCredential");
501503
expect(result).not.toHaveProperty("providers");
504+
expect(result.skillsLibraryEnabled).toBe(true);
502505
expect(result.sourceControlWritingStyle).toMatchObject({
503506
customInstructions: "🙂".repeat(4000),
504507
truncated: true,
505508
});
509+
const update = Schema.decodeUnknownSync(
510+
EnvironmentToolkit.tools.t3_environment_preferences_update.parametersSchema,
511+
);
512+
expect(update({ skillsLibraryEnabled: true })).toMatchObject({ skillsLibraryEnabled: true });
506513
});
507514

508515
it.effect("resolves reused attachment references from stored metadata", () =>

‎apps/server/src/mcp/toolkits/environment/handlers.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function preferences(settings: ServerSettings) {
1313
defaultThreadEnvMode,
1414
newWorktreesStartFromOrigin,
1515
enableProviderUpdateChecks,
16+
skillsLibraryEnabled,
1617
backgroundActivity,
1718
sourceControlWritingStyle,
1819
} = settings;
@@ -21,6 +22,7 @@ export function preferences(settings: ServerSettings) {
2122
defaultThreadEnvMode,
2223
newWorktreesStartFromOrigin,
2324
enableProviderUpdateChecks,
25+
skillsLibraryEnabled,
2426
backgroundActivity: { profile: backgroundActivity.profile },
2527
sourceControlWritingStyle: {
2628
...sourceControlWritingStyle,

‎apps/server/src/mcp/toolkits/environment/tools.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const PreferenceFields = {
1919
defaultThreadEnvMode: ServerSettings.fields.defaultThreadEnvMode,
2020
newWorktreesStartFromOrigin: ServerSettings.fields.newWorktreesStartFromOrigin,
2121
enableProviderUpdateChecks: ServerSettings.fields.enableProviderUpdateChecks,
22+
skillsLibraryEnabled: ServerSettings.fields.skillsLibraryEnabled,
2223
backgroundActivity: Schema.Struct({ profile: BackgroundActivityProfileSelection }),
2324
sourceControlWritingStyle: Schema.Struct({
2425
mode: Schema.String,
@@ -62,6 +63,7 @@ const EnvironmentPreferencesTool = Tool.make("t3_environment_preferences_update"
6263
defaultThreadEnvMode: ServerSettingsPatch.fields.defaultThreadEnvMode,
6364
newWorktreesStartFromOrigin: ServerSettingsPatch.fields.newWorktreesStartFromOrigin,
6465
enableProviderUpdateChecks: ServerSettingsPatch.fields.enableProviderUpdateChecks,
66+
skillsLibraryEnabled: ServerSettingsPatch.fields.skillsLibraryEnabled,
6567
backgroundActivity: Schema.optionalKey(Schema.Struct({ profile: BackgroundActivityProfile })),
6668
sourceControlWritingStyle: ServerSettingsPatch.fields.sourceControlWritingStyle,
6769
}),

‎apps/server/src/observability/RpcInstrumentation.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ const RPC_AGGREGATES = {
9898
[WS_METHODS.serverGetResourceTelemetryHistory]: "server",
9999
[WS_METHODS.serverRetryResourceTelemetry]: "server",
100100
[WS_METHODS.serverCheckOtlpEndpoint]: "server",
101+
[WS_METHODS.serverGetSkillsLibraryStatus]: "server",
102+
[WS_METHODS.serverRefreshSkillsLibrary]: "server",
101103
[WS_METHODS.serverPrepareTriage]: "server",
102104
[WS_METHODS.serverGetUsageSummary]: "server",
103105
[WS_METHODS.serverRefreshUsageRates]: "server",

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ import { spawnClaudeProcess } from "../../provider/Drivers/ClaudeProcess.ts";
154154
import {
155155
claudeSignedOutMessage,
156156
claudeAccountSettings,
157+
parseClaudeAccountDir,
157158
resolveClaudeHomePath,
158159
type ClaudeRuntime,
159160
} from "../../provider/Drivers/ClaudeHome.ts";
@@ -1519,7 +1520,10 @@ export function makeClaudeQueryOptions(input: {
15191520
...(typeof querySettings === "object" && querySettings !== null ? querySettings : {}),
15201521
autoCompactWindow: Number(input.settings.autoCompactWindow),
15211522
} as ClaudeSdkSettings);
1522-
const accountSettings = input.settings ? claudeAccountSettings(input.settings) : undefined;
1523+
const accountSettings =
1524+
input.settings?.setupMode === "cli"
1525+
? claudeAccountSettings(parseClaudeAccountDir(input.settings.homePath))
1526+
: undefined;
15231527
// A settings file path cannot take extra keys, so it goes through unchanged.
15241528
const effectiveQuerySettings =
15251529
input.toolSearchOverride === undefined || typeof compactQuerySettings === "string"
@@ -1578,7 +1582,11 @@ export function makeClaudeQueryOptions(input: {
15781582
},
15791583
},
15801584
spawnClaudeCodeProcess: (options) =>
1581-
spawnClaudeProcess(options, input.platform, input.settings!.homePath),
1585+
spawnClaudeProcess(
1586+
options,
1587+
input.platform,
1588+
parseClaudeAccountDir(input.settings!.homePath),
1589+
),
15821590
}),
15831591
...(input.onUserDialog === undefined ? {} : { onUserDialog: input.onUserDialog }),
15841592
...(input.supportedDialogKinds === undefined
@@ -11291,8 +11299,6 @@ export const createClaudeAdapterV2 = Effect.fn("ClaudeAdapterV2Driver.create")(
1129111299
const queryRunner = yield* ClaudeAgentSdkQueryRunner;
1129211300
const serverConfig = yield* ServerConfig.ServerConfig;
1129311301
const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
11294-
if (runtime.mode === "cli")
11295-
yield* fileSystem.makeDirectory(runtime.configDir, { recursive: true, mode: 0o700 });
1129611302
const path = yield* Path.Path;
1129711303
const crypto = yield* Crypto.Crypto;
1129811304
const binaryPath = yield* resolveClaudeSdkExecutablePath(

‎apps/server/src/orchestration-v2/Adapters/ClaudeAgentSdkQueryRunner.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { vi } from "vite-plus/test";
2222
import * as HostProcess from "@t3tools/shared/HostProcess";
2323
import { AgentScope } from "@t3tools/shared/AgentScope";
2424
import { ProviderEventLoggers } from "@t3tools/provider-core/server/ProviderEventLoggers";
25+
import { parseClaudeAccountDir } from "../../provider/Drivers/ClaudeHome.ts";
2526
import { spawnClaudeProcess } from "../../provider/Drivers/ClaudeProcess.ts";
2627
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
2728
import { signalProcessGroup } from "@t3tools/provider-core/server/processGroup";
@@ -474,7 +475,7 @@ describe.skipIf(HostProcess.Platform.defaultValue() === "win32")("Claude CLI pro
474475
signal: AbortSignal.any([]),
475476
},
476477
HostProcess.Platform.defaultValue(),
477-
mode === "cli" ? dir : undefined,
478+
mode === "cli" ? parseClaudeAccountDir(dir) : undefined,
478479
) as NodeChildProcess.ChildProcess;
479480
yield* Effect.addFinalizer(() =>
480481
Effect.sync(() => {

‎apps/server/src/provider/ClaudeCliAuth.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export const makeClaudeCliAuth = Effect.fn("makeClaudeCliAuth")(function* (optio
2727
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2828
const fileSystem = yield* FileSystem.FileSystem;
2929
const { runtime, instanceId } = options;
30-
const settings = encodeSettings(claudeAccountSettings(runtime.config));
30+
const settings = encodeSettings(
31+
claudeAccountSettings(runtime.mode === "cli" ? runtime.configDir : undefined),
32+
);
3133
const spawn = Effect.fnUntraced(function* (args: ReadonlyArray<string>) {
3234
yield* fileSystem.makeDirectory(runtime.configDir, { recursive: true, mode: 0o700 });
3335
const environment = { ...runtime.environment, BROWSER: "false" };

0 commit comments

Comments
 (0)