Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6df2036979 |
No files matched your search
@@ -30,6 +30,7 @@ export const RPC_REQUIRED_SCOPES = {
|
||||
[ORCHESTRATION_WS_METHODS.subscribeThread]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.serverProbe]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.serverGetConfig]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.serverListProviderSkills]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.serverRefreshProviders]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.serverUpdateProvider]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.serverUpdateServer]: AuthOrchestrationOperateScope,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
import { CodexSettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
@@ -36,7 +37,12 @@ import { ServerConfig } from "../../config.ts";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
import { ProviderDriverError } from "../Errors.ts";
|
||||
import { makeCodexAdapter } from "../Layers/CodexAdapter.ts";
|
||||
import { checkCodexProviderStatus, makePendingCodexProvider } from "../Layers/CodexProvider.ts";
|
||||
import { resolveCodexLaunchArgs } from "../Layers/codexLaunchArgs.ts";
|
||||
import {
|
||||
checkCodexProviderStatus,
|
||||
listCodexProviderSkills,
|
||||
makePendingCodexProvider,
|
||||
} from "../Layers/CodexProvider.ts";
|
||||
import { ProviderEventLoggers } from "../Layers/ProviderEventLoggers.ts";
|
||||
import { makeManagedServerProvider } from "../makeManagedServerProvider.ts";
|
||||
import type { ProviderDriver, ProviderInstance } from "../ProviderDriver.ts";
|
||||
@@ -198,6 +204,29 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
|
||||
),
|
||||
);
|
||||
|
||||
const listSkills = (cwd: string) =>
|
||||
listCodexProviderSkills({
|
||||
binaryPath: effectiveConfig.binaryPath,
|
||||
homePath: effectiveConfig.homePath,
|
||||
launchArgs: resolveCodexLaunchArgs(effectiveConfig.launchArgs, processEnv),
|
||||
cwd,
|
||||
environment: processEnv,
|
||||
}).pipe(
|
||||
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
|
||||
Effect.scoped,
|
||||
Effect.timeout(Duration.seconds(10)),
|
||||
Effect.catch((error) =>
|
||||
Effect.logWarning("Codex workspace skill discovery failed; using global skills.", {
|
||||
cwd,
|
||||
error: String(error),
|
||||
instanceId,
|
||||
}).pipe(
|
||||
Effect.andThen(snapshot.getSnapshot),
|
||||
Effect.map((provider) => provider.skills),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return {
|
||||
instanceId,
|
||||
driverKind: DRIVER_KIND,
|
||||
@@ -208,6 +237,7 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
|
||||
snapshot,
|
||||
adapter,
|
||||
textGeneration,
|
||||
listSkills,
|
||||
} satisfies ProviderInstance;
|
||||
}),
|
||||
};
|
||||
@@ -319,14 +319,17 @@ export function buildCodexInitializeParams(): CodexSchema.V1InitializeParams {
|
||||
};
|
||||
}
|
||||
|
||||
const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(function* (input: {
|
||||
interface CodexAppServerProbeInput {
|
||||
readonly binaryPath: string;
|
||||
readonly homePath?: string;
|
||||
readonly launchArgs?: string;
|
||||
readonly cwd: string;
|
||||
readonly customModels?: ReadonlyArray<string>;
|
||||
readonly environment?: NodeJS.ProcessEnv;
|
||||
}) {
|
||||
}
|
||||
|
||||
const openCodexAppServerProbe = Effect.fn("openCodexAppServerProbe")(function* (
|
||||
input: CodexAppServerProbeInput,
|
||||
) {
|
||||
// `~` is not shell-expanded when env vars are set via `child_process.spawn`,
|
||||
// so `CODEX_HOME=~/.codex_work` would reach codex verbatim and trip
|
||||
// "CODEX_HOME points to '~/.codex_work', but that path does not exist".
|
||||
@@ -369,22 +372,33 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
|
||||
Effect.provide(clientContext),
|
||||
);
|
||||
|
||||
const initialize = yield* client.request("initialize", {
|
||||
clientInfo: {
|
||||
name: "t3code_desktop",
|
||||
title: "T3 Code Desktop",
|
||||
version: "0.1.0",
|
||||
},
|
||||
capabilities: {
|
||||
experimentalApi: true,
|
||||
},
|
||||
});
|
||||
const initialize = yield* client.request("initialize", buildCodexInitializeParams());
|
||||
yield* client.notify("initialized", undefined);
|
||||
|
||||
// Extract the version string after the first '/' in userAgent, up to the next space or the end
|
||||
const versionMatch = initialize.userAgent.match(/\/([^\s]+)/);
|
||||
const version = versionMatch ? versionMatch[1] : undefined;
|
||||
|
||||
return { client, version };
|
||||
});
|
||||
|
||||
export const listCodexProviderSkills = Effect.fn("listCodexProviderSkills")(function* (input: {
|
||||
readonly binaryPath: string;
|
||||
readonly homePath?: string;
|
||||
readonly launchArgs?: string;
|
||||
readonly cwd: string;
|
||||
readonly environment?: NodeJS.ProcessEnv;
|
||||
}) {
|
||||
const { client } = yield* openCodexAppServerProbe(input);
|
||||
const response = yield* client.request("skills/list", { cwds: [input.cwd] });
|
||||
return parseCodexSkillsListResponse(response, input.cwd);
|
||||
});
|
||||
|
||||
const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(function* (
|
||||
input: CodexAppServerProbeInput & { readonly customModels?: ReadonlyArray<string> },
|
||||
) {
|
||||
const { client, version } = yield* openCodexAppServerProbe(input);
|
||||
|
||||
const accountResponse = yield* client.request("account/read", {});
|
||||
if (!accountResponse.account && accountResponse.requiresOpenaiAuth) {
|
||||
return {
|
||||
@@ -411,7 +425,9 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
|
||||
models: applyPreferredCodexDefaultModel(
|
||||
appendCustomCodexModels(models, input.customModels ?? []),
|
||||
),
|
||||
skills: parseCodexSkillsListResponse(skillsResponse, input.cwd),
|
||||
skills: parseCodexSkillsListResponse(skillsResponse, input.cwd).filter(
|
||||
(skill) => skill.scope !== "repo",
|
||||
),
|
||||
} satisfies CodexAppServerProviderSnapshot;
|
||||
});
|
||||
|
||||
|
||||
@@ -819,7 +819,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
|
||||
]);
|
||||
});
|
||||
|
||||
it.effect("does not run provider probes during layer construction", () =>
|
||||
it.effect("does not probe at construction and routes cwd-scoped skill discovery", () =>
|
||||
Effect.gen(function* () {
|
||||
const codexDriver = ProviderDriverKind.make("codex");
|
||||
const codexInstanceId = ProviderInstanceId.make("codex");
|
||||
@@ -838,6 +838,13 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
|
||||
skills: [],
|
||||
} as const satisfies ServerProvider;
|
||||
const refreshCalls = yield* Ref.make(0);
|
||||
const skillCwds = yield* Ref.make<ReadonlyArray<string>>([]);
|
||||
const workspaceSkill = {
|
||||
name: "project-review",
|
||||
path: "/tmp/project/.agents/skills/project-review/SKILL.md",
|
||||
scope: "repo",
|
||||
enabled: true,
|
||||
} as const;
|
||||
const instance = {
|
||||
instanceId: codexInstanceId,
|
||||
driverKind: codexDriver,
|
||||
@@ -860,6 +867,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
|
||||
},
|
||||
adapter: {} as ProviderInstance["adapter"],
|
||||
textGeneration: {} as ProviderInstance["textGeneration"],
|
||||
listSkills: (cwd: string) =>
|
||||
Ref.update(skillCwds, (cwds) => [...cwds, cwd]).pipe(Effect.as([workspaceSkill])),
|
||||
} satisfies ProviderInstance;
|
||||
const instanceRegistryLayer = Layer.succeed(
|
||||
ProviderInstanceRegistry.ProviderInstanceRegistry,
|
||||
@@ -889,6 +898,11 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
|
||||
const registry = yield* ProviderRegistry.ProviderRegistry;
|
||||
assert.deepStrictEqual(yield* registry.getProviders, [initialProvider]);
|
||||
assert.strictEqual(yield* Ref.get(refreshCalls), 0);
|
||||
assert.deepStrictEqual(
|
||||
yield* registry.listSkills({ instanceId: codexInstanceId, cwd: "/tmp/project" }),
|
||||
[workspaceSkill],
|
||||
);
|
||||
assert.deepStrictEqual(yield* Ref.get(skillCwds), ["/tmp/project"]);
|
||||
}).pipe(Effect.provide(runtimeServices));
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -496,6 +496,20 @@ export const ProviderRegistryLive = Layer.effect(
|
||||
return yield* refreshOneSource(providerSource);
|
||||
});
|
||||
|
||||
const listSkills = Effect.fn("listSkills")(function* (input: {
|
||||
readonly instanceId: ProviderInstanceId;
|
||||
readonly cwd: string;
|
||||
}) {
|
||||
const instance = yield* instanceRegistry.getInstance(input.instanceId);
|
||||
if (instance === undefined || !instance.enabled) {
|
||||
return [];
|
||||
}
|
||||
if (instance.listSkills !== undefined) {
|
||||
return yield* instance.listSkills(input.cwd);
|
||||
}
|
||||
return (yield* instance.snapshot.getSnapshot).skills;
|
||||
});
|
||||
|
||||
const getProviderMaintenanceCapabilitiesForInstance = Effect.fn(
|
||||
"getProviderMaintenanceCapabilitiesForInstance",
|
||||
)(function* (instanceId: ProviderInstanceId, provider: ProviderDriverKind) {
|
||||
@@ -710,6 +724,7 @@ export const ProviderRegistryLive = Layer.effect(
|
||||
refresh(provider).pipe(Effect.catchCause(recoverRefreshFailure)),
|
||||
refreshInstance: (instanceId: ProviderInstanceId) =>
|
||||
refreshInstance(instanceId).pipe(Effect.catchCause(recoverRefreshFailure)),
|
||||
listSkills,
|
||||
getProviderMaintenanceCapabilitiesForInstance,
|
||||
setProviderMaintenanceActionState,
|
||||
get streamChanges() {
|
||||
|
||||
@@ -25,6 +25,7 @@ import type {
|
||||
ProviderDriverKind,
|
||||
ProviderInstanceEnvironment,
|
||||
ProviderInstanceId,
|
||||
ServerProviderSkill,
|
||||
} from "@t3tools/contracts";
|
||||
import type * as Effect from "effect/Effect";
|
||||
import type * as Schema from "effect/Schema";
|
||||
@@ -71,6 +72,8 @@ export interface ProviderInstance {
|
||||
readonly snapshot: ServerProviderShape;
|
||||
readonly adapter: ProviderAdapterShape<ProviderAdapterError>;
|
||||
readonly textGeneration: TextGeneration.TextGeneration["Service"];
|
||||
/** Resolve the skills visible from a workspace cwd. */
|
||||
readonly listSkills?: (cwd: string) => Effect.Effect<ReadonlyArray<ServerProviderSkill>>;
|
||||
}
|
||||
|
||||
export interface ProviderContinuationIdentity {
|
||||
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
ProviderInstanceId,
|
||||
ProviderDriverKind,
|
||||
ServerProvider,
|
||||
ServerProviderSkill,
|
||||
ServerProviderUpdateState,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Context from "effect/Context";
|
||||
@@ -19,6 +20,11 @@ import type { ProviderMaintenanceCapabilities } from "../providerMaintenance.ts"
|
||||
|
||||
export type ProviderMaintenanceActionKind = "update";
|
||||
|
||||
export interface ProviderRegistryListSkillsInput {
|
||||
readonly instanceId: ProviderInstanceId;
|
||||
readonly cwd: string;
|
||||
}
|
||||
|
||||
export interface ProviderRegistryShape {
|
||||
/**
|
||||
* Read the latest provider snapshots for every configured instance.
|
||||
@@ -48,6 +54,11 @@ export interface ProviderRegistryShape {
|
||||
instanceId: ProviderInstanceId,
|
||||
) => Effect.Effect<ReadonlyArray<ServerProvider>>;
|
||||
|
||||
/** Resolve provider skills using the active workspace cwd. */
|
||||
readonly listSkills: (
|
||||
input: ProviderRegistryListSkillsInput,
|
||||
) => Effect.Effect<ReadonlyArray<ServerProviderSkill>>;
|
||||
|
||||
/**
|
||||
* Resolve the maintenance capabilities owned by one live provider instance.
|
||||
* Falls back to manual-only capabilities when the instance is not live.
|
||||
|
||||
@@ -187,6 +187,7 @@ function makeRegistry(
|
||||
|
||||
const registry: ProviderRegistryShape = {
|
||||
getProviders: Ref.get(providersRef),
|
||||
listSkills: () => Effect.succeed([]),
|
||||
refresh: () => Ref.get(providersRef),
|
||||
refreshInstance: () => Ref.get(providersRef),
|
||||
getProviderMaintenanceCapabilitiesForInstance: (_instanceId, provider) =>
|
||||
|
||||
@@ -9,6 +9,7 @@ export const makeProviderRegistryMock = (
|
||||
providers: ReadonlyArray<ServerProvider> = [],
|
||||
): ProviderRegistryShape => ({
|
||||
getProviders: Effect.succeed(providers),
|
||||
listSkills: () => Effect.succeed([]),
|
||||
refresh: () => Effect.succeed(providers),
|
||||
refreshInstance: () => Effect.succeed(providers),
|
||||
getProviderMaintenanceCapabilitiesForInstance: (_instanceId, provider) =>
|
||||
|
||||
@@ -4342,6 +4342,85 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
|
||||
);
|
||||
|
||||
it.effect("routes websocket rpc server.listProviderSkills with the active workspace cwd", () =>
|
||||
Effect.gen(function* () {
|
||||
const instanceId = ProviderInstanceId.make("codex_work");
|
||||
const projectId = ProjectId.make("project-skills");
|
||||
const threadId = ThreadId.make("thread-skills");
|
||||
const skills = [
|
||||
{
|
||||
name: "project-review",
|
||||
path: "/tmp/project-worktree/.agents/skills/project-review/SKILL.md",
|
||||
scope: "repo",
|
||||
enabled: true,
|
||||
},
|
||||
] as const;
|
||||
const receivedInputs: Array<{
|
||||
readonly instanceId: ProviderInstanceId;
|
||||
readonly cwd: string;
|
||||
}> = [];
|
||||
|
||||
yield* buildAppUnderTest({
|
||||
layers: {
|
||||
providerRegistry: {
|
||||
listSkills: (input) =>
|
||||
Effect.sync(() => {
|
||||
receivedInputs.push(input);
|
||||
return skills;
|
||||
}),
|
||||
},
|
||||
projectionSnapshotQuery: {
|
||||
getProjectShellById: (requestedProjectId) =>
|
||||
Effect.succeed(
|
||||
Option.some({
|
||||
...makeDefaultOrchestrationReadModel().projects[0]!,
|
||||
id: requestedProjectId,
|
||||
workspaceRoot: "/tmp/project",
|
||||
}),
|
||||
),
|
||||
getThreadShellById: (requestedThreadId) =>
|
||||
Effect.succeed(
|
||||
Option.some(
|
||||
makeDefaultOrchestrationThreadShell({
|
||||
id: requestedThreadId,
|
||||
projectId,
|
||||
worktreePath: "/tmp/project-worktree",
|
||||
}),
|
||||
),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const wsUrl = yield* getWsServerUrl("/ws");
|
||||
const responses = yield* Effect.scoped(
|
||||
withWsRpcClient(wsUrl, (client) =>
|
||||
Effect.gen(function* () {
|
||||
const projectResponse = yield* client[WS_METHODS.serverListProviderSkills]({
|
||||
instanceId,
|
||||
projectId,
|
||||
});
|
||||
const threadResponse = yield* client[WS_METHODS.serverListProviderSkills]({
|
||||
instanceId,
|
||||
projectId,
|
||||
threadId,
|
||||
});
|
||||
return [projectResponse, threadResponse] as const;
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
assert.deepEqual(receivedInputs, [
|
||||
{ instanceId, cwd: "/tmp/project" },
|
||||
{ instanceId, cwd: "/tmp/project-worktree" },
|
||||
]);
|
||||
assert.deepEqual(
|
||||
responses.map((response) => response.skills),
|
||||
[skills, skills],
|
||||
);
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
|
||||
);
|
||||
|
||||
it.effect("routes websocket rpc server.removeKeybinding", () =>
|
||||
Effect.gen(function* () {
|
||||
const rule: KeybindingRule = {
|
||||
|
||||
@@ -1389,6 +1389,36 @@ const makeWsRpcLayer = (
|
||||
).pipe(Effect.map((providers) => ({ providers }))),
|
||||
{ "rpc.aggregate": "server" },
|
||||
),
|
||||
[WS_METHODS.serverListProviderSkills]: (input) =>
|
||||
observeRpcEffect(
|
||||
WS_METHODS.serverListProviderSkills,
|
||||
Effect.gen(function* () {
|
||||
const project = yield* projectionSnapshotQuery
|
||||
.getProjectShellById(input.projectId)
|
||||
.pipe(Effect.orElseSucceed(() => Option.none()));
|
||||
if (Option.isNone(project)) {
|
||||
return { skills: [] };
|
||||
}
|
||||
|
||||
let cwd = project.value.workspaceRoot;
|
||||
if (input.threadId !== undefined) {
|
||||
const thread = yield* projectionSnapshotQuery
|
||||
.getThreadShellById(input.threadId)
|
||||
.pipe(Effect.orElseSucceed(() => Option.none()));
|
||||
if (Option.isNone(thread) || thread.value.projectId !== input.projectId) {
|
||||
return { skills: [] };
|
||||
}
|
||||
cwd = thread.value.worktreePath ?? cwd;
|
||||
}
|
||||
|
||||
const skills = yield* providerRegistry.listSkills({
|
||||
instanceId: input.instanceId,
|
||||
cwd,
|
||||
});
|
||||
return { skills };
|
||||
}),
|
||||
{ "rpc.aggregate": "server" },
|
||||
),
|
||||
[WS_METHODS.serverUpdateProvider]: (input) =>
|
||||
observeRpcEffect(
|
||||
WS_METHODS.serverUpdateProvider,
|
||||
|
||||
@@ -5921,6 +5921,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
routeKind={routeKind}
|
||||
routeThreadRef={routeThreadRef}
|
||||
draftId={draftId}
|
||||
activeProjectId={activeProject?.id ?? null}
|
||||
activeThreadId={activeThreadId}
|
||||
activeThreadEnvironmentId={activeThread?.environmentId}
|
||||
activeThread={activeThread}
|
||||
|
||||
@@ -3,12 +3,14 @@ import type {
|
||||
EnvironmentId,
|
||||
ModelSelection,
|
||||
PreviewAnnotationPayload,
|
||||
ProjectId,
|
||||
ProviderApprovalDecision,
|
||||
ProviderInteractionMode,
|
||||
ResolvedKeybindingsConfig,
|
||||
RuntimeMode,
|
||||
ScopedThreadRef,
|
||||
ServerProvider,
|
||||
ServerProviderSkill,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
@@ -76,6 +78,7 @@ import {
|
||||
removeInlineTerminalContextPlaceholder,
|
||||
} from "../../lib/terminalContext";
|
||||
import { useComposerPathSearch } from "../../lib/composerPathSearchState";
|
||||
import { useProviderSkills } from "../../state/queries";
|
||||
import { type ElementContextDraft } from "../../lib/elementContext";
|
||||
import { ComposerPendingElementContexts } from "./ComposerPendingElementContexts";
|
||||
import { ComposerPendingReviewComments } from "./ComposerPendingReviewComments";
|
||||
@@ -514,6 +517,7 @@ export interface ChatComposerProps {
|
||||
draftId: DraftId | null;
|
||||
|
||||
// Thread context
|
||||
activeProjectId: ProjectId | null;
|
||||
activeThreadId: ThreadId | null;
|
||||
activeThreadEnvironmentId: EnvironmentId | undefined;
|
||||
activeThread: Thread | undefined;
|
||||
@@ -628,10 +632,11 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
routeKind,
|
||||
routeThreadRef,
|
||||
draftId,
|
||||
activeProjectId,
|
||||
activeThreadId,
|
||||
activeThreadEnvironmentId: _activeThreadEnvironmentId,
|
||||
activeThread,
|
||||
isServerThread: _isServerThread,
|
||||
isServerThread,
|
||||
isLocalDraftThread: _isLocalDraftThread,
|
||||
forceExpandedOnMobile,
|
||||
projectSelectionRequired,
|
||||
@@ -875,7 +880,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
() => selectedProviderEntry?.models ?? [],
|
||||
[selectedProviderEntry],
|
||||
);
|
||||
|
||||
const composerPromptInjectionState = useMemo(
|
||||
() => getComposerPromptInjectionState(prompt),
|
||||
[prompt],
|
||||
@@ -1047,6 +1051,33 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
cwd: isPathTrigger ? gitCwd : null,
|
||||
query: isPathTrigger ? pathTriggerQuery : null,
|
||||
});
|
||||
const providerSkillsThreadId = isServerThread ? activeThreadId : null;
|
||||
const providerSkills = useProviderSkills({
|
||||
environmentId,
|
||||
instanceId: selectedInstanceId,
|
||||
projectId: activeProjectId,
|
||||
threadId: providerSkillsThreadId,
|
||||
enabled: composerTriggerKind === "skill",
|
||||
});
|
||||
const providerSkillsTargetKey = `${environmentId}\0${selectedInstanceId}\0${activeProjectId ?? ""}\0${providerSkillsThreadId ?? ""}`;
|
||||
const [cachedProviderSkills, setCachedProviderSkills] = useState<{
|
||||
readonly targetKey: string;
|
||||
readonly skills: ReadonlyArray<ServerProviderSkill>;
|
||||
} | null>(null);
|
||||
useEffect(() => {
|
||||
if (providerSkills.data) {
|
||||
setCachedProviderSkills({
|
||||
targetKey: providerSkillsTargetKey,
|
||||
skills: providerSkills.data.skills,
|
||||
});
|
||||
}
|
||||
}, [providerSkills.data, providerSkillsTargetKey]);
|
||||
const selectedProviderSkills =
|
||||
providerSkills.data?.skills ??
|
||||
(cachedProviderSkills?.targetKey === providerSkillsTargetKey
|
||||
? cachedProviderSkills.skills
|
||||
: selectedProviderStatus?.skills.filter((skill) => skill.scope !== "repo")) ??
|
||||
[];
|
||||
|
||||
const composerMenuItems = useMemo<ComposerCommandItem[]>(() => {
|
||||
if (!composerTrigger) return [];
|
||||
@@ -1102,22 +1133,26 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
return searchSlashCommandItems(slashCommandItems, query);
|
||||
}
|
||||
if (composerTrigger.kind === "skill") {
|
||||
return searchProviderSkills(selectedProviderStatus?.skills ?? [], composerTrigger.query).map(
|
||||
(skill) => ({
|
||||
id: `skill:${selectedProvider}:${skill.name}`,
|
||||
type: "skill" as const,
|
||||
provider: selectedProvider,
|
||||
skill,
|
||||
label: formatProviderSkillDisplayName(skill),
|
||||
description:
|
||||
skill.shortDescription ??
|
||||
skill.description ??
|
||||
(skill.scope ? `${skill.scope} skill` : "Run provider skill"),
|
||||
}),
|
||||
);
|
||||
return searchProviderSkills(selectedProviderSkills, composerTrigger.query).map((skill) => ({
|
||||
id: `skill:${selectedProvider}:${skill.name}`,
|
||||
type: "skill" as const,
|
||||
provider: selectedProvider,
|
||||
skill,
|
||||
label: formatProviderSkillDisplayName(skill),
|
||||
description:
|
||||
skill.shortDescription ??
|
||||
skill.description ??
|
||||
(skill.scope ? `${skill.scope} skill` : "Run provider skill"),
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
}, [composerTrigger, selectedProvider, selectedProviderStatus, workspaceEntries.entries]);
|
||||
}, [
|
||||
composerTrigger,
|
||||
selectedProvider,
|
||||
selectedProviderSkills,
|
||||
selectedProviderStatus,
|
||||
workspaceEntries.entries,
|
||||
]);
|
||||
|
||||
const composerMenuOpen = Boolean(composerTrigger);
|
||||
const composerMenuSearchKey = composerTrigger
|
||||
@@ -1182,7 +1217,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
]);
|
||||
|
||||
const isComposerMenuLoading =
|
||||
composerTriggerKind === "path" && pathTriggerQuery.length > 0 && workspaceEntries.isPending;
|
||||
(composerTriggerKind === "path" && pathTriggerQuery.length > 0 && workspaceEntries.isPending) ||
|
||||
(composerTriggerKind === "skill" && providerSkills.isPending && composerMenuItems.length === 0);
|
||||
const composerMenuEmptyState = useMemo(() => {
|
||||
if (composerTriggerKind === "skill") {
|
||||
return "No skills found. Try / to browse provider commands.";
|
||||
@@ -3048,7 +3084,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
? composerTerminalContexts
|
||||
: []
|
||||
}
|
||||
skills={selectedProviderStatus?.skills ?? []}
|
||||
skills={selectedProviderSkills}
|
||||
{...(showMobilePendingAnswerActions ? { className: "max-sm:pb-11" } : {})}
|
||||
onRemoveTerminalContext={removeComposerTerminalContextFromDraft}
|
||||
onChange={onPromptChange}
|
||||
|
||||
@@ -14,6 +14,8 @@ import type {
|
||||
OrchestrationThread,
|
||||
ProjectContentMatch,
|
||||
ProjectEntryKind,
|
||||
ProjectId,
|
||||
ProviderInstanceId,
|
||||
ThreadId,
|
||||
VcsListRefsResult,
|
||||
VcsRef,
|
||||
@@ -28,6 +30,7 @@ import { orchestrationEnvironment } from "./orchestration";
|
||||
import { isPaginatedBranchesNextPagePending } from "./paginatedBranches";
|
||||
import { projectContentSearch, projectEnvironment } from "./projects";
|
||||
import { useEnvironmentQuery } from "./query";
|
||||
import { serverEnvironment } from "./server";
|
||||
import { useEnvironmentThread } from "./threads";
|
||||
import { vcsEnvironment } from "./vcs";
|
||||
|
||||
@@ -297,6 +300,30 @@ export function useComposerPathSearch(target: ComposerPathSearchTarget) {
|
||||
return useProjectPathSearch(target, COMPOSER_PATH_SEARCH_LIMIT);
|
||||
}
|
||||
|
||||
export function useProviderSkills(target: {
|
||||
readonly environmentId: EnvironmentId | null;
|
||||
readonly instanceId: ProviderInstanceId | null;
|
||||
readonly projectId: ProjectId | null;
|
||||
readonly threadId: ThreadId | null;
|
||||
readonly enabled: boolean;
|
||||
}) {
|
||||
return useEnvironmentQuery(
|
||||
target.enabled &&
|
||||
target.environmentId !== null &&
|
||||
target.instanceId !== null &&
|
||||
target.projectId !== null
|
||||
? serverEnvironment.providerSkills({
|
||||
environmentId: target.environmentId,
|
||||
input: {
|
||||
instanceId: target.instanceId,
|
||||
projectId: target.projectId,
|
||||
...(target.threadId !== null ? { threadId: target.threadId } : {}),
|
||||
},
|
||||
})
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
interface ProjectContentSearchTarget {
|
||||
readonly environmentId: EnvironmentId | null;
|
||||
readonly cwd: string | null;
|
||||
|
||||
@@ -683,6 +683,11 @@ export function createServerEnvironmentAtoms<R, E>(
|
||||
tag: WS_METHODS.serverGetResourceTelemetryHistory,
|
||||
staleTimeMs: 5_000,
|
||||
}),
|
||||
providerSkills: createEnvironmentRpcQueryAtomFamily(runtime, {
|
||||
label: "environment-data:server:provider-skills",
|
||||
tag: WS_METHODS.serverListProviderSkills,
|
||||
staleTimeMs: 30_000,
|
||||
}),
|
||||
configProjection,
|
||||
welcome: createEnvironmentRpcSubscriptionAtomFamily(runtime, {
|
||||
label: "environment-data:server:welcome",
|
||||
|
||||
@@ -126,6 +126,8 @@ import {
|
||||
ServerConfig,
|
||||
ServerProviderUpdateError,
|
||||
ServerProviderUpdateInput,
|
||||
ServerProviderListSkillsInput,
|
||||
ServerProviderListSkillsResult,
|
||||
ServerLifecycleStreamEvent,
|
||||
ServerRemoveKeybindingInput,
|
||||
ServerRemoveKeybindingResult,
|
||||
@@ -223,6 +225,7 @@ export const WS_METHODS = {
|
||||
serverProbe: "server.probe",
|
||||
serverGetConfig: "server.getConfig",
|
||||
serverRefreshProviders: "server.refreshProviders",
|
||||
serverListProviderSkills: "server.listProviderSkills",
|
||||
serverUpdateProvider: "server.updateProvider",
|
||||
serverUpdateServer: "server.updateServer",
|
||||
serverUpdateServerWithProgress: "server.updateServerWithProgress",
|
||||
@@ -301,6 +304,12 @@ export const WsServerRefreshProvidersRpc = Rpc.make(WS_METHODS.serverRefreshProv
|
||||
error: EnvironmentAuthorizationError,
|
||||
});
|
||||
|
||||
export const WsServerListProviderSkillsRpc = Rpc.make(WS_METHODS.serverListProviderSkills, {
|
||||
payload: ServerProviderListSkillsInput,
|
||||
success: ServerProviderListSkillsResult,
|
||||
error: EnvironmentAuthorizationError,
|
||||
});
|
||||
|
||||
export const WsServerUpdateProviderRpc = Rpc.make(WS_METHODS.serverUpdateProvider, {
|
||||
payload: ServerProviderUpdateInput,
|
||||
success: ServerProviderUpdatedPayload,
|
||||
@@ -787,6 +796,7 @@ export const WsRpcGroup = RpcGroup.make(
|
||||
WsServerProbeRpc,
|
||||
WsServerGetConfigRpc,
|
||||
WsServerRefreshProvidersRpc,
|
||||
WsServerListProviderSkillsRpc,
|
||||
WsServerUpdateProviderRpc,
|
||||
WsServerUpdateServerRpc,
|
||||
WsServerUpdateServerWithProgressRpc,
|
||||
|
||||
@@ -96,6 +96,18 @@ export const ServerProviderSkill = Schema.Struct({
|
||||
});
|
||||
export type ServerProviderSkill = typeof ServerProviderSkill.Type;
|
||||
|
||||
export const ServerProviderListSkillsInput = Schema.Struct({
|
||||
instanceId: ProviderInstanceId,
|
||||
projectId: ProjectId,
|
||||
threadId: Schema.optional(ThreadId),
|
||||
});
|
||||
export type ServerProviderListSkillsInput = typeof ServerProviderListSkillsInput.Type;
|
||||
|
||||
export const ServerProviderListSkillsResult = Schema.Struct({
|
||||
skills: Schema.Array(ServerProviderSkill),
|
||||
});
|
||||
export type ServerProviderListSkillsResult = typeof ServerProviderListSkillsResult.Type;
|
||||
|
||||
/**
|
||||
* Availability of a configured provider instance from the runtime's POV.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user