6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
88 lines
2.8 KiB
TypeScript
88 lines
2.8 KiB
TypeScript
/**
|
|
* Shared scaffolding for the Managed Agent session-operation tools.
|
|
*
|
|
* Every operation authenticates the same way (a Claude Platform
|
|
* service-account credential the executor resolves into `accessToken`) and
|
|
* most address an existing session by id, so those parameter definitions and
|
|
* the guard that reads them live here rather than being restated per tool.
|
|
*/
|
|
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
/** Credential picker value; the executor swaps it for `accessToken` at run time. */
|
|
export const CREDENTIAL_PARAM = {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Claude Platform credential (Anthropic workspace API key) to act with.',
|
|
} as const
|
|
|
|
/** Decrypted workspace API key injected by the executor. Never set by the author. */
|
|
export const ACCESS_TOKEN_PARAM = {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'hidden',
|
|
description: 'Workspace API key injected by the executor from the selected credential.',
|
|
} as const
|
|
|
|
export const SESSION_ID_PARAM = {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Anthropic session id (sesn_...) to act on.',
|
|
} as const
|
|
|
|
/**
|
|
* `ToolConfig` requires a `request` shape even when `directExecution`
|
|
* short-circuits the HTTP path, so every session-operation tool reuses this
|
|
* inert stub instead of repeating it.
|
|
*/
|
|
export const UNUSED_REQUEST: ToolConfig['request'] = {
|
|
url: () => '',
|
|
method: 'POST',
|
|
headers: () => ({}),
|
|
}
|
|
|
|
/** Params common to every session-operation tool. */
|
|
export interface ManagedAgentSessionParams {
|
|
credential: string
|
|
accessToken?: string
|
|
sessionId?: string
|
|
}
|
|
|
|
/**
|
|
* Validates the two things every session operation needs. Returns a message on
|
|
* failure so each tool can surface it as a normal tool error rather than
|
|
* throwing — a missing credential is an author mistake, not an exception.
|
|
*/
|
|
export function resolveSessionTarget(
|
|
params: ManagedAgentSessionParams
|
|
): { ok: true; apiKey: string; sessionId: string } | { ok: false; error: string } {
|
|
const apiKey = params.accessToken
|
|
if (!apiKey) {
|
|
return {
|
|
ok: false,
|
|
error: 'No Claude Platform credential is selected, or it could not be resolved.',
|
|
}
|
|
}
|
|
const sessionId = params.sessionId?.trim()
|
|
if (!sessionId) {
|
|
return { ok: false, error: 'A session id is required.' }
|
|
}
|
|
return { ok: true, apiKey, sessionId }
|
|
}
|
|
|
|
/** Validates the credential alone, for operations that do not target a session. */
|
|
export function resolveApiKey(
|
|
params: Pick<ManagedAgentSessionParams, 'accessToken'>
|
|
): { ok: true; apiKey: string } | { ok: false; error: string } {
|
|
const apiKey = params.accessToken
|
|
if (!apiKey) {
|
|
return {
|
|
ok: false,
|
|
error: 'No Claude Platform credential is selected, or it could not be resolved.',
|
|
}
|
|
}
|
|
return { ok: true, apiKey }
|
|
}
|