Skip to content

Commit 4c7ef0c

Browse files
committed
feat(managed-agent): add scoped agent create command
Add `bl managed-agent agent create` with automatic YAML key generation, atomic config updates, preview-by-default behavior, and create-only scoped apply that ignores unrelated resource drift.
1 parent 69c1fb9 commit 4c7ef0c

12 files changed

Lines changed: 902 additions & 122 deletions

File tree

packages/cli/src/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ import {
152152
managedAgentSessionEvents,
153153
managedAgentSkillList,
154154
managedAgentCapabilities,
155+
managedAgentAgentCreate,
155156
managedAgentAgentList,
156157
managedAgentAgentGet,
157158
managedAgentAgentSearch,
@@ -350,6 +351,7 @@ export const commands: Record<string, AnyCommand> = {
350351
"managed-agent session events": managedAgentSessionEvents,
351352
"managed-agent skill-list": managedAgentSkillList,
352353
"managed-agent capabilities": managedAgentCapabilities,
354+
"managed-agent agent create": managedAgentAgentCreate,
353355
"managed-agent agent list": managedAgentAgentList,
354356
"managed-agent agent get": managedAgentAgentGet,
355357
"managed-agent agent search": managedAgentAgentSearch,

packages/commands/src/commands/managed-agent/_engine/credentials.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,16 @@ export function normalizeInterpolatedProviderBlocks(providers: Record<string, un
170170
* provider's `api_key` resolved empty (missing env var, or no bl login for
171171
* bailian). Replaces the SDK's raw `Environment variable '...' is not set` /
172172
* zod config error with a clean message plus a provider-specific hint. Validates
173-
* every declared provider, so a project is only runnable once all its providers'
174-
* keys are available; offline commands skip the check entirely.
173+
* every declared provider by default. A scoped operation may pass its exact
174+
* provider list so unrelated credentials cannot block it; offline commands skip
175+
* the check entirely.
175176
*/
176-
export function assertProviderCredentials(providers: Record<string, unknown>): void {
177+
export function assertProviderCredentials(
178+
providers: Record<string, unknown>,
179+
targetProviders?: readonly string[],
180+
): void {
177181
for (const [name, raw] of Object.entries(providers)) {
182+
if (targetProviders && !targetProviders.includes(name)) continue;
178183
if (!raw || typeof raw !== "object") continue;
179184
const block = raw as Record<string, unknown>;
180185
if (!("api_key" in block)) continue;

packages/commands/src/commands/managed-agent/_engine/file-state-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
type StateScope,
77
} from "@openagentpack/sdk";
88

9-
function createStateScope(configPath: string, projectName?: string): StateScope {
9+
export function createFileStateScope(configPath: string, projectName?: string): StateScope {
1010
const resolved = resolve(configPath);
1111
return { projectId: projectName ?? basename(dirname(resolved)) };
1212
}
@@ -19,6 +19,6 @@ export async function loadFileState(
1919
): Promise<IStateManager> {
2020
const resolved = resolve(configPath);
2121
const backend = new LocalFileStateBackend({ configPath: resolved, statePath });
22-
const path = backend.getStatePath(createStateScope(resolved, projectName));
22+
const path = backend.getStatePath(createFileStateScope(resolved, projectName));
2323
return StateManager.load(path);
2424
}

0 commit comments

Comments
 (0)