@openagentpack/sdk 0.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1145 @@
1
+ import { R as ResourceAddress, a as ResourceType, C as CloudAgent, b as CloudEnvironment, c as CloudVault, E as EventStreamOptions, P as ProviderSessionEvent, d as EventListOptions, e as ProviderSessionEventList, f as PlannedAction, D as Diagnostic, A as AgentDefinition, g as AgentWithReadiness, h as AgentSyncRun } from './session-event-CmiO8Gqv.js';
2
+ export { i as ActionType, j as ActionTypeSchema, k as AgentDefinitionSchema, l as AgentDriftSeverity, m as AgentDriftSeveritySchema, n as AgentModel, o as AgentModelSchema, p as AgentReadiness, q as AgentReadinessSchema, r as AgentReadinessStatus, s as AgentReadinessStatusSchema, t as AgentRecoveryAction, u as AgentRecoveryActionSchema, v as AgentSkillRef, w as AgentSkillRefSchema, x as AgentSyncResult, y as AgentSyncResultSchema, z as AgentSyncRunSchema, B as AgentSyncStatus, F as AgentSyncStatusSchema, G as AgentWithReadinessSchema, H as CloudAgentSchema, I as CloudEnvironmentSchema, J as CloudVaultSchema, K as CreateSessionRequest, L as CreateSessionRequestSchema, M as CreateSessionResponse, N as CreateSessionResponseSchema, O as DiagnosticSchema, Q as DiagnosticSeverity, S as DiagnosticSeveritySchema, T as DriftKind, U as DriftKindSchema, V as GetSessionRequest, W as GetSessionRequestSchema, X as KNOWN_SESSION_EVENT_TYPES, Y as KnownSessionEventType, Z as ListCloudAgentsResponse, _ as ListCloudAgentsResponseSchema, $ as ListCloudEnvironmentsResponse, a0 as ListCloudEnvironmentsResponseSchema, a1 as ListSessionEventsRequest, a2 as ListSessionEventsRequestSchema, a3 as ListSessionEventsResponse, a4 as ListSessionEventsResponseSchema, a5 as ListSessionsRequest, a6 as ListSessionsRequestSchema, a7 as ListSessionsResponse, a8 as ListSessionsResponseSchema, a9 as PlannedActionSchema, aa as ResourceAddressSchema, ab as ResourceTypeSchema, ac as SendEventRequest, ad as SendEventRequestSchema, ae as SendEventResponse, af as SendEventResponseSchema, ag as Session, ah as SessionAgent, ai as SessionAgentSchema, aj as SessionContentBlock, ak as SessionContentBlockSchema, al as SessionEvent, am as SessionEventSchema, an as SessionEventType, ao as SessionEventTypeName, ap as SessionEventTypeSchema, aq as SessionSchema } from './session-event-CmiO8Gqv.js';
3
+ import { P as ProviderFileInfo } from './file-URqwlxLf.js';
4
+ import 'zod';
5
+
6
+ declare class UserError extends Error {
7
+ constructor(message: string);
8
+ }
9
+
10
+ type ProviderName = string;
11
+ interface ProjectConfig {
12
+ version: string;
13
+ providers: Record<string, unknown>;
14
+ defaults?: DefaultsConfig;
15
+ environments?: Record<string, EnvironmentDecl>;
16
+ vaults?: Record<string, VaultDecl>;
17
+ memory_stores?: Record<string, MemoryStoreDecl>;
18
+ skills?: Record<string, SkillDecl>;
19
+ files?: Record<string, FileDecl>;
20
+ agents?: Record<string, AgentDecl>;
21
+ deployments?: Record<string, DeploymentDecl>;
22
+ }
23
+ interface DefaultsConfig {
24
+ provider?: string;
25
+ }
26
+ interface EnvironmentDecl {
27
+ name?: string;
28
+ description?: string;
29
+ provider?: ProviderName;
30
+ config: EnvironmentConfig;
31
+ metadata?: Record<string, string>;
32
+ }
33
+ interface EnvironmentConfig {
34
+ type: "cloud";
35
+ networking?: NetworkingConfig;
36
+ packages?: PackagesConfig;
37
+ }
38
+ interface NetworkingConfig {
39
+ type: "unrestricted" | "limited";
40
+ allow_mcp_servers?: boolean;
41
+ allow_package_managers?: boolean;
42
+ allowed_hosts?: string[];
43
+ }
44
+ interface PackagesConfig {
45
+ apt?: string[];
46
+ pip?: string[];
47
+ npm?: string[];
48
+ cargo?: string[];
49
+ gem?: string[];
50
+ go?: string[];
51
+ }
52
+ interface VaultDecl {
53
+ display_name: string;
54
+ provider?: ProviderName;
55
+ credentials: CredentialDecl[];
56
+ metadata?: Record<string, string>;
57
+ }
58
+ type CredentialType = "static_bearer" | "environment_variable";
59
+ interface CredentialDecl {
60
+ name: string;
61
+ type: CredentialType;
62
+ mcp_server_url?: string;
63
+ access_token?: string;
64
+ protocol?: "sse" | "streamable_http";
65
+ secret_name?: string;
66
+ secret_value?: string;
67
+ networking?: {
68
+ type: "unrestricted" | "limited";
69
+ };
70
+ }
71
+ interface MemoryStoreDecl {
72
+ description: string;
73
+ provider?: ProviderName;
74
+ entries?: MemoryEntryDecl[];
75
+ }
76
+ interface MemoryEntryDecl {
77
+ key: string;
78
+ content: string;
79
+ }
80
+ interface SkillDecl {
81
+ name?: string;
82
+ source: string;
83
+ description?: string;
84
+ version?: string;
85
+ origin?: "custom" | "official";
86
+ provider?: ProviderName;
87
+ }
88
+ interface FileDecl {
89
+ source: string;
90
+ name?: string;
91
+ purpose?: string;
92
+ provider?: ProviderName;
93
+ }
94
+ interface ModelWithSpeed {
95
+ id: string;
96
+ speed?: "standard" | "fast";
97
+ }
98
+ type ModelSpec = string | ModelWithSpeed;
99
+ interface AgentDecl {
100
+ name?: string;
101
+ description?: string;
102
+ model: string | Record<ProviderName, ModelSpec>;
103
+ instructions: string;
104
+ environment?: string;
105
+ provider?: ProviderName;
106
+ tools?: AgentToolsDecl;
107
+ mcp_servers?: McpServerDecl[];
108
+ skills?: AgentSkillDecl[];
109
+ vault?: string;
110
+ memory_stores?: string[];
111
+ multiagent?: MultiagentDecl;
112
+ metadata?: Record<string, string>;
113
+ }
114
+ type AgentSkillDecl = string | AgentSkillRefDecl;
115
+ interface AgentSkillRefDecl {
116
+ type: "official" | "custom";
117
+ skill_id: string;
118
+ version?: string;
119
+ }
120
+ interface AgentToolsDecl {
121
+ builtin: string[];
122
+ mcp?: AgentMcpToolkitDecl[];
123
+ permissions?: Record<string, "allow" | "ask">;
124
+ }
125
+ interface AgentMcpToolkitDecl {
126
+ type: "mcp_toolkit";
127
+ mcp_server_name: string;
128
+ default_config?: {
129
+ enabled: boolean;
130
+ };
131
+ configs: Array<{
132
+ name: string;
133
+ enabled: boolean;
134
+ }>;
135
+ }
136
+ interface McpServerDecl {
137
+ name: string;
138
+ type?: "url" | "http" | "official";
139
+ url?: string;
140
+ }
141
+ interface MultiagentDecl {
142
+ type: "coordinator";
143
+ agents: string[];
144
+ }
145
+ interface DeploymentDecl {
146
+ agent: string;
147
+ agent_version?: number;
148
+ environment?: string;
149
+ vaults?: string[];
150
+ memory_stores?: string[];
151
+ resources?: DeploymentResourceDecl[];
152
+ initial_events: InitialEventDecl[];
153
+ schedule?: ScheduleDecl;
154
+ description?: string;
155
+ provider?: ProviderName;
156
+ metadata?: Record<string, string>;
157
+ }
158
+ type DeploymentResourceDecl = DeploymentFileResource | DeploymentMemoryStoreResource | DeploymentGithubRepoResource;
159
+ interface DeploymentFileResource {
160
+ type: "file";
161
+ file_id?: string;
162
+ source?: string;
163
+ mount_path?: string;
164
+ }
165
+ interface DeploymentMemoryStoreResource {
166
+ type: "memory_store";
167
+ memory_store: string;
168
+ access?: "read_write" | "read_only";
169
+ instructions?: string;
170
+ }
171
+ interface DeploymentGithubRepoResource {
172
+ type: "github_repository";
173
+ url: string;
174
+ checkout?: {
175
+ branch?: string;
176
+ commit?: string;
177
+ };
178
+ mount_path?: string;
179
+ authorization_token?: string;
180
+ }
181
+ type InitialEventDecl = InitialUserMessage | InitialSystemMessage | InitialDefineOutcome;
182
+ interface InitialUserMessage {
183
+ type: "user.message";
184
+ content: string;
185
+ }
186
+ interface InitialSystemMessage {
187
+ type: "system.message";
188
+ content: string;
189
+ }
190
+ interface InitialDefineOutcome {
191
+ type: "user.define_outcome";
192
+ description?: string;
193
+ rubric?: string;
194
+ rubric_file?: string;
195
+ max_iterations?: number;
196
+ }
197
+ interface ScheduleDecl {
198
+ expression: string;
199
+ timezone: string;
200
+ }
201
+ /**
202
+ * A ProjectConfig where all file references (instructions, memory entries)
203
+ * have been resolved to their inline content.
204
+ */
205
+ interface ResolvedProjectConfig extends ProjectConfig {
206
+ _resolved: true;
207
+ }
208
+
209
+ interface SessionFileResource {
210
+ file_id: string;
211
+ mount_path: string;
212
+ }
213
+ interface SessionBindings {
214
+ agent_id: string;
215
+ agent_version?: number;
216
+ /** Cloud sandbox id. Every provider runs sessions inside an environment. */
217
+ environment_id: string;
218
+ vault_ids: string[];
219
+ memory_store_ids: string[];
220
+ files?: SessionFileResource[];
221
+ title?: string;
222
+ metadata?: Record<string, string>;
223
+ }
224
+ interface ProviderSessionInfo {
225
+ id: string;
226
+ agent_id: string;
227
+ environment_id: string;
228
+ status: string;
229
+ title?: string;
230
+ vault_ids: string[];
231
+ memory_store_ids: string[];
232
+ created_at: string;
233
+ updated_at: string;
234
+ attributes: Record<string, unknown>;
235
+ }
236
+ interface SessionFilter {
237
+ agent_id?: string;
238
+ limit?: number;
239
+ page?: string;
240
+ }
241
+ interface SessionListResult {
242
+ sessions: ProviderSessionInfo[];
243
+ has_more: boolean;
244
+ next_page?: string;
245
+ }
246
+
247
+ interface SkillFile {
248
+ relativePath: string;
249
+ content: Buffer;
250
+ }
251
+
252
+ interface ProviderSkillInfo {
253
+ id: string;
254
+ name: string;
255
+ description?: string;
256
+ source: "custom" | "official";
257
+ status: "checking" | "active" | "rejected" | "deleted";
258
+ latest_version?: string;
259
+ created_at?: string;
260
+ updated_at?: string;
261
+ }
262
+
263
+ interface ResourceState {
264
+ address: ResourceAddress;
265
+ remote_id: string | null;
266
+ version?: number;
267
+ /**
268
+ * Backward-compatible alias for desired_hash. Kept while older state files
269
+ * and callers still read/write content_hash directly.
270
+ */
271
+ content_hash: string;
272
+ desired_hash?: string;
273
+ desired_comparable_hash?: string;
274
+ remote_hash?: string;
275
+ remote_snapshot?: unknown;
276
+ drift_status?: "in_sync" | "drifted" | "missing" | "unchecked";
277
+ }
278
+ interface StateFile {
279
+ resources: ResourceState[];
280
+ }
281
+
282
+ interface RemoteResource {
283
+ id: string | null;
284
+ type: string;
285
+ version?: number;
286
+ }
287
+ interface ModelInfo {
288
+ id: string;
289
+ display_name: string;
290
+ source: string;
291
+ is_enabled: boolean;
292
+ is_new: boolean;
293
+ price_factor?: number;
294
+ efforts?: string[];
295
+ default_effort?: string;
296
+ }
297
+ type DriftSupport = "full" | "existence" | "unsupported";
298
+ interface ComparableRemoteResource {
299
+ id: string | null;
300
+ type: string;
301
+ version?: number;
302
+ comparable: unknown;
303
+ snapshot?: unknown;
304
+ }
305
+ /**
306
+ * A remote resource reverse-mapped into a `agents.yaml` declaration, ready to be
307
+ * serialized under the matching top-level group (e.g. `vaults.<name>`).
308
+ * `name` is the yaml key; `decl` matches the corresponding zod schema shape.
309
+ */
310
+ interface ExportedResource {
311
+ name: string;
312
+ decl: Record<string, unknown>;
313
+ }
314
+ interface ResolvedAgentRefs {
315
+ skill_ids: Array<{
316
+ type: string;
317
+ skill_id: string;
318
+ version?: string;
319
+ }>;
320
+ multiagent_agent_ids?: string[];
321
+ }
322
+ interface ResolvedDeploymentRefs {
323
+ agent_id: string;
324
+ agent_version?: number;
325
+ environment_id: string;
326
+ vault_ids: string[];
327
+ memory_store_ids: Record<string, string>;
328
+ }
329
+ interface DeploymentContext {
330
+ id: string | null;
331
+ name: string;
332
+ decl: DeploymentDecl;
333
+ refs: ResolvedDeploymentRefs;
334
+ basePath: string;
335
+ }
336
+ interface DeploymentRunResult$1 {
337
+ run_id?: string;
338
+ session_id: string | null;
339
+ error?: {
340
+ type: string;
341
+ message: string;
342
+ };
343
+ }
344
+ interface DeploymentInfo$1 {
345
+ id: string | null;
346
+ status: string;
347
+ paused_reason?: {
348
+ type: string;
349
+ error?: {
350
+ type: string;
351
+ };
352
+ };
353
+ schedule?: {
354
+ expression: string;
355
+ timezone?: string;
356
+ };
357
+ attributes?: Record<string, unknown>;
358
+ }
359
+ interface ProviderAdapter {
360
+ readonly name: string;
361
+ /**
362
+ * Whether `sendSessionMessage` returns an event-id cursor the stream/poll can
363
+ * resume after. true → send-then-stream with `afterId`; false → connect-before-send.
364
+ */
365
+ readonly eventResume: boolean;
366
+ validate(): Promise<void>;
367
+ /**
368
+ * Locate a remote resource. When `id` is provided, the resource is verified
369
+ * precisely via its detail endpoint (`GET /{endpoint}/{id}`), which avoids the
370
+ * ambiguity of name matching when names are not unique. Without `id`, falls
371
+ * back to listing and matching by `name` (used by conflict adoption).
372
+ */
373
+ findResource(type: ResourceType, name: string, id?: string | null): Promise<RemoteResource | null>;
374
+ listAgents?(filter?: {
375
+ prefix?: string;
376
+ limit?: number;
377
+ }): Promise<CloudAgent[]>;
378
+ listEnvironments?(filter?: {
379
+ limit?: number;
380
+ }): Promise<CloudEnvironment[]>;
381
+ listVaults?(filter?: {
382
+ limit?: number;
383
+ }): Promise<CloudVault[]>;
384
+ getDriftSupport?(type: ResourceType): DriftSupport;
385
+ readComparableResource?(type: ResourceType, id: string | null, name: string): Promise<ComparableRemoteResource | null>;
386
+ normalizeDesiredResource?(type: ResourceType, name: string, decl: unknown): unknown | null;
387
+ /**
388
+ * Reverse-map remote resources of a given type into `agents.yaml` declarations
389
+ * (used by `agents sync`). Returns an empty array for unsupported types. Secret
390
+ * values that the provider does not return are emitted as `${ENV}` placeholders.
391
+ */
392
+ exportResources?(type: ResourceType): Promise<ExportedResource[]>;
393
+ createEnvironment(name: string, decl: EnvironmentDecl): Promise<RemoteResource>;
394
+ updateEnvironment(id: string, name: string, decl: EnvironmentDecl): Promise<RemoteResource>;
395
+ deleteEnvironment(id: string, cascade?: boolean): Promise<void>;
396
+ createVault(name: string, decl: VaultDecl): Promise<RemoteResource>;
397
+ deleteVault(id: string): Promise<void>;
398
+ createSkill(name: string, decl: SkillDecl, files: SkillFile[]): Promise<RemoteResource>;
399
+ updateSkill(id: string, name: string, decl: SkillDecl, files: SkillFile[]): Promise<RemoteResource>;
400
+ deleteSkill(id: string): Promise<void>;
401
+ createAgent(name: string, decl: AgentDecl, refs: ResolvedAgentRefs): Promise<RemoteResource>;
402
+ updateAgent(id: string, name: string, decl: AgentDecl, refs: ResolvedAgentRefs): Promise<RemoteResource>;
403
+ deleteAgent(id: string): Promise<void>;
404
+ createMemoryStore?(name: string, decl: MemoryStoreDecl): Promise<RemoteResource>;
405
+ deleteMemoryStore?(id: string): Promise<void>;
406
+ createDeployment(name: string, decl: DeploymentDecl, refs: ResolvedDeploymentRefs, basePath: string): Promise<RemoteResource>;
407
+ updateDeployment(id: string, name: string, decl: DeploymentDecl, refs: ResolvedDeploymentRefs, basePath: string): Promise<RemoteResource>;
408
+ deleteDeployment(id: string): Promise<void>;
409
+ runDeployment(ctx: DeploymentContext): Promise<DeploymentRunResult$1>;
410
+ getDeployment(ctx: DeploymentContext): Promise<DeploymentInfo$1>;
411
+ uploadFile(filePath: string, options?: {
412
+ name?: string;
413
+ purpose?: string;
414
+ }): Promise<ProviderFileInfo>;
415
+ /** Upload from in-memory content (no filesystem), for server contexts that receive bytes directly (e.g. webui browser uploads). */
416
+ uploadFileContent(content: Uint8Array, filename: string, options?: {
417
+ mimeType?: string;
418
+ purpose?: string;
419
+ }): Promise<ProviderFileInfo>;
420
+ deleteFile(id: string): Promise<void>;
421
+ /** Fetch a single file's metadata (incl. scan `status`); used to gate session binding on availability. */
422
+ getFileInfo?(id: string): Promise<ProviderFileInfo>;
423
+ /**
424
+ * Resolve a short-lived presigned download URL for a file (e.g. an agent-delivered artifact).
425
+ * Optional — only providers with a content/download endpoint implement it (qoder GET
426
+ * /files/{id}/content). Callers fetch it on demand so the URL never goes stale in the UI.
427
+ */
428
+ getFileDownloadUrl?(id: string): Promise<{
429
+ url: string;
430
+ expires_at?: string;
431
+ }>;
432
+ /** List workspace user-uploaded files (newest first). Optional — only providers with a list API implement it. */
433
+ listFiles?(): Promise<ProviderFileInfo[]>;
434
+ /**
435
+ * List skills (newest first). `source` selects the catalog: "custom" (workspace-uploaded, the
436
+ * default) or "official" (the provider's built-in catalog). Optional — only providers with a
437
+ * list API implement it.
438
+ */
439
+ listSkills?(source?: "custom" | "official"): Promise<ProviderSkillInfo[]>;
440
+ /** Fetch a single skill's metadata (incl. scan `status`); used to poll create → active. */
441
+ getSkillInfo?(id: string): Promise<ProviderSkillInfo>;
442
+ /**
443
+ * Create a skill from an already-uploaded zip's file_id and return immediately with the
444
+ * initial (usually `checking`) status. NON-blocking — unlike `createSkill`, it does NOT wait
445
+ * for the security scan. The webui polls `getSkillInfo` until `active`.
446
+ */
447
+ createSkillFromFileId?(fileId: string): Promise<ProviderSkillInfo>;
448
+ createSession(bindings: SessionBindings): Promise<ProviderSessionInfo>;
449
+ listSessions(filter?: SessionFilter): Promise<SessionListResult>;
450
+ getSession(id: string): Promise<ProviderSessionInfo>;
451
+ deleteSession(id: string): Promise<void>;
452
+ sendSessionMessage(sessionId: string, message: string): Promise<string | undefined>;
453
+ streamSessionEvents(sessionId: string, options?: EventStreamOptions): AsyncIterable<ProviderSessionEvent>;
454
+ listSessionEvents(sessionId: string, options?: EventListOptions): Promise<ProviderSessionEventList>;
455
+ listModels?(): Promise<ModelInfo[]>;
456
+ /**
457
+ * Download all remote skills and return their extracted file content.
458
+ * Used by `agents sync` to materialize skill sources locally.
459
+ * Returns a map of skill name → extracted SkillFile[].
460
+ */
461
+ downloadAllSkillFiles?(): Promise<Map<string, SkillFile[]>>;
462
+ }
463
+
464
+ interface IStateManager {
465
+ getResource(address: ResourceAddress): ResourceState | undefined;
466
+ setResource(resource: ResourceState): void;
467
+ removeResource(address: ResourceAddress): void;
468
+ listResources(): ResourceState[];
469
+ findResource(query: {
470
+ type: string;
471
+ name: string;
472
+ provider?: string;
473
+ }): ResourceState | undefined;
474
+ getStateFile(): StateFile;
475
+ save(): Promise<void>;
476
+ }
477
+ declare class StateManager implements IStateManager {
478
+ private state;
479
+ private path;
480
+ private index;
481
+ private constructor();
482
+ private buildIndex;
483
+ static load(path: string): Promise<StateManager>;
484
+ static initialize(path: string): StateManager;
485
+ getResource(address: ResourceAddress): ResourceState | undefined;
486
+ setResource(resource: ResourceState): void;
487
+ removeResource(address: ResourceAddress): void;
488
+ listResources(): ResourceState[];
489
+ findResource(query: {
490
+ type: string;
491
+ name: string;
492
+ provider?: string;
493
+ }): ResourceState | undefined;
494
+ getStateFile(): StateFile;
495
+ save(): Promise<void>;
496
+ }
497
+
498
+ interface StateScope {
499
+ projectId: string;
500
+ }
501
+ interface StateBackend {
502
+ read<T>(scope: StateScope, fn: (state: IStateManager) => Promise<T> | T): Promise<T>;
503
+ write<T>(scope: StateScope, fn: (state: IStateManager) => Promise<T> | T): Promise<T>;
504
+ }
505
+
506
+ interface ProjectRuntimeContext {
507
+ configPath?: string;
508
+ statePath?: string;
509
+ projectName: string;
510
+ config: ResolvedProjectConfig;
511
+ state: IStateManager;
512
+ providers: Map<string, ProviderAdapter>;
513
+ }
514
+ interface CreateRuntimeInput {
515
+ projectName: string;
516
+ config: ResolvedProjectConfig;
517
+ state: IStateManager;
518
+ configPath?: string;
519
+ providers?: Record<string, unknown>;
520
+ }
521
+ interface BackendRuntimeInput {
522
+ projectName: string;
523
+ config: ResolvedProjectConfig;
524
+ stateBackend: StateBackend;
525
+ stateScope: StateScope;
526
+ configPath?: string;
527
+ providers?: Record<string, unknown>;
528
+ }
529
+ /**
530
+ * Context-first entry point: create a ProjectRuntimeContext from pre-resolved objects.
531
+ * No file I/O is performed — the caller is responsible for loading and resolving config.
532
+ */
533
+ declare function createProjectRuntime(input: CreateRuntimeInput): ProjectRuntimeContext;
534
+ declare function readProjectRuntime<T>(input: BackendRuntimeInput, fn: (ctx: ProjectRuntimeContext) => Promise<T> | T): Promise<T>;
535
+ declare function writeProjectRuntime<T>(input: BackendRuntimeInput, fn: (ctx: ProjectRuntimeContext) => Promise<T> | T): Promise<T>;
536
+
537
+ interface ResolveProjectConfigOptions {
538
+ /** Override the derived project name (defaults to the config file's parent directory). */
539
+ projectName?: string;
540
+ /** Expand `${env:...}` references while loading (defaults to true). */
541
+ resolveEnv?: boolean;
542
+ }
543
+ interface LoadedProjectConfig {
544
+ configPath: string;
545
+ projectName: string;
546
+ config: ResolvedProjectConfig;
547
+ }
548
+ /**
549
+ * Shared config-resolution spine for every host: load the config file, raise
550
+ * configuration errors as a UserError, then resolve file references. Interfaces
551
+ * call this instead of re-implementing the load-and-resolve sequence.
552
+ */
553
+ declare function resolveProjectConfig(filePath: string, options?: ResolveProjectConfigOptions): Promise<LoadedProjectConfig>;
554
+ interface ResolveProjectConfigFromObjectOptions {
555
+ /** Project name to stamp onto the resolved config. */
556
+ projectName: string;
557
+ /** Base path used to resolve any `file:` references (defaults to process.cwd()). */
558
+ basePath?: string;
559
+ }
560
+ /**
561
+ * Object-level twin of {@link resolveProjectConfig}: validate an in-memory config
562
+ * object through the same zod schema and file-reference resolution instead of
563
+ * reading from disk. Hosts that assemble config from env + code (rather than a
564
+ * yaml file) use this so they don't bypass SDK invariants like the `_resolved` marker.
565
+ */
566
+ declare function resolveProjectConfigFromObject(rawConfig: unknown, options: ResolveProjectConfigFromObjectOptions): Promise<LoadedProjectConfig>;
567
+
568
+ interface ExecutionPlan {
569
+ actions: PlannedAction[];
570
+ diagnostics: Diagnostic[];
571
+ }
572
+
573
+ type RuntimeFeedbackLevel = "info" | "success" | "warning" | "error";
574
+ type RuntimeFeedbackType = "resource_action_success" | "resource_action_failed" | "resource_already_gone" | "resource_adopted" | "refresh_resource_missing" | "refresh_drift_unchecked" | "refresh_resource_failed" | "provider_wait";
575
+ interface RuntimeFeedbackEvent {
576
+ type: RuntimeFeedbackType;
577
+ level: RuntimeFeedbackLevel;
578
+ message: string;
579
+ action?: PlannedAction;
580
+ resource?: ResourceAddress;
581
+ }
582
+ type RuntimeFeedbackSink = (event: RuntimeFeedbackEvent) => void;
583
+
584
+ interface ResourceRuntimeOptions extends DestructiveDecisionOptions {
585
+ provider?: string;
586
+ refresh?: boolean;
587
+ refreshOnly?: boolean;
588
+ quiet?: boolean;
589
+ onFeedback?: RuntimeFeedbackSink;
590
+ }
591
+ interface ResourceRefreshResult {
592
+ removed: ResourceState[];
593
+ errors: Array<{
594
+ resource: ResourceState;
595
+ error: string;
596
+ }>;
597
+ }
598
+ interface ResourceActionResult {
599
+ action: PlannedAction;
600
+ status: "success" | "failed" | "skipped";
601
+ error?: string;
602
+ }
603
+ interface ResourceExecutionResult {
604
+ results: ResourceActionResult[];
605
+ partial: boolean;
606
+ }
607
+ interface ResourcePlanResult {
608
+ executionContext: ProjectRuntimeContext;
609
+ plan: ExecutionPlan;
610
+ refreshResult?: ResourceRefreshResult;
611
+ targetProviders?: string[];
612
+ destructiveActions: PlannedAction[];
613
+ }
614
+ type DestructivePolicy = "block" | "prompt" | "force";
615
+ interface DestructiveDecisionOptions {
616
+ policy?: DestructivePolicy;
617
+ confirm?: (actions: PlannedAction[]) => boolean | Promise<boolean>;
618
+ }
619
+ interface ResourceSyncRun {
620
+ planned: ResourcePlanResult;
621
+ execution?: ResourceExecutionResult;
622
+ }
623
+ declare function syncProjectResourcesWithStateBackend(input: BackendRuntimeInput, options?: ResourceRuntimeOptions): Promise<ResourceSyncRun>;
624
+ declare function importResource(ctx: ProjectRuntimeContext, address: ResourceAddress, remoteId: string, options?: {
625
+ resourceVersion?: number;
626
+ }): Promise<ResourceState>;
627
+ declare function planProjectContext(ctx: ProjectRuntimeContext, options?: ResourceRuntimeOptions): Promise<ResourcePlanResult>;
628
+ declare function executePlannedProject(planned: ResourcePlanResult, options?: DestructiveDecisionOptions & {
629
+ onFeedback?: RuntimeFeedbackSink;
630
+ concurrency?: number;
631
+ }): Promise<ResourceExecutionResult>;
632
+ declare function decideDestructive(destructiveActions: PlannedAction[], options?: DestructiveDecisionOptions): Promise<"proceed" | "blocked" | "cancelled">;
633
+
634
+ interface ValidateProjectConfigOptions {
635
+ /** Providers to capability-check. Defaults to the config's target providers. */
636
+ providers?: string[];
637
+ }
638
+ /** Full config validation: cross-references + provider capabilities. Used by `agents validate`/plan/apply. */
639
+ declare function validateProjectConfig(config: ProjectConfig, options?: ValidateProjectConfigOptions): Diagnostic[];
640
+ /**
641
+ * Reference checks only (no provider capabilities). The low-level primitive for hosts
642
+ * that must NOT run provider capability rules — e.g. webui playbooks use server-only MCP
643
+ * (no tools.mcp), which the Bailian capability check would wrongly flag.
644
+ */
645
+ declare function collectConfigReferences(config: ProjectConfig): Diagnostic[];
646
+
647
+ interface SyncProjectOptions {
648
+ /** Provider to read remote resources from (single provider, not "all"). */
649
+ provider: string;
650
+ /** Resource types to export. Defaults to ["vault"]. */
651
+ types?: ResourceType[];
652
+ /** When set, preserve the raw providers block from this config file in output. */
653
+ configPath?: string;
654
+ }
655
+ interface SecretPlaceholder {
656
+ vaultName: string;
657
+ credentialName: string;
658
+ envVar: string;
659
+ }
660
+ interface SyncProjectResult {
661
+ /** The assembled config object (version + providers + resource groups). */
662
+ config: Record<string, unknown>;
663
+ /** Serialized yaml, aligned with the plan/apply config format. */
664
+ yaml: string;
665
+ /** Count of exported resources per type. */
666
+ counts: Record<string, number>;
667
+ /** Downloaded skill files, keyed by skill name → extracted SkillFile[]. */
668
+ skillFiles?: Map<string, SkillFile[]>;
669
+ /** Vault credential secret placeholders that need user input. */
670
+ secretPlaceholders?: SecretPlaceholder[];
671
+ }
672
+ /**
673
+ * Pick the provider to sync from when --provider is omitted.
674
+ * Requires an on-disk config with an unambiguous default.
675
+ */
676
+ declare function resolveSyncProvider(config: Pick<ResolvedProjectConfig, "providers" | "defaults">, explicitProvider?: string): string;
677
+ /**
678
+ * Reverse-export a provider's remote resources WITHOUT a `agents.yaml`. The adapter
679
+ * is built from environment variables (e.g. ANTHROPIC_API_KEY), making this the
680
+ * first-run entry point: bootstrap a config from a remote account before any
681
+ * local file exists. The emitted `providers` block uses `${ENV}` placeholders.
682
+ */
683
+ declare function syncProviderResourcesFromEnv(opts: SyncProjectOptions): Promise<SyncProjectResult>;
684
+ /**
685
+ * Reverse-export using credentials from an existing project config/runtime context.
686
+ */
687
+ declare function syncProviderResourcesFromContext(ctx: ProjectRuntimeContext, opts: SyncProjectOptions): Promise<SyncProjectResult>;
688
+
689
+ interface MigrateOptions {
690
+ fromPath: string;
691
+ toPath: string;
692
+ }
693
+ interface MigrateResult {
694
+ added: Record<string, number>;
695
+ skipped: Record<string, number>;
696
+ yaml: string;
697
+ }
698
+ /**
699
+ * Migrate resources from a synced.yaml into an existing agents.yaml.
700
+ *
701
+ * - Uses the target agents.yaml's provider (from `defaults.provider` or the first provider key)
702
+ * - Appends resources that don't already exist (by YAML key)
703
+ * - Skips resources whose key already exists in the target
704
+ * - Replaces the `provider` field on each migrated resource with the target provider
705
+ */
706
+ declare function migrateConfig(opts: MigrateOptions): Promise<MigrateResult>;
707
+
708
+ /**
709
+ * The deployment-execution seam: trigger a run and read deployment status. The
710
+ * deployment runtime drives a configured deployment exclusively through this
711
+ * surface. The wide {@link import("./interface.ts").ProviderAdapter} structurally
712
+ * satisfies it; create/update/delete of deployments live in {@link ResourceCrudAdapter}.
713
+ */
714
+ interface DeploymentRunAdapter {
715
+ runDeployment(ctx: DeploymentContext): Promise<DeploymentRunResult$1>;
716
+ getDeployment(ctx: DeploymentContext): Promise<DeploymentInfo$1>;
717
+ }
718
+
719
+ interface DeploymentSummary {
720
+ name: string;
721
+ provider: string;
722
+ remoteId: string | null;
723
+ scheduleExpression: string;
724
+ agent: string;
725
+ state: ResourceState;
726
+ }
727
+ interface DeploymentBindings {
728
+ agentId: string;
729
+ environmentId: string;
730
+ vaultIds: string[];
731
+ memoryStoreIds: string[];
732
+ }
733
+ interface DeploymentInfo {
734
+ id: string | null;
735
+ status: string;
736
+ paused_reason?: {
737
+ type: string;
738
+ error?: {
739
+ type: string;
740
+ };
741
+ };
742
+ schedule?: {
743
+ expression: string;
744
+ timezone?: string;
745
+ };
746
+ attributes?: Record<string, unknown>;
747
+ }
748
+ interface DeploymentDetail {
749
+ name: string;
750
+ provider: string;
751
+ info: DeploymentInfo;
752
+ bindings: DeploymentBindings;
753
+ }
754
+ interface DeploymentRunResult {
755
+ run_id?: string;
756
+ session_id: string | null;
757
+ error?: {
758
+ type: string;
759
+ message: string;
760
+ };
761
+ }
762
+ interface DeploymentRun {
763
+ name: string;
764
+ provider: string;
765
+ result: DeploymentRunResult;
766
+ }
767
+ declare function listDeploymentsForContext(ctx: ProjectRuntimeContext, providerFilter?: string): DeploymentSummary[];
768
+ declare function getDeploymentDetailsForContext(ctx: ProjectRuntimeContext, name: string, adapter?: Pick<DeploymentRunAdapter, "getDeployment">, resolvedProvider?: string): Promise<DeploymentDetail>;
769
+ declare function runDeploymentForContext(ctx: ProjectRuntimeContext, name: string, adapter?: Pick<DeploymentRunAdapter, "runDeployment">, resolvedProvider?: string): Promise<DeploymentRun>;
770
+ declare function getDeploymentRuntimeProviderForContext(ctx: ProjectRuntimeContext, name: string, overrideProvider?: string): string;
771
+
772
+ type DestroyResourceStatus = "success" | "failed" | "blocked" | "skipped";
773
+ type DestroyResourceResultReason = "destroyed" | "already_gone" | "cascade_required" | "provider_missing" | "failed" | "skipped";
774
+ interface DestroyResourceResult {
775
+ resource: ResourceState;
776
+ status: DestroyResourceStatus;
777
+ reason: DestroyResourceResultReason;
778
+ error?: string;
779
+ cascaded?: boolean;
780
+ }
781
+ interface DestroyPlanResult {
782
+ resources: ResourceState[];
783
+ executionContext: ProjectRuntimeContext;
784
+ }
785
+ interface DestroyProjectOptions {
786
+ cascade?: boolean;
787
+ onFeedback?: RuntimeFeedbackSink;
788
+ onResourceStart?: (resource: ResourceState) => void;
789
+ onResourceResult?: (result: DestroyResourceResult) => void;
790
+ onCascadeRequired?: (result: DestroyResourceResult) => boolean | Promise<boolean>;
791
+ }
792
+ interface DestroyProjectResult extends DestroyPlanResult {
793
+ results: DestroyResourceResult[];
794
+ destroyed: number;
795
+ partial: boolean;
796
+ }
797
+ declare function planDestroyProjectContext(ctx: ProjectRuntimeContext): DestroyPlanResult;
798
+ declare function destroyPlannedProjectResources(planned: DestroyPlanResult, options?: DestroyProjectOptions): Promise<DestroyProjectResult>;
799
+
800
+ interface ProviderModelInfo {
801
+ id: string;
802
+ display_name: string;
803
+ source: string;
804
+ is_enabled: boolean;
805
+ is_new: boolean;
806
+ price_factor?: number;
807
+ efforts?: string[];
808
+ default_effort?: string;
809
+ }
810
+ interface ProviderModelListing {
811
+ provider: string;
812
+ supportsDynamicListing: boolean;
813
+ models: ProviderModelInfo[];
814
+ }
815
+ /**
816
+ * The model-listing seam: enumerate a provider's available models. Optional —
817
+ * only providers with dynamic model discovery implement it. The wide
818
+ * {@link import("../providers/interface.ts").ProviderAdapter} structurally satisfies it.
819
+ */
820
+ interface ModelListAdapter {
821
+ listModels?(): Promise<ModelInfo[]>;
822
+ }
823
+ /**
824
+ * Context-first entry point: list models from a pre-built providers Map.
825
+ * No file I/O is performed — the caller supplies the provider adapters.
826
+ */
827
+ declare function listProviderModelsForContext(providers: ReadonlyMap<string, ModelListAdapter>, providerFilter?: string): Promise<ProviderModelListing[]>;
828
+ declare function listProviderNames(): string[];
829
+
830
+ interface AgentSkillBuildInput {
831
+ kind: "official" | "custom";
832
+ /** Skill code/id for official skills. */
833
+ code?: string;
834
+ version?: string;
835
+ /** Name + source for custom (managed) skills. */
836
+ name?: string;
837
+ source?: string;
838
+ description?: string;
839
+ }
840
+ interface AgentMcpBuildInput {
841
+ serverName: string;
842
+ serverType: "official" | "url" | "http";
843
+ serverUrl?: string;
844
+ defaultEnabled?: boolean;
845
+ tools: Array<{
846
+ name: string;
847
+ enabled?: boolean;
848
+ }>;
849
+ }
850
+ interface AgentBuildInput {
851
+ description?: string;
852
+ model?: AgentDecl["model"];
853
+ instructions?: string;
854
+ environment?: string;
855
+ provider?: string;
856
+ builtinTools?: string[];
857
+ skills?: AgentSkillBuildInput[];
858
+ mcp?: AgentMcpBuildInput[];
859
+ metadata?: Record<string, string>;
860
+ }
861
+ interface BuiltAgent {
862
+ agent: AgentDecl;
863
+ /** Custom skills referenced by the agent, to be merged into config.skills. */
864
+ customSkills: Record<string, SkillDecl>;
865
+ }
866
+ /**
867
+ * Construct a normalized AgentDecl by overlaying neutral override fields onto an
868
+ * optional base agent. Owns the provider-specific encoding of tools/mcp/skills so
869
+ * callers (e.g. a WebUI catalog) don't hand-assemble core's config shapes.
870
+ */
871
+ declare function buildAgentDecl(base: AgentDecl | undefined, input: AgentBuildInput): BuiltAgent;
872
+
873
+ interface AgentResourcePlanOptions {
874
+ refresh?: boolean;
875
+ quiet?: boolean;
876
+ }
877
+ interface AgentResourceSyncOptions extends AgentResourcePlanOptions {
878
+ policy?: DestructivePolicy;
879
+ confirm?: (actions: PlannedAction[]) => boolean | Promise<boolean>;
880
+ }
881
+ /**
882
+ * List RAW cloud agents from the provider — the actual remote objects, not the local
883
+ * config agents that `listAgents` returns. This is what the resource center needs to
884
+ * surface same-name duplicates and identity-stamp drift (metadata.playbook vs agents.*) that
885
+ * the local view can't see. Resolves the single configured provider (or `options.provider`)
886
+ * and delegates to the adapter's optional `listAgents`; returns [] if unsupported.
887
+ */
888
+ declare function listCloudAgents(ctx: ProjectRuntimeContext, options?: {
889
+ provider?: string;
890
+ prefix?: string;
891
+ limit?: number;
892
+ }): Promise<CloudAgent[]>;
893
+ /**
894
+ * List RAW cloud environments — the shared base sandboxes (networking + packages) that
895
+ * sessions run inside. Not tied to any playbook/agent. Delegates to the adapter's optional
896
+ * `listEnvironments`; returns [] if unsupported.
897
+ */
898
+ declare function listCloudEnvironments(ctx: ProjectRuntimeContext, options?: {
899
+ provider?: string;
900
+ limit?: number;
901
+ }): Promise<CloudEnvironment[]>;
902
+ /** Create a cloud environment directly (used by the webui entry-check base-env provisioning). */
903
+ declare function createCloudEnvironment(ctx: ProjectRuntimeContext, name: string, decl: EnvironmentDecl, options?: {
904
+ provider?: string;
905
+ }): Promise<RemoteResource>;
906
+ /** Delete a cloud environment by remote id (used by the webui resource center). */
907
+ declare function deleteCloudEnvironment(ctx: ProjectRuntimeContext, id: string, options?: {
908
+ provider?: string;
909
+ }): Promise<void>;
910
+ /**
911
+ * List RAW cloud vaults — the shared credential stores bound to sessions via `vault_ids`.
912
+ * Not tied to any playbook/agent. Delegates to the adapter's optional `listVaults`; returns []
913
+ * if unsupported.
914
+ */
915
+ declare function listCloudVaults(ctx: ProjectRuntimeContext, options?: {
916
+ provider?: string;
917
+ limit?: number;
918
+ }): Promise<CloudVault[]>;
919
+ /** Create a cloud vault (+ its credentials) directly, for the webui's user-supplied-key flow. */
920
+ declare function createCloudVault(ctx: ProjectRuntimeContext, name: string, decl: VaultDecl, options?: {
921
+ provider?: string;
922
+ }): Promise<RemoteResource>;
923
+ /** Delete a cloud vault by remote id (used by the webui resource center). */
924
+ declare function deleteCloudVault(ctx: ProjectRuntimeContext, id: string, options?: {
925
+ provider?: string;
926
+ }): Promise<void>;
927
+ /** Archive a cloud agent (soft delete → status=archived). Used by the resource center's
928
+ * archive action; the bailian adapter maps this to POST /agents/{id}/archive. */
929
+ declare function archiveCloudAgent(ctx: ProjectRuntimeContext, id: string, options?: {
930
+ provider?: string;
931
+ }): Promise<void>;
932
+ declare function getAgent(ctx: ProjectRuntimeContext, agentId: string): AgentDefinition;
933
+ declare function listAgentsWithReadiness(ctx: ProjectRuntimeContext, options?: {
934
+ refresh?: boolean;
935
+ }): Promise<AgentWithReadiness[]>;
936
+ declare function syncAgentResourcesWithStateBackend(input: BackendRuntimeInput, agentId: string, options?: AgentResourceSyncOptions): Promise<AgentSyncRun>;
937
+
938
+ interface SessionCreateOptions {
939
+ environment?: string;
940
+ /**
941
+ * Explicit remote environment id. When set, it is bound directly (bypassing the
942
+ * config-name → state resolution), letting callers that already hold a provider
943
+ * environment id (e.g. the webui) pin the sandbox without declaring it in config.
944
+ * Takes precedence over `environment` / the agent's declared environment.
945
+ */
946
+ environmentId?: string;
947
+ vault?: string;
948
+ /**
949
+ * Explicit remote vault ids. When set, they are bound directly (bypassing the
950
+ * config-name → state resolution), letting callers that already hold provider
951
+ * vault ids (e.g. the webui) bind a user-supplied credential vault without
952
+ * declaring it in config. Takes precedence over `vault` / the agent's vault.
953
+ */
954
+ vaultIds?: string[];
955
+ memoryStores?: string[];
956
+ /** Uploaded files to mount as session resources, so the task can read the user's files. */
957
+ files?: {
958
+ fileId: string;
959
+ mountPath: string;
960
+ }[];
961
+ title?: string;
962
+ provider?: string;
963
+ metadata?: Record<string, string>;
964
+ }
965
+ declare function resolveSessionProvider(agentName: string, config: ProjectConfig, overrideProvider?: string): string;
966
+
967
+ interface SessionRuntimeTarget {
968
+ agent?: string;
969
+ provider?: string;
970
+ }
971
+ interface SessionRuntimeCreateOptions extends SessionCreateOptions, SessionRuntimeTarget {
972
+ }
973
+ interface SessionRuntimeRunOptions extends SessionRuntimeCreateOptions {
974
+ pollIntervalMs?: number;
975
+ pollTimeoutMs?: number;
976
+ }
977
+ interface SessionRuntimeSendOptions extends SessionRuntimeTarget {
978
+ pollIntervalMs?: number;
979
+ pollTimeoutMs?: number;
980
+ }
981
+ interface CreatedSessionRun {
982
+ agentName: string;
983
+ provider: string;
984
+ session: ProviderSessionInfo;
985
+ }
986
+ interface StreamingSessionRun extends CreatedSessionRun {
987
+ events: AsyncIterable<ProviderSessionEvent>;
988
+ }
989
+ interface CollectedSessionEvents {
990
+ eventId?: string;
991
+ terminalStatus: string;
992
+ result: ProviderSessionEventList;
993
+ }
994
+ interface SessionSummary {
995
+ session: ProviderSessionInfo;
996
+ provider: string;
997
+ agentId?: string;
998
+ agentName?: string;
999
+ }
1000
+ interface SessionSummaryList {
1001
+ provider: string;
1002
+ summaries: SessionSummary[];
1003
+ hasMore: boolean;
1004
+ nextPage?: string;
1005
+ }
1006
+ declare function isTerminalSessionStatus(status: string | undefined): boolean;
1007
+ declare function createSessionForAgent(ctx: ProjectRuntimeContext, options?: SessionRuntimeCreateOptions): Promise<CreatedSessionRun>;
1008
+ declare function startSessionRun(ctx: ProjectRuntimeContext, prompt: string, options?: SessionRuntimeRunOptions): Promise<StreamingSessionRun>;
1009
+ declare function sendSessionMessageStreaming(ctx: ProjectRuntimeContext, sessionId: string, message: string, options?: SessionRuntimeSendOptions): Promise<AsyncIterable<ProviderSessionEvent>>;
1010
+ declare function startSessionRunPolling(ctx: ProjectRuntimeContext, prompt: string, options?: SessionRuntimeRunOptions): Promise<CreatedSessionRun & CollectedSessionEvents>;
1011
+ declare function sendSessionMessagePolling(ctx: ProjectRuntimeContext, sessionId: string, message: string, options?: SessionRuntimeSendOptions): Promise<CollectedSessionEvents>;
1012
+ declare function listSessionSummaries(ctx: ProjectRuntimeContext, options?: SessionRuntimeTarget & {
1013
+ filter?: SessionFilter;
1014
+ }): Promise<SessionSummaryList>;
1015
+ declare function getSession(ctx: ProjectRuntimeContext, sessionId: string, provider?: string): Promise<ProviderSessionInfo>;
1016
+ declare function deleteSession(ctx: ProjectRuntimeContext, sessionId: string, provider?: string): Promise<void>;
1017
+ declare function listSessionEvents(ctx: ProjectRuntimeContext, sessionId: string, options?: SessionRuntimeTarget & {
1018
+ limit?: number;
1019
+ order?: string;
1020
+ page_token?: string;
1021
+ page?: string;
1022
+ }): Promise<ProviderSessionEventList>;
1023
+ /**
1024
+ * Upload a file's raw bytes to the resolved provider's Files API and return its metadata.
1025
+ * Content-based (no filesystem) so server contexts can forward browser uploads directly.
1026
+ */
1027
+ declare function uploadFile(ctx: ProjectRuntimeContext, content: Uint8Array, filename: string, options?: SessionRuntimeTarget & {
1028
+ mimeType?: string;
1029
+ purpose?: string;
1030
+ }): Promise<ProviderFileInfo & {
1031
+ available: boolean;
1032
+ }>;
1033
+ /** Delete a previously uploaded file by id from the resolved provider's Files API. */
1034
+ declare function deleteFile(ctx: ProjectRuntimeContext, id: string, options?: SessionRuntimeTarget): Promise<void>;
1035
+ /** Fetch a single file's metadata (incl. scan `status`), to gate session binding on availability. */
1036
+ declare function getFileInfo(ctx: ProjectRuntimeContext, id: string, options?: SessionRuntimeTarget): Promise<ProviderFileInfo & {
1037
+ available: boolean;
1038
+ }>;
1039
+ /** Resolve a short-lived presigned download URL for a file (e.g. an agent-delivered artifact). */
1040
+ declare function getFileDownloadUrl(ctx: ProjectRuntimeContext, id: string, options?: SessionRuntimeTarget): Promise<{
1041
+ url: string;
1042
+ expires_at?: string;
1043
+ }>;
1044
+ /** List workspace user-uploaded files (newest first) from the resolved provider's Files API.
1045
+ * Returns [] when the provider lacks file listing (graceful degradation, mirrors cloud listing). */
1046
+ declare function listFiles(ctx: ProjectRuntimeContext, options?: SessionRuntimeTarget): Promise<Array<ProviderFileInfo & {
1047
+ available: boolean;
1048
+ }>>;
1049
+ /** List skills (newest first) from the resolved provider's Skills API. `source` selects the
1050
+ * catalog: "custom" (workspace-uploaded, the default) or "official" (the built-in catalog).
1051
+ * Returns [] when the provider lacks skill listing (graceful degradation, mirrors cloud listing). */
1052
+ declare function listSkills(ctx: ProjectRuntimeContext, options?: SessionRuntimeTarget & {
1053
+ source?: "custom" | "official";
1054
+ }): Promise<ProviderSkillInfo[]>;
1055
+ /** Fetch a single skill's metadata (incl. scan `status`), to poll create → active. */
1056
+ declare function getSkillInfo(ctx: ProjectRuntimeContext, id: string, options?: SessionRuntimeTarget): Promise<ProviderSkillInfo>;
1057
+ /** Create a skill from an uploaded zip's file_id (non-blocking; returns initial scan status). */
1058
+ declare function createSkillFromFileId(ctx: ProjectRuntimeContext, fileId: string, options?: SessionRuntimeTarget): Promise<ProviderSkillInfo>;
1059
+ /** Delete a custom skill by id from the resolved provider's Skills API. */
1060
+ declare function deleteSkill(ctx: ProjectRuntimeContext, id: string, options?: SessionRuntimeTarget): Promise<void>;
1061
+ /**
1062
+ * Subscribe to a session's live event stream by id (native SSE). The underlying provider
1063
+ * stream pushes only post-connect events, so callers that need full history must replay it
1064
+ * via listSessionEvents and de-dupe by ProviderSessionEvent.id.
1065
+ */
1066
+ declare function streamSessionEvents(ctx: ProjectRuntimeContext, sessionId: string, options?: SessionRuntimeTarget & EventStreamOptions): AsyncIterable<ProviderSessionEvent>;
1067
+
1068
+ /** Files as carried by `SessionBindings.files` — only `mount_path` matters for the hint. */
1069
+ interface MountedFile {
1070
+ mount_path: string;
1071
+ }
1072
+ /** Prepend the file-mount hint to a prompt. Returns the prompt unchanged when there are no files. */
1073
+ declare function prependFileHint(prompt: string, files: MountedFile[] | undefined, provider: string): string;
1074
+ /** 将 prompt 内 ⟦file:mountPath⟧ 占位符替换为 provider 感知的真实 sandbox 路径 */
1075
+ declare function rewriteFileMentions(prompt: string, provider: string): string;
1076
+ /** 发送给 provider 前统一处理:先替换 mention 占位符,再 prepend 文件 hint */
1077
+ declare function preparePromptForProvider(prompt: string, files: MountedFile[] | undefined, provider: string): string;
1078
+
1079
+ /**
1080
+ * Resolve a provider's config block from environment variables (actual values, not
1081
+ * `${ENV}` placeholders). Throws when a required field's env var is unset. Used both
1082
+ * by `buildProviderFromEnv` and by servers that assemble a raw project config object
1083
+ * (e.g. the server) and feed it through `resolveProjectConfigFromObject`.
1084
+ */
1085
+ declare function resolveProviderConfigFromEnv(providerName: string): Record<string, string>;
1086
+
1087
+ declare const AGENTS_CONFIG_PROVIDERS: readonly ["bailian", "qoder", "ark", "claude"];
1088
+ type ProviderConfigProvider = (typeof AGENTS_CONFIG_PROVIDERS)[number];
1089
+ declare const AGENTS_PROVIDER_FIELDS: Record<ProviderConfigProvider, readonly {
1090
+ key: string;
1091
+ label: string;
1092
+ secret: boolean;
1093
+ }[]>;
1094
+ type ProviderConfig = {
1095
+ AGENTS_PROVIDER: ProviderConfigProvider;
1096
+ [key: string]: string;
1097
+ };
1098
+ declare function providerConfigPath(): string;
1099
+ /** Active provider after bootstrap — defaults to bailian when unset. */
1100
+ declare function resolveActiveProvider(): ProviderConfigProvider;
1101
+ /** Whether the current process env has all required fields for the active provider. */
1102
+ declare function areRuntimeCredentialsReady(): boolean;
1103
+ /** Load the nearest `.env` walking up from `startDir` (at most 10 levels). */
1104
+ declare function loadDotEnv(startDir?: string): string | undefined;
1105
+ /** Apply config.json provider fields to `process.env`. With `force: false`, only unset vars are filled. */
1106
+ declare function applyProviderConfigToEnv(config: ProviderConfig, { force }?: {
1107
+ force?: boolean;
1108
+ }): void;
1109
+ /** Load ~/.agents/config.json into `process.env`. Bootstrap passes `{ force: true }` so config.json wins. */
1110
+ declare function loadProviderConfigIntoEnvSync(options?: {
1111
+ force?: boolean;
1112
+ }): void;
1113
+ /** Async variant for servers that prefer non-blocking I/O at startup. */
1114
+ declare function loadProviderConfigIntoEnv(options?: {
1115
+ force?: boolean;
1116
+ }): Promise<void>;
1117
+ /**
1118
+ * Runtime credential bootstrap:
1119
+ * 1. `.env` (and pre-set shell env) — lowest priority for provider fields
1120
+ * 2. `~/.agents/config.json` — highest priority; overrides conflicting provider fields
1121
+ */
1122
+ declare function bootstrapRuntimeCredentialsSync(startDir?: string): void;
1123
+ declare function bootstrapRuntimeCredentials(startDir?: string): Promise<void>;
1124
+
1125
+ declare function parseStateAddress(address: string, options?: {
1126
+ requireProvider?: boolean;
1127
+ }): ResourceAddress;
1128
+
1129
+ interface LocalFileStateBackendOptions {
1130
+ configPath?: string;
1131
+ statePath?: string;
1132
+ }
1133
+ declare class LocalFileStateBackend implements StateBackend {
1134
+ private readonly configPath?;
1135
+ private readonly statePath?;
1136
+ constructor(options?: LocalFileStateBackendOptions);
1137
+ read<T>(scope: StateScope, fn: (state: IStateManager) => Promise<T> | T): Promise<T>;
1138
+ write<T>(scope: StateScope, fn: (state: IStateManager) => Promise<T> | T): Promise<T>;
1139
+ getStatePath(_scope: StateScope): string;
1140
+ }
1141
+
1142
+ /** Normalize a skill zip and extract its entries to SkillFile[]. */
1143
+ declare function extractSkillZipFiles(raw: Buffer): Promise<SkillFile[]>;
1144
+
1145
+ export { AGENTS_CONFIG_PROVIDERS, AGENTS_PROVIDER_FIELDS, type AgentBuildInput, AgentDefinition, type AgentMcpBuildInput, type AgentSkillBuildInput, AgentSyncRun, AgentWithReadiness, type BackendRuntimeInput, CloudAgent, CloudEnvironment, CloudVault, type CollectedSessionEvents, type DestroyResourceResult, type DestructivePolicy, Diagnostic, type IStateManager, type LoadedProjectConfig, LocalFileStateBackend, type MigrateOptions, type MigrateResult, PlannedAction, type ProjectRuntimeContext, type ProviderConfig, type ProviderConfigProvider, ProviderFileInfo, ProviderSessionEvent, type ProviderSessionInfo, type ProviderSkillInfo, type ResolvedProjectConfig, type ResourceActionResult, ResourceAddress, type ResourceExecutionResult, type ResourcePlanResult, type ResourceRefreshResult, type ResourceRuntimeOptions, type ResourceState, type ResourceSyncRun, ResourceType, type RuntimeFeedbackEvent, type RuntimeFeedbackSink, type SecretPlaceholder, type SkillFile, StateManager, type StateScope, type SyncProjectOptions, type SyncProjectResult, UserError, type ValidateProjectConfigOptions, applyProviderConfigToEnv, archiveCloudAgent, areRuntimeCredentialsReady, bootstrapRuntimeCredentials, bootstrapRuntimeCredentialsSync, buildAgentDecl, collectConfigReferences, createCloudEnvironment, createCloudVault, createProjectRuntime, createSessionForAgent, createSkillFromFileId, decideDestructive, deleteCloudEnvironment, deleteCloudVault, deleteFile, deleteSession, deleteSkill, destroyPlannedProjectResources, executePlannedProject, extractSkillZipFiles, getAgent, getDeploymentDetailsForContext, getDeploymentRuntimeProviderForContext, getFileDownloadUrl, getFileInfo, getSession, getSkillInfo, importResource, isTerminalSessionStatus, listAgentsWithReadiness, listCloudAgents, listCloudEnvironments, listCloudVaults, listDeploymentsForContext, listFiles, listProviderModelsForContext, listProviderNames, listSessionEvents, listSessionSummaries, listSkills, loadDotEnv, loadProviderConfigIntoEnv, loadProviderConfigIntoEnvSync, migrateConfig, parseStateAddress, planDestroyProjectContext, planProjectContext, preparePromptForProvider, prependFileHint, providerConfigPath, readProjectRuntime, resolveActiveProvider, resolveProjectConfig, resolveProjectConfigFromObject, resolveProviderConfigFromEnv, resolveSessionProvider, resolveSyncProvider, rewriteFileMentions, runDeploymentForContext, sendSessionMessagePolling, sendSessionMessageStreaming, startSessionRun, startSessionRunPolling, streamSessionEvents, syncAgentResourcesWithStateBackend, syncProjectResourcesWithStateBackend, syncProviderResourcesFromContext, syncProviderResourcesFromEnv, uploadFile, validateProjectConfig, writeProjectRuntime };