Adding secrets to TypeScript Golem agents. Use when the user asks to add secrets, store API keys, manage sensitive config values, or use Secret<T> in TypeScript agents.
Secrets are sensitive configuration values (API keys, passwords, tokens) stored per-environment and accessed via Secret<T> from @golemcloud/golem-ts-sdk. Unlike regular config fields, secret values are fetched on demand and managed separately from the agent config.
Wrap sensitive fields with Secret<T> in your config type:
import { Config, Secret } from "@golemcloud/golem-ts-sdk";
type MyAgentConfig = {
name: string;
apiKey: Secret<string>;
db: {
host: string;
port: number;
password: Secret<string>;
};
};
Call on a field to fetch the current value:
.get()Secret<T>import { agent, BaseAgent, Config, Secret } from "@golemcloud/golem-ts-sdk";
@agent()
export class MyAgent extends BaseAgent {
constructor(readonly id: string, readonly config: Config<MyAgentConfig>) {
super();
}
connect(): string {
const cfg = this.config.value;
const key = cfg.apiKey.get();
const pwd = cfg.db.password.get();
return `Connecting to ${cfg.db.host}:${cfg.db.port}`;
}
}
# Create secrets (--secret-type uses language-native type names)
golem agent-secret create apiKey --secret-type string --secret-value "sk-abc123"
golem agent-secret create db.password --secret-type string --secret-value "s3cret"
# List, update, and delete
golem agent-secret list
golem agent-secret update-value apiKey --secret-value "new-value"
golem agent-secret delete apiKey
Note: For
update-valueanddelete, you can also use--id <uuid>instead of the positional path.
For development environments, define secret defaults in golem.yaml. These are not used in production:
secretDefaults:
local:
- path: [apiKey]
value: "dev-key-123"
- path: [db, password]
value: "dev-password"
Secret<T> fields are not loaded eagerly — call .get() to fetch the current value.config section of golem.yaml — use secretDefaults for dev environments only.--secret-type flag accepts TypeScript type names: string, s32, boolean, string[] (JSON-encoded analysed types like '{"type":"Str"}' are also supported as a fallback).golem-add-config-ts alongside this skill.