Interface: AgencyInstance<R>
Defined in: packages/agentos/src/api/types.ts:2125
What agency() returns: the Agency interface with typed results.
Assignable to Agency.
Extends
Type Parameters
R
R extends AgencyResult = AgencyResult
What generate() resolves to: PanelResult for a panel agency.
Methods
close()
close():
Promise<void>
Defined in: packages/agentos/src/api/types.ts:1310
Releases all in-memory state held by this agent.
Returns
Promise<void>
Inherited from
Agency.close
connect()?
optionalconnect():Promise<void>
Defined in: packages/agentos/src/api/types.ts:1329
Connects the agent to configured channel adapters (e.g. Discord, Slack). Present on agency instances only.
Returns
Promise<void>
Inherited from
Agency.connect
export()?
optionalexport(metadata?,options?):unknown
Defined in: packages/agentos/src/api/types.ts:1340
Exports the agent's full configuration as a portable object.
The returned AgentExportConfig (imported from ./agentExport.js)
can be serialized to JSON or YAML and re-imported via importAgent().
Parameters
metadata?
Record<string, unknown>
Optional human-readable metadata to attach.
options?
Redaction options; secrets are redacted unless redactSecrets is false.
redactSecrets?
boolean
Returns
unknown
A portable config object.
Inherited from
Agency.export
exportJSON()?
optionalexportJSON(metadata?,options?):string
Defined in: packages/agentos/src/api/types.ts:1348
Exports the agent's full configuration as a pretty-printed JSON string.
Parameters
metadata?
Record<string, unknown>
Optional human-readable metadata to attach.
options?
Redaction options; secrets are redacted unless redactSecrets is false.
redactSecrets?
boolean
Returns
string
JSON string with 2-space indentation.
Inherited from
Agency.exportJSON
generate()
generate(
prompt,opts?):Promise<R>
Defined in: packages/agentos/src/api/types.ts:2126
Generates a single reply (non-streaming).
Parameters
prompt
string
User prompt text.
opts?
Record<string, unknown>
Optional per-call overrides.
Returns
Promise<R>
The complete generation result including text, usage, and tool calls.
Overrides
Agency.generate
listen()?
optionallisten(opts?):Promise<{close: () =>Promise<void>;port:number;url:string; }>
Defined in: packages/agentos/src/api/types.ts:1322
Starts a loopback WebSocket listener on 127.0.0.1 that exchanges JSON text:
{ "text": "..." } in, { "text": "..." } out, one request at a time per
connection. It performs no speech recognition or synthesis; a binary frame
receives an audio_not_supported error and close code 1003. Present on
agency instances created with voice: { enabled: true }. Spoken calls use
VoiceSessionFactory.
Parameters
opts?
Listener options; port 0, the default, picks a free port.
port?
number
Returns
Promise<{ close: () => Promise<void>; port: number; url: string; }>
Resolves to the bound port, URL, and a close() teardown function.
Inherited from
Agency.listen
session()
session(
id?):unknown
Defined in: packages/agentos/src/api/types.ts:1302
Returns (or creates) a named conversation session.
Parameters
id?
string
Optional session identifier; auto-generated when omitted.
Returns
unknown
The session object for this ID.
Inherited from
Agency.session
stream()
stream(
prompt,opts?):AgencyStreamResult<R> &object
Defined in: packages/agentos/src/api/types.ts:2127
Streams a reply, returning a streaming result surface.
Single agents return a StreamTextResult with textStream, text,
usage, and toolCalls. Agencies return an AgencyStreamResult
with additional agentCalls, parsed, and finalTextStream fields.
Both are assignable to AgentStreamResult.
Parameters
prompt
string
User prompt text.
opts?
Record<string, unknown>
Optional per-call overrides.
Returns
AgencyStreamResult<R> & object
A streaming result with at least textStream, fullStream,
text, and usage.
Overrides
Agency.stream
usage()
usage(
sessionId?):Promise<unknown>
Defined in: packages/agentos/src/api/types.ts:1308
Returns cumulative usage totals for the agent or a specific session.
Parameters
sessionId?
string
Optional session filter.
Returns
Promise<unknown>
Inherited from
Agency.usage