@openagentpack/sdk 0.2.0-beta.0 → 0.3.0-beta-fb9e73b-20260721
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.
- package/dist/index.d.ts +206 -10
- package/dist/index.js +1159 -225
- package/dist/{session-event-CObCawiI.d.ts → session-event-CxLg_XqS.d.ts} +51 -7
- package/dist/session-events.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,9 +35,22 @@ var REQUIRED_METHODS_BY_KIND = {
|
|
|
35
35
|
skill: ["createSkill", "updateSkill", "deleteSkill"],
|
|
36
36
|
agent: ["createAgent", "updateAgent", "deleteAgent"],
|
|
37
37
|
template: ["createTemplate", "updateTemplate", "archiveTemplate"],
|
|
38
|
-
memory_store: [
|
|
38
|
+
memory_store: [
|
|
39
|
+
"createMemoryStore",
|
|
40
|
+
"deleteMemoryStore",
|
|
41
|
+
"listMemoryStores",
|
|
42
|
+
"getMemoryStore",
|
|
43
|
+
"updateMemoryStore",
|
|
44
|
+
"createMemory",
|
|
45
|
+
"listMemories",
|
|
46
|
+
"getMemory",
|
|
47
|
+
"updateMemory",
|
|
48
|
+
"deleteMemory"
|
|
49
|
+
],
|
|
39
50
|
deployment: ["createDeployment", "updateDeployment", "deleteDeployment", "runDeployment", "getDeployment"],
|
|
40
|
-
session: ["createSession", "listSessions", "getSession", "deleteSession", "sendSessionMessage"]
|
|
51
|
+
session: ["createSession", "listSessions", "getSession", "deleteSession", "sendSessionMessage"],
|
|
52
|
+
identity: ["createIdentity", "updateIdentity", "deleteIdentity"],
|
|
53
|
+
channel: ["createChannel", "updateChannel", "deleteChannel"]
|
|
41
54
|
};
|
|
42
55
|
|
|
43
56
|
// src/internal/providers/registry.ts
|
|
@@ -45,13 +58,13 @@ var registry = /* @__PURE__ */ new Map();
|
|
|
45
58
|
function registerProvider(def) {
|
|
46
59
|
registry.set(def.name, def);
|
|
47
60
|
}
|
|
48
|
-
function validateProviderFacets(def,
|
|
61
|
+
function validateProviderFacets(def, adapter2) {
|
|
49
62
|
const missing = [];
|
|
50
63
|
for (const [kind, methods] of Object.entries(REQUIRED_METHODS_BY_KIND)) {
|
|
51
64
|
if (!isSupported(def.capabilities, kind)) continue;
|
|
52
|
-
for (const
|
|
53
|
-
if (typeof
|
|
54
|
-
missing.push(`${kind}.${
|
|
65
|
+
for (const method2 of methods) {
|
|
66
|
+
if (typeof adapter2[method2] !== "function") {
|
|
67
|
+
missing.push(`${kind}.${method2}`);
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
70
|
}
|
|
@@ -75,9 +88,9 @@ function buildProviders(providersConfig, projectName) {
|
|
|
75
88
|
throw new UserError(`Unknown provider '${name}'. Registered: ${Array.from(registry.keys()).join(", ")}`);
|
|
76
89
|
}
|
|
77
90
|
const parsed = def.configSchema.parse(rawConfig);
|
|
78
|
-
const
|
|
79
|
-
validateProviderFacets(def,
|
|
80
|
-
adapters.set(name,
|
|
91
|
+
const adapter2 = def.createAdapter(parsed, projectName);
|
|
92
|
+
validateProviderFacets(def, adapter2);
|
|
93
|
+
adapters.set(name, adapter2);
|
|
81
94
|
}
|
|
82
95
|
return adapters;
|
|
83
96
|
}
|
|
@@ -144,9 +157,9 @@ function buildProviderFromEnv(providerName, projectName) {
|
|
|
144
157
|
}
|
|
145
158
|
const config = resolveProviderConfigFromEnv(providerName);
|
|
146
159
|
const parsed = def.configSchema.parse(config);
|
|
147
|
-
const
|
|
148
|
-
validateProviderFacets(def,
|
|
149
|
-
return
|
|
160
|
+
const adapter2 = def.createAdapter(parsed, projectName);
|
|
161
|
+
validateProviderFacets(def, adapter2);
|
|
162
|
+
return adapter2;
|
|
150
163
|
}
|
|
151
164
|
|
|
152
165
|
// src/internal/providers/claude/adapter.ts
|
|
@@ -352,6 +365,216 @@ function toRemoteResource(res) {
|
|
|
352
365
|
};
|
|
353
366
|
}
|
|
354
367
|
|
|
368
|
+
// src/internal/providers/memory-api.ts
|
|
369
|
+
function query(path, values) {
|
|
370
|
+
const params = new URLSearchParams();
|
|
371
|
+
for (const [key, value] of Object.entries(values)) {
|
|
372
|
+
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
373
|
+
}
|
|
374
|
+
const encoded = params.toString();
|
|
375
|
+
return encoded ? `${path}?${encoded}` : path;
|
|
376
|
+
}
|
|
377
|
+
function canonicalPath(path) {
|
|
378
|
+
return path.replace(/^\/+/, "");
|
|
379
|
+
}
|
|
380
|
+
function providerPath(path, style) {
|
|
381
|
+
const relative = canonicalPath(path);
|
|
382
|
+
return style === "absolute" ? `/${relative}` : relative;
|
|
383
|
+
}
|
|
384
|
+
function page(raw, map) {
|
|
385
|
+
const body = raw;
|
|
386
|
+
const data = (body.data ?? body.items ?? body.memories ?? body.memory_stores ?? body.memory_versions ?? []).map(map);
|
|
387
|
+
const next = body.next_cursor ?? body.next_page ?? body.last_id;
|
|
388
|
+
return { data, has_more: Boolean(body.has_more ?? next), ...next ? { next_cursor: next } : {} };
|
|
389
|
+
}
|
|
390
|
+
function mapMemoryStore(raw) {
|
|
391
|
+
return {
|
|
392
|
+
id: String(raw.id),
|
|
393
|
+
type: "memory_store",
|
|
394
|
+
name: String(raw.name ?? ""),
|
|
395
|
+
description: String(raw.description ?? ""),
|
|
396
|
+
metadata: raw.metadata ?? {},
|
|
397
|
+
...raw.status ? { status: String(raw.status) } : {},
|
|
398
|
+
...typeof (raw.entry_count ?? raw.memory_count) === "number" ? { entry_count: Number(raw.entry_count ?? raw.memory_count) } : {},
|
|
399
|
+
...typeof (raw.total_size ?? raw.storage_bytes) === "number" ? { total_size: Number(raw.total_size ?? raw.storage_bytes) } : {},
|
|
400
|
+
...typeof raw.session_count === "number" ? { session_count: raw.session_count } : {},
|
|
401
|
+
created_by: raw.created_by,
|
|
402
|
+
created_at: String(raw.created_at ?? ""),
|
|
403
|
+
updated_at: String(raw.updated_at ?? raw.created_at ?? ""),
|
|
404
|
+
archived_at: raw.archived_at ?? null
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function mapMemory(raw) {
|
|
408
|
+
return {
|
|
409
|
+
id: String(raw.id),
|
|
410
|
+
type: "memory",
|
|
411
|
+
memory_store_id: String(raw.memory_store_id ?? raw.store_id ?? ""),
|
|
412
|
+
path: canonicalPath(String(raw.path ?? "")),
|
|
413
|
+
content: raw.content,
|
|
414
|
+
content_size_bytes: Number(raw.content_size_bytes ?? raw.size ?? 0),
|
|
415
|
+
content_sha256: String(raw.content_sha256 ?? ""),
|
|
416
|
+
...typeof raw.version === "number" ? { version: raw.version } : {},
|
|
417
|
+
...raw.memory_version_id ? { memory_version_id: String(raw.memory_version_id) } : {},
|
|
418
|
+
metadata: raw.metadata ?? {},
|
|
419
|
+
created_by: raw.created_by,
|
|
420
|
+
created_at: String(raw.created_at ?? ""),
|
|
421
|
+
updated_at: String(raw.updated_at ?? raw.created_at ?? "")
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function mapMemoryListItem(raw) {
|
|
425
|
+
if (raw.type === "memory_prefix") return { type: "memory_prefix", path: canonicalPath(String(raw.path ?? "")) };
|
|
426
|
+
return mapMemory(raw);
|
|
427
|
+
}
|
|
428
|
+
function mapMemoryVersion(raw) {
|
|
429
|
+
const operation = String(raw.operation ?? raw.action ?? "updated");
|
|
430
|
+
return {
|
|
431
|
+
id: String(raw.id),
|
|
432
|
+
type: "memory_version",
|
|
433
|
+
memory_store_id: String(raw.memory_store_id ?? raw.store_id ?? ""),
|
|
434
|
+
memory_id: String(raw.memory_id ?? raw.entry_id ?? ""),
|
|
435
|
+
path: (raw.path ?? raw.entry_path) == null ? raw.path ?? raw.entry_path : canonicalPath(String(raw.path ?? raw.entry_path)),
|
|
436
|
+
content: raw.content,
|
|
437
|
+
content_size_bytes: raw.content_size_bytes ?? raw.size,
|
|
438
|
+
content_sha256: raw.content_sha256,
|
|
439
|
+
operation: operation === "modified" ? "updated" : operation,
|
|
440
|
+
...typeof raw.version === "number" ? { version: raw.version } : {},
|
|
441
|
+
...typeof raw.redacted === "boolean" ? { redacted: raw.redacted } : {},
|
|
442
|
+
redacted_at: raw.redacted_at,
|
|
443
|
+
created_by: raw.created_by,
|
|
444
|
+
created_at: String(raw.created_at ?? "")
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
var ProviderMemoryApi = class {
|
|
448
|
+
constructor(client, dialect) {
|
|
449
|
+
this.client = client;
|
|
450
|
+
this.dialect = dialect;
|
|
451
|
+
}
|
|
452
|
+
client;
|
|
453
|
+
dialect;
|
|
454
|
+
async listStores(options = {}) {
|
|
455
|
+
const raw = await this.client.get(
|
|
456
|
+
query("/memory_stores", {
|
|
457
|
+
limit: options.limit,
|
|
458
|
+
[this.dialect.cursorParam]: options.cursor,
|
|
459
|
+
include_archived: this.dialect.supportsIncludeArchived ? options.include_archived : void 0
|
|
460
|
+
})
|
|
461
|
+
);
|
|
462
|
+
return page(raw, mapMemoryStore);
|
|
463
|
+
}
|
|
464
|
+
async getStore(id) {
|
|
465
|
+
return mapMemoryStore(await this.client.get(`/memory_stores/${id}`));
|
|
466
|
+
}
|
|
467
|
+
async updateStore(id, input) {
|
|
468
|
+
let body = { ...input };
|
|
469
|
+
if (this.dialect.storeMetadataMode === "merge_patch" && input.metadata !== void 0) {
|
|
470
|
+
const current = await this.getStore(id);
|
|
471
|
+
body = {
|
|
472
|
+
...input,
|
|
473
|
+
metadata: {
|
|
474
|
+
...Object.fromEntries(Object.keys(current.metadata).map((key) => [key, null])),
|
|
475
|
+
...input.metadata
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
return mapMemoryStore(await this.client.post(`/memory_stores/${id}`, body));
|
|
480
|
+
}
|
|
481
|
+
async archiveStore(id) {
|
|
482
|
+
return mapMemoryStore(await this.client.post(`/memory_stores/${id}/archive`, {}));
|
|
483
|
+
}
|
|
484
|
+
async createMemory(storeId, input) {
|
|
485
|
+
const body = {
|
|
486
|
+
path: providerPath(input.path, this.dialect.pathStyle),
|
|
487
|
+
content: input.content,
|
|
488
|
+
...this.dialect.supportsMemoryMetadata && input.metadata ? { metadata: input.metadata } : {}
|
|
489
|
+
};
|
|
490
|
+
return mapMemory(await this.client.post(`/memory_stores/${storeId}/memories`, body));
|
|
491
|
+
}
|
|
492
|
+
async listMemories(storeId, options = {}) {
|
|
493
|
+
const raw = await this.client.get(
|
|
494
|
+
query(`/memory_stores/${storeId}/memories`, {
|
|
495
|
+
limit: options.limit,
|
|
496
|
+
[this.dialect.cursorParam]: options.cursor,
|
|
497
|
+
[this.dialect.prefixParam]: options.prefix ? providerPath(options.prefix, this.dialect.pathStyle) : void 0,
|
|
498
|
+
depth: options.depth,
|
|
499
|
+
view: this.dialect.supportsView ? options.view : void 0
|
|
500
|
+
})
|
|
501
|
+
);
|
|
502
|
+
return page(raw, mapMemoryListItem);
|
|
503
|
+
}
|
|
504
|
+
async getMemory(storeId, memoryId) {
|
|
505
|
+
const path = `/memory_stores/${storeId}/memories/${memoryId}${this.dialect.supportsView ? "?view=full" : ""}`;
|
|
506
|
+
return mapMemory(await this.client.get(path));
|
|
507
|
+
}
|
|
508
|
+
async updateMemory(storeId, memoryId, input) {
|
|
509
|
+
const { expected_content_sha256, ...values } = input;
|
|
510
|
+
const body = {
|
|
511
|
+
...values.content !== void 0 ? { content: values.content } : {},
|
|
512
|
+
...this.dialect.supportsMemoryMetadata && values.metadata ? { metadata: values.metadata } : {},
|
|
513
|
+
...this.dialect.supportsPathUpdate !== false && values.path ? { path: providerPath(values.path, this.dialect.pathStyle) } : {}
|
|
514
|
+
};
|
|
515
|
+
if (expected_content_sha256 && this.dialect.updatePrecondition !== "none") {
|
|
516
|
+
if (this.dialect.updatePrecondition === "precondition") {
|
|
517
|
+
body.precondition = { type: "content_sha256", content_sha256: expected_content_sha256 };
|
|
518
|
+
} else {
|
|
519
|
+
body[this.dialect.updatePrecondition] = expected_content_sha256;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
const path = `/memory_stores/${storeId}/memories/${memoryId}${this.dialect.supportsView ? "?view=full" : ""}`;
|
|
523
|
+
const raw = await this.client.post(path, body);
|
|
524
|
+
return mapMemory(raw);
|
|
525
|
+
}
|
|
526
|
+
async deleteMemory(storeId, memoryId, expected) {
|
|
527
|
+
await this.client.delete(
|
|
528
|
+
query(`/memory_stores/${storeId}/memories/${memoryId}`, {
|
|
529
|
+
expected_content_sha256: this.dialect.supportsDeletePrecondition ? expected : void 0
|
|
530
|
+
})
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
async listVersions(storeId, options = {}) {
|
|
534
|
+
const segment = this.dialect.versionsSegment ?? "memory_versions";
|
|
535
|
+
const raw = await this.client.get(
|
|
536
|
+
query(`/memory_stores/${storeId}/${segment}`, {
|
|
537
|
+
limit: options.limit,
|
|
538
|
+
[this.dialect.cursorParam]: options.cursor,
|
|
539
|
+
memory_id: options.memory_id,
|
|
540
|
+
view: this.dialect.supportsView ? options.view : void 0
|
|
541
|
+
})
|
|
542
|
+
);
|
|
543
|
+
return page(raw, mapMemoryVersion);
|
|
544
|
+
}
|
|
545
|
+
async getVersion(storeId, versionId) {
|
|
546
|
+
const segment = this.dialect.versionsSegment ?? "memory_versions";
|
|
547
|
+
return mapMemoryVersion(
|
|
548
|
+
await this.client.get(
|
|
549
|
+
`/memory_stores/${storeId}/${segment}/${versionId}${this.dialect.supportsView ? "?view=full" : ""}`
|
|
550
|
+
)
|
|
551
|
+
);
|
|
552
|
+
}
|
|
553
|
+
async redactVersion(storeId, versionId) {
|
|
554
|
+
const segment = this.dialect.versionsSegment ?? "memory_versions";
|
|
555
|
+
return mapMemoryVersion(
|
|
556
|
+
await this.client.post(`/memory_stores/${storeId}/${segment}/${versionId}/redact`, {})
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
async batchCreateMemories(storeId, input) {
|
|
560
|
+
const body = {
|
|
561
|
+
items: input.items.map((item) => ({
|
|
562
|
+
path: providerPath(item.path, this.dialect.pathStyle),
|
|
563
|
+
content: item.content
|
|
564
|
+
})),
|
|
565
|
+
on_conflict: input.on_conflict
|
|
566
|
+
};
|
|
567
|
+
const raw = await this.client.post(`/memory_stores/${storeId}/memories/batch_create`, body);
|
|
568
|
+
return {
|
|
569
|
+
results: (raw.results ?? []).map((item) => ({
|
|
570
|
+
path: canonicalPath(item.path),
|
|
571
|
+
...item.memory ? { memory: mapMemory(item.memory) } : {},
|
|
572
|
+
...item.error ? { error: item.error } : {}
|
|
573
|
+
}))
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
|
|
355
578
|
// src/internal/providers/session-event-response.ts
|
|
356
579
|
async function listSessionEventsPaged(client, sessionId, options, toEvent, config) {
|
|
357
580
|
const params = new URLSearchParams();
|
|
@@ -1039,10 +1262,30 @@ function mapSession(bindings) {
|
|
|
1039
1262
|
var ClaudeAdapter = class _ClaudeAdapter {
|
|
1040
1263
|
name = "claude";
|
|
1041
1264
|
eventResume = false;
|
|
1265
|
+
memoryCapabilities = {
|
|
1266
|
+
archive_store: true,
|
|
1267
|
+
batch_create: false,
|
|
1268
|
+
versions: true,
|
|
1269
|
+
optimistic_concurrency: true,
|
|
1270
|
+
memory_metadata: false
|
|
1271
|
+
};
|
|
1042
1272
|
client;
|
|
1273
|
+
memoryClient;
|
|
1274
|
+
memoryApi;
|
|
1043
1275
|
projectName;
|
|
1044
1276
|
constructor(apiKey, beta, projectName) {
|
|
1045
1277
|
this.client = new ClaudeClient({ apiKey, beta });
|
|
1278
|
+
this.memoryClient = new ClaudeClient({ apiKey, beta: "agent-memory-2026-07-22" });
|
|
1279
|
+
this.memoryApi = new ProviderMemoryApi(this.memoryClient, {
|
|
1280
|
+
pathStyle: "absolute",
|
|
1281
|
+
cursorParam: "page",
|
|
1282
|
+
updatePrecondition: "precondition",
|
|
1283
|
+
prefixParam: "path_prefix",
|
|
1284
|
+
supportsView: true,
|
|
1285
|
+
supportsMemoryMetadata: false,
|
|
1286
|
+
supportsDeletePrecondition: true,
|
|
1287
|
+
supportsIncludeArchived: true
|
|
1288
|
+
});
|
|
1046
1289
|
this.projectName = projectName ?? "";
|
|
1047
1290
|
}
|
|
1048
1291
|
async validate() {
|
|
@@ -1058,7 +1301,13 @@ var ClaudeAdapter = class _ClaudeAdapter {
|
|
|
1058
1301
|
file: "/files"
|
|
1059
1302
|
};
|
|
1060
1303
|
async findResource(type, name, id) {
|
|
1061
|
-
const raw = await locateRemote(
|
|
1304
|
+
const raw = await locateRemote(
|
|
1305
|
+
type === "memory_store" ? this.memoryClient : this.client,
|
|
1306
|
+
_ClaudeAdapter.ENDPOINT_MAP[type],
|
|
1307
|
+
name,
|
|
1308
|
+
id,
|
|
1309
|
+
notArchived
|
|
1310
|
+
);
|
|
1062
1311
|
return raw ? toRemoteResource(raw) : null;
|
|
1063
1312
|
}
|
|
1064
1313
|
async listAgents(filter) {
|
|
@@ -1191,6 +1440,62 @@ var ClaudeAdapter = class _ClaudeAdapter {
|
|
|
1191
1440
|
async deleteAgent(id) {
|
|
1192
1441
|
await this.client.post(`/agents/${id}/archive`, {});
|
|
1193
1442
|
}
|
|
1443
|
+
async createMemoryStore(name, decl) {
|
|
1444
|
+
const res = await this.memoryClient.post("/memory_stores", {
|
|
1445
|
+
name,
|
|
1446
|
+
description: decl.description,
|
|
1447
|
+
metadata: decl.metadata
|
|
1448
|
+
});
|
|
1449
|
+
const storeId = String(res.id);
|
|
1450
|
+
try {
|
|
1451
|
+
for (const entry of decl.entries ?? []) {
|
|
1452
|
+
await this.memoryApi.createMemory(storeId, { path: entry.key, content: entry.content });
|
|
1453
|
+
}
|
|
1454
|
+
} catch (error) {
|
|
1455
|
+
await this.memoryClient.delete(`/memory_stores/${storeId}`).catch(() => void 0);
|
|
1456
|
+
throw error;
|
|
1457
|
+
}
|
|
1458
|
+
return toRemoteResource(res);
|
|
1459
|
+
}
|
|
1460
|
+
async deleteMemoryStore(id) {
|
|
1461
|
+
await this.memoryClient.delete(`/memory_stores/${id}`);
|
|
1462
|
+
}
|
|
1463
|
+
listMemoryStores(options) {
|
|
1464
|
+
return this.memoryApi.listStores(options);
|
|
1465
|
+
}
|
|
1466
|
+
getMemoryStore(id) {
|
|
1467
|
+
return this.memoryApi.getStore(id);
|
|
1468
|
+
}
|
|
1469
|
+
updateMemoryStore(id, input) {
|
|
1470
|
+
return this.memoryApi.updateStore(id, input);
|
|
1471
|
+
}
|
|
1472
|
+
archiveMemoryStore(id) {
|
|
1473
|
+
return this.memoryApi.archiveStore(id);
|
|
1474
|
+
}
|
|
1475
|
+
createMemory(storeId, input) {
|
|
1476
|
+
return this.memoryApi.createMemory(storeId, input);
|
|
1477
|
+
}
|
|
1478
|
+
listMemories(storeId, options) {
|
|
1479
|
+
return this.memoryApi.listMemories(storeId, options);
|
|
1480
|
+
}
|
|
1481
|
+
getMemory(storeId, memoryId) {
|
|
1482
|
+
return this.memoryApi.getMemory(storeId, memoryId);
|
|
1483
|
+
}
|
|
1484
|
+
updateMemory(storeId, memoryId, input) {
|
|
1485
|
+
return this.memoryApi.updateMemory(storeId, memoryId, input);
|
|
1486
|
+
}
|
|
1487
|
+
deleteMemory(storeId, memoryId, expected) {
|
|
1488
|
+
return this.memoryApi.deleteMemory(storeId, memoryId, expected);
|
|
1489
|
+
}
|
|
1490
|
+
listMemoryVersions(storeId, options) {
|
|
1491
|
+
return this.memoryApi.listVersions(storeId, options);
|
|
1492
|
+
}
|
|
1493
|
+
getMemoryVersion(storeId, versionId) {
|
|
1494
|
+
return this.memoryApi.getVersion(storeId, versionId);
|
|
1495
|
+
}
|
|
1496
|
+
redactMemoryVersion(storeId, versionId) {
|
|
1497
|
+
return this.memoryApi.redactVersion(storeId, versionId);
|
|
1498
|
+
}
|
|
1194
1499
|
async createDeployment(name, decl, refs, basePath) {
|
|
1195
1500
|
const uploaded = await this.uploadDeploymentFiles(decl, basePath);
|
|
1196
1501
|
const body = mapDeployment(name, decl, refs, this.projectName, uploaded);
|
|
@@ -1353,15 +1658,13 @@ var CLAUDE_CAPABILITIES = {
|
|
|
1353
1658
|
skill: { tier: "native", reason: "skills API with files[] upload" },
|
|
1354
1659
|
agent: { tier: "native", reason: "managed agents API" },
|
|
1355
1660
|
template: { tier: "unsupported", reason: "no Forward Template equivalent on Claude" },
|
|
1356
|
-
memory_store: {
|
|
1357
|
-
tier: "unsupported",
|
|
1358
|
-
reason: "Claude exposes Memory Stores, but the OpenAgentPack adapter has not implemented them yet",
|
|
1359
|
-
remediation: "use skill knowledge or MCP until Claude Memory Store support is added to the adapter"
|
|
1360
|
-
},
|
|
1661
|
+
memory_store: { tier: "native", reason: "beta memory_stores API" },
|
|
1361
1662
|
mcp_server: { tier: "native", reason: "mcp_servers field on agent" },
|
|
1362
1663
|
multiagent: { tier: "native", reason: "coordinator + roster topology" },
|
|
1363
1664
|
deployment: { tier: "native", reason: "deployments API" },
|
|
1364
|
-
session: { tier: "native", reason: "sessions API" }
|
|
1665
|
+
session: { tier: "native", reason: "sessions API" },
|
|
1666
|
+
identity: { tier: "unsupported", reason: "no mapped Identity primitive on Claude" },
|
|
1667
|
+
channel: { tier: "unsupported", reason: "no mapped messaging Channel primitive on Claude" }
|
|
1365
1668
|
};
|
|
1366
1669
|
|
|
1367
1670
|
// src/internal/providers/claude/config.ts
|
|
@@ -1606,10 +1909,11 @@ function agentToDecl2(raw) {
|
|
|
1606
1909
|
metadata: stripAgentsMetadata(raw.metadata)
|
|
1607
1910
|
});
|
|
1608
1911
|
}
|
|
1609
|
-
function
|
|
1912
|
+
function mapMemoryStore2(name, decl) {
|
|
1610
1913
|
return {
|
|
1611
1914
|
name,
|
|
1612
|
-
description: decl.description
|
|
1915
|
+
description: decl.description,
|
|
1916
|
+
metadata: decl.metadata
|
|
1613
1917
|
};
|
|
1614
1918
|
}
|
|
1615
1919
|
function mapDeployment2(name, decl, refs, projectName, uploadedFiles) {
|
|
@@ -1930,17 +2234,36 @@ function deriveForwardGateway(cloudGateway) {
|
|
|
1930
2234
|
const trimmed = cloudGateway.replace(/\/$/, "");
|
|
1931
2235
|
return trimmed.endsWith("/cloud") ? `${trimmed.slice(0, -"/cloud".length)}/forward` : `${trimmed}/forward`;
|
|
1932
2236
|
}
|
|
1933
|
-
var QODER_DEFAULT_IDENTITY_EXTERNAL_ID = "__qca_admin_identity__";
|
|
1934
2237
|
var QoderAdapter = class _QoderAdapter {
|
|
1935
2238
|
name = "qoder";
|
|
1936
2239
|
eventResume = true;
|
|
2240
|
+
memoryCapabilities = {
|
|
2241
|
+
archive_store: true,
|
|
2242
|
+
batch_create: false,
|
|
2243
|
+
versions: true,
|
|
2244
|
+
optimistic_concurrency: true,
|
|
2245
|
+
memory_metadata: true
|
|
2246
|
+
};
|
|
1937
2247
|
client;
|
|
2248
|
+
memoryApi;
|
|
1938
2249
|
forwardClient;
|
|
1939
2250
|
projectName;
|
|
1940
2251
|
forwardSessionIds = /* @__PURE__ */ new Set();
|
|
1941
|
-
defaultForwardIdentityId;
|
|
1942
2252
|
constructor(apiKey, gateway, projectName, forwardGateway) {
|
|
1943
2253
|
this.client = new QoderClient({ apiKey, gateway });
|
|
2254
|
+
this.memoryApi = new ProviderMemoryApi(this.client, {
|
|
2255
|
+
pathStyle: "relative",
|
|
2256
|
+
cursorParam: "after_id",
|
|
2257
|
+
updatePrecondition: "content_sha256",
|
|
2258
|
+
prefixParam: "prefix",
|
|
2259
|
+
versionsSegment: "versions",
|
|
2260
|
+
storeMetadataMode: "merge_patch",
|
|
2261
|
+
supportsView: false,
|
|
2262
|
+
supportsMemoryMetadata: true,
|
|
2263
|
+
supportsPathUpdate: false,
|
|
2264
|
+
supportsDeletePrecondition: false,
|
|
2265
|
+
supportsIncludeArchived: true
|
|
2266
|
+
});
|
|
1944
2267
|
this.forwardClient = new QoderClient({
|
|
1945
2268
|
apiKey,
|
|
1946
2269
|
gateway: forwardGateway ?? deriveForwardGateway(gateway)
|
|
@@ -1964,6 +2287,21 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
1964
2287
|
const raw2 = await locateRemote(this.forwardClient, "/templates", name, id, (item) => item.status !== "archived");
|
|
1965
2288
|
return raw2 ? toRemoteResource(raw2) : null;
|
|
1966
2289
|
}
|
|
2290
|
+
if (type === "identity") {
|
|
2291
|
+
try {
|
|
2292
|
+
if (id) return toRemoteResource(await this.forwardClient.get(`/identities/${id}`));
|
|
2293
|
+
const res = await this.forwardClient.get(`/identities?external_id=${encodeURIComponent(name)}&limit=100`);
|
|
2294
|
+
const raw2 = (res.data ?? []).find((item) => item.external_id === name);
|
|
2295
|
+
return raw2 ? toRemoteResource(raw2) : null;
|
|
2296
|
+
} catch (err) {
|
|
2297
|
+
if (ApiError.isNotFound(err)) return null;
|
|
2298
|
+
throw err;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
if (type === "channel") {
|
|
2302
|
+
const raw2 = await locateRemote(this.forwardClient, "/channels", name, id, () => true);
|
|
2303
|
+
return raw2 ? toRemoteResource(raw2) : null;
|
|
2304
|
+
}
|
|
1967
2305
|
const raw = await locateRemote(this.client, _QoderAdapter.ENDPOINT_MAP[type], name, id, notArchived);
|
|
1968
2306
|
return raw ? toRemoteResource(raw) : null;
|
|
1969
2307
|
}
|
|
@@ -2009,12 +2347,23 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
2009
2347
|
return toRestSkillInfo(res);
|
|
2010
2348
|
}
|
|
2011
2349
|
getDriftSupport(type) {
|
|
2012
|
-
if (type === "agent" || type === "environment" || type === "template"
|
|
2350
|
+
if (type === "agent" || type === "environment" || type === "template" || type === "identity" || type === "channel")
|
|
2351
|
+
return "full";
|
|
2013
2352
|
if (type === "deployment") return "unsupported";
|
|
2014
2353
|
return _QoderAdapter.ENDPOINT_MAP[type] ? "existence" : "unsupported";
|
|
2015
2354
|
}
|
|
2016
2355
|
async readComparableResource(type, id, name) {
|
|
2017
|
-
if (type !== "agent" && type !== "environment" && type !== "template"
|
|
2356
|
+
if (type !== "agent" && type !== "environment" && type !== "template" && type !== "identity" && type !== "channel")
|
|
2357
|
+
return null;
|
|
2358
|
+
if (type === "identity" || type === "channel") {
|
|
2359
|
+
const remote = await this.findResource(type, name, id);
|
|
2360
|
+
if (!remote?.id) return null;
|
|
2361
|
+
const raw2 = await this.forwardClient.get(
|
|
2362
|
+
`/${type === "identity" ? "identities" : "channels"}/${remote.id}`
|
|
2363
|
+
);
|
|
2364
|
+
const comparable2 = this.normalizeRemote(type, raw2);
|
|
2365
|
+
return { id: remote.id, type, comparable: comparable2, snapshot: comparable2 };
|
|
2366
|
+
}
|
|
2018
2367
|
const isTemplate = type === "template";
|
|
2019
2368
|
const endpoint = type === "agent" ? "/agents" : type === "environment" ? "/environments" : "/templates";
|
|
2020
2369
|
const raw = await locateRemote(
|
|
@@ -2048,6 +2397,16 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
2048
2397
|
);
|
|
2049
2398
|
}
|
|
2050
2399
|
if (type === "template") return null;
|
|
2400
|
+
if (type === "identity") {
|
|
2401
|
+
const identity = decl;
|
|
2402
|
+
if (identity.identity_id) return null;
|
|
2403
|
+
return this.normalizeRemote(type, {
|
|
2404
|
+
external_id: identity.external_id,
|
|
2405
|
+
name: identity.name ?? name,
|
|
2406
|
+
enabled: identity.enabled ?? true,
|
|
2407
|
+
metadata: identity.metadata ?? {}
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2051
2410
|
return null;
|
|
2052
2411
|
}
|
|
2053
2412
|
normalizeRemote(type, raw) {
|
|
@@ -2081,6 +2440,27 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
2081
2440
|
metadata: stripAgentsMetadata(raw.metadata)
|
|
2082
2441
|
});
|
|
2083
2442
|
}
|
|
2443
|
+
if (type === "identity") {
|
|
2444
|
+
return compactDeep({
|
|
2445
|
+
external_id: raw.external_id,
|
|
2446
|
+
name: raw.name,
|
|
2447
|
+
enabled: raw.enabled,
|
|
2448
|
+
metadata: raw.metadata ?? {}
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
if (type === "channel") {
|
|
2452
|
+
const channelConfig = raw.channel_config ?? {};
|
|
2453
|
+
return compactDeep({
|
|
2454
|
+
identity_id: raw.identity_id,
|
|
2455
|
+
template_id: raw.template_id,
|
|
2456
|
+
channel_type: raw.channel_type,
|
|
2457
|
+
name: raw.name,
|
|
2458
|
+
enabled: raw.enabled,
|
|
2459
|
+
channel_config: {
|
|
2460
|
+
response_options: channelConfig.response_options ?? {}
|
|
2461
|
+
}
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2084
2464
|
return compactDeep({
|
|
2085
2465
|
description: raw.description,
|
|
2086
2466
|
model: normalizeModel(raw.model),
|
|
@@ -2190,6 +2570,71 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
2190
2570
|
async archiveTemplate(id) {
|
|
2191
2571
|
await this.forwardClient.post(`/templates/${id}/archive`, {});
|
|
2192
2572
|
}
|
|
2573
|
+
async createIdentity(name, decl) {
|
|
2574
|
+
if (decl.identity_id) return { id: decl.identity_id, type: "identity" };
|
|
2575
|
+
const res = await this.forwardClient.post("/identities", {
|
|
2576
|
+
external_id: decl.external_id,
|
|
2577
|
+
name: decl.name ?? name,
|
|
2578
|
+
enabled: decl.enabled ?? true,
|
|
2579
|
+
metadata: decl.metadata ?? {}
|
|
2580
|
+
});
|
|
2581
|
+
return toRemoteResource(res);
|
|
2582
|
+
}
|
|
2583
|
+
async updateIdentity(id, name, decl) {
|
|
2584
|
+
if (decl.identity_id) return { id: decl.identity_id, type: "identity" };
|
|
2585
|
+
const current = await this.forwardClient.get(`/identities/${id}`);
|
|
2586
|
+
const currentMetadata = current.metadata ?? {};
|
|
2587
|
+
const desiredMetadata = decl.metadata ?? {};
|
|
2588
|
+
const metadata = { ...desiredMetadata };
|
|
2589
|
+
for (const key of Object.keys(currentMetadata)) {
|
|
2590
|
+
if (!(key in desiredMetadata)) metadata[key] = "";
|
|
2591
|
+
}
|
|
2592
|
+
const res = await this.forwardClient.post(`/identities/${id}`, {
|
|
2593
|
+
external_id: decl.external_id,
|
|
2594
|
+
name: decl.name ?? name,
|
|
2595
|
+
enabled: decl.enabled ?? true,
|
|
2596
|
+
metadata
|
|
2597
|
+
});
|
|
2598
|
+
return toRemoteResource(res);
|
|
2599
|
+
}
|
|
2600
|
+
async deleteIdentity(id) {
|
|
2601
|
+
await this.forwardClient.delete(`/identities/${id}`);
|
|
2602
|
+
}
|
|
2603
|
+
async createChannel(name, decl, refs) {
|
|
2604
|
+
const res = await this.forwardClient.post("/channels", this.mapChannel(name, decl, refs));
|
|
2605
|
+
return toRemoteResource(res);
|
|
2606
|
+
}
|
|
2607
|
+
async updateChannel(id, name, decl, refs) {
|
|
2608
|
+
const current = await this.forwardClient.get(`/channels/${id}`);
|
|
2609
|
+
if (current.channel_type !== decl.type) {
|
|
2610
|
+
await this.deleteChannel(id);
|
|
2611
|
+
return this.createChannel(name, decl, refs);
|
|
2612
|
+
}
|
|
2613
|
+
const body = this.mapChannel(name, decl, refs);
|
|
2614
|
+
delete body.channel_type;
|
|
2615
|
+
const res = await this.forwardClient.post(`/channels/${id}`, body);
|
|
2616
|
+
return toRemoteResource(res);
|
|
2617
|
+
}
|
|
2618
|
+
async deleteChannel(id) {
|
|
2619
|
+
await this.forwardClient.delete(`/channels/${id}`);
|
|
2620
|
+
}
|
|
2621
|
+
mapChannel(name, decl, refs) {
|
|
2622
|
+
return {
|
|
2623
|
+
identity_id: refs.identity_id,
|
|
2624
|
+
template_id: refs.agent_id,
|
|
2625
|
+
channel_type: decl.type,
|
|
2626
|
+
name: decl.name ?? name,
|
|
2627
|
+
enabled: decl.enabled ?? true,
|
|
2628
|
+
channel_config: {
|
|
2629
|
+
credentials: decl.credentials,
|
|
2630
|
+
response_options: {
|
|
2631
|
+
include_tool_calls: false,
|
|
2632
|
+
include_thinking: false,
|
|
2633
|
+
...decl.options ?? {}
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2193
2638
|
async registerForwardVaults(vaultIds) {
|
|
2194
2639
|
for (const id of vaultIds) {
|
|
2195
2640
|
await this.forwardClient.post("/resources/registry", {
|
|
@@ -2199,22 +2644,58 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
2199
2644
|
}
|
|
2200
2645
|
}
|
|
2201
2646
|
async createMemoryStore(name, decl) {
|
|
2202
|
-
const body =
|
|
2647
|
+
const body = mapMemoryStore2(name, decl);
|
|
2203
2648
|
const res = await this.client.post("/memory_stores", body);
|
|
2204
2649
|
const storeId = res.id;
|
|
2205
|
-
|
|
2206
|
-
for (const entry of decl.entries) {
|
|
2207
|
-
await this.
|
|
2208
|
-
content: entry.content,
|
|
2209
|
-
path: entry.key
|
|
2210
|
-
});
|
|
2650
|
+
try {
|
|
2651
|
+
for (const entry of decl.entries ?? []) {
|
|
2652
|
+
await this.memoryApi.createMemory(storeId, { content: entry.content, path: entry.key });
|
|
2211
2653
|
}
|
|
2654
|
+
} catch (error) {
|
|
2655
|
+
await this.client.delete(`/memory_stores/${storeId}`).catch(() => void 0);
|
|
2656
|
+
throw error;
|
|
2212
2657
|
}
|
|
2213
2658
|
return toRemoteResource(res);
|
|
2214
2659
|
}
|
|
2215
2660
|
async deleteMemoryStore(id) {
|
|
2216
2661
|
await this.client.delete(`/memory_stores/${id}`);
|
|
2217
2662
|
}
|
|
2663
|
+
listMemoryStores(options) {
|
|
2664
|
+
return this.memoryApi.listStores(options);
|
|
2665
|
+
}
|
|
2666
|
+
getMemoryStore(id) {
|
|
2667
|
+
return this.memoryApi.getStore(id);
|
|
2668
|
+
}
|
|
2669
|
+
updateMemoryStore(id, input) {
|
|
2670
|
+
return this.memoryApi.updateStore(id, input);
|
|
2671
|
+
}
|
|
2672
|
+
archiveMemoryStore(id) {
|
|
2673
|
+
return this.memoryApi.archiveStore(id);
|
|
2674
|
+
}
|
|
2675
|
+
createMemory(storeId, input) {
|
|
2676
|
+
return this.memoryApi.createMemory(storeId, input);
|
|
2677
|
+
}
|
|
2678
|
+
listMemories(storeId, options) {
|
|
2679
|
+
return this.memoryApi.listMemories(storeId, options);
|
|
2680
|
+
}
|
|
2681
|
+
getMemory(storeId, memoryId) {
|
|
2682
|
+
return this.memoryApi.getMemory(storeId, memoryId);
|
|
2683
|
+
}
|
|
2684
|
+
updateMemory(storeId, memoryId, input) {
|
|
2685
|
+
return this.memoryApi.updateMemory(storeId, memoryId, input);
|
|
2686
|
+
}
|
|
2687
|
+
deleteMemory(storeId, memoryId, expected) {
|
|
2688
|
+
return this.memoryApi.deleteMemory(storeId, memoryId, expected);
|
|
2689
|
+
}
|
|
2690
|
+
listMemoryVersions(storeId, options) {
|
|
2691
|
+
return this.memoryApi.listVersions(storeId, options);
|
|
2692
|
+
}
|
|
2693
|
+
getMemoryVersion(storeId, versionId) {
|
|
2694
|
+
return this.memoryApi.getVersion(storeId, versionId);
|
|
2695
|
+
}
|
|
2696
|
+
redactMemoryVersion(storeId, versionId) {
|
|
2697
|
+
return this.memoryApi.redactVersion(storeId, versionId);
|
|
2698
|
+
}
|
|
2218
2699
|
async createDeployment(name, decl, refs, basePath) {
|
|
2219
2700
|
const uploaded = await this.uploadDeploymentFiles(decl, basePath);
|
|
2220
2701
|
const body = mapDeployment2(name, decl, refs, this.projectName, uploaded);
|
|
@@ -2278,9 +2759,11 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
2278
2759
|
}
|
|
2279
2760
|
async createSession(bindings) {
|
|
2280
2761
|
if (bindings.delivery === "forward") {
|
|
2281
|
-
|
|
2762
|
+
if (!bindings.identity_id) {
|
|
2763
|
+
throw new UserError("Qoder Forward sessions require an explicit resolved identity_id.");
|
|
2764
|
+
}
|
|
2282
2765
|
const body2 = {
|
|
2283
|
-
identity_id:
|
|
2766
|
+
identity_id: bindings.identity_id,
|
|
2284
2767
|
template_id: bindings.template_id,
|
|
2285
2768
|
incremental_streaming_enabled: false
|
|
2286
2769
|
};
|
|
@@ -2302,30 +2785,6 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
2302
2785
|
const res = await this.client.post("/sessions", body);
|
|
2303
2786
|
return toSessionInfo2(res);
|
|
2304
2787
|
}
|
|
2305
|
-
async resolveDefaultForwardIdentityId() {
|
|
2306
|
-
if (this.defaultForwardIdentityId) return this.defaultForwardIdentityId;
|
|
2307
|
-
let afterId;
|
|
2308
|
-
do {
|
|
2309
|
-
const params = new URLSearchParams({ limit: "100" });
|
|
2310
|
-
if (afterId) params.set("after_id", afterId);
|
|
2311
|
-
const res = await this.forwardClient.get(`/identities?${params}`);
|
|
2312
|
-
const identities = res.data ?? [];
|
|
2313
|
-
const match = identities.find(
|
|
2314
|
-
(identity) => identity.external_id === QODER_DEFAULT_IDENTITY_EXTERNAL_ID && identity.enabled !== false && identity.archived !== true
|
|
2315
|
-
);
|
|
2316
|
-
if (typeof match?.id === "string") {
|
|
2317
|
-
this.defaultForwardIdentityId = match.id;
|
|
2318
|
-
return match.id;
|
|
2319
|
-
}
|
|
2320
|
-
const hasMore = res.has_more ?? false;
|
|
2321
|
-
const nextId = hasMore ? res.last_id ?? void 0 : void 0;
|
|
2322
|
-
if (!nextId || nextId === afterId) break;
|
|
2323
|
-
afterId = nextId;
|
|
2324
|
-
} while (afterId);
|
|
2325
|
-
throw new UserError(
|
|
2326
|
-
`Qoder default Forward Identity '${QODER_DEFAULT_IDENTITY_EXTERNAL_ID}' was not found. Ask Qoder to provision it, set defaults.session.qoder.identity_id, or pass --identity-id.`
|
|
2327
|
-
);
|
|
2328
|
-
}
|
|
2329
2788
|
async listSessions(filter) {
|
|
2330
2789
|
if (filter?.agent_id?.startsWith("tmpl_")) {
|
|
2331
2790
|
const params2 = new URLSearchParams({ template_id: filter.agent_id });
|
|
@@ -2448,8 +2907,8 @@ var QoderAdapter = class _QoderAdapter {
|
|
|
2448
2907
|
if (options?.order) params.set("order", options.order);
|
|
2449
2908
|
const afterId = options?.after_id ?? options?.page_token ?? options?.page;
|
|
2450
2909
|
if (afterId) params.set("after_id", afterId);
|
|
2451
|
-
const
|
|
2452
|
-
const res = await this.forwardClient.get(`/sessions/${sessionId}/events${
|
|
2910
|
+
const query2 = params.toString();
|
|
2911
|
+
const res = await this.forwardClient.get(`/sessions/${sessionId}/events${query2 ? `?${query2}` : ""}`);
|
|
2453
2912
|
const data = res.data ?? [];
|
|
2454
2913
|
const hasMore = res.has_more ?? false;
|
|
2455
2914
|
return {
|
|
@@ -2573,7 +3032,9 @@ var QODER_CAPABILITIES = {
|
|
|
2573
3032
|
tier: "native",
|
|
2574
3033
|
reason: "deployments API with scheduled and manual runs"
|
|
2575
3034
|
},
|
|
2576
|
-
session: { tier: "native", reason: "sessions API" }
|
|
3035
|
+
session: { tier: "native", reason: "sessions API" },
|
|
3036
|
+
identity: { tier: "native", reason: "Forward Identities API" },
|
|
3037
|
+
channel: { tier: "native", reason: "Forward Channels API" }
|
|
2577
3038
|
};
|
|
2578
3039
|
|
|
2579
3040
|
// src/internal/providers/qoder/config.ts
|
|
@@ -3494,7 +3955,9 @@ var BAILIAN_CAPABILITIES = {
|
|
|
3494
3955
|
reason: "no deployment primitive on Bailian; expanded into a session at run time",
|
|
3495
3956
|
remediation: "scheduling and outcome rubrics are not enforced server-side \u2014 use external cron/CI for always-on or scheduled runs"
|
|
3496
3957
|
},
|
|
3497
|
-
session: { tier: "native", reason: "sessions API" }
|
|
3958
|
+
session: { tier: "native", reason: "sessions API" },
|
|
3959
|
+
identity: { tier: "unsupported", reason: "no mapped Identity primitive on Bailian" },
|
|
3960
|
+
channel: { tier: "unsupported", reason: "no mapped messaging Channel primitive on Bailian" }
|
|
3498
3961
|
};
|
|
3499
3962
|
|
|
3500
3963
|
// src/internal/providers/bailian/config.ts
|
|
@@ -3713,10 +4176,11 @@ function mapEnvironment4(name, decl, projectName, wireName) {
|
|
|
3713
4176
|
if (decl.description) body.description = decl.description;
|
|
3714
4177
|
return body;
|
|
3715
4178
|
}
|
|
3716
|
-
function
|
|
4179
|
+
function mapMemoryStore3(name, decl) {
|
|
3717
4180
|
return {
|
|
3718
4181
|
name,
|
|
3719
|
-
description: decl.description
|
|
4182
|
+
description: decl.description,
|
|
4183
|
+
metadata: decl.metadata
|
|
3720
4184
|
};
|
|
3721
4185
|
}
|
|
3722
4186
|
function mapAgent4(name, decl, refs, version, projectName) {
|
|
@@ -3915,10 +4379,28 @@ function mapSession4(bindings) {
|
|
|
3915
4379
|
var ArkAdapter = class _ArkAdapter {
|
|
3916
4380
|
name = "ark";
|
|
3917
4381
|
eventResume = false;
|
|
4382
|
+
memoryCapabilities = {
|
|
4383
|
+
archive_store: false,
|
|
4384
|
+
batch_create: true,
|
|
4385
|
+
versions: false,
|
|
4386
|
+
optimistic_concurrency: false,
|
|
4387
|
+
memory_metadata: false
|
|
4388
|
+
};
|
|
3918
4389
|
client;
|
|
4390
|
+
memoryApi;
|
|
3919
4391
|
projectName;
|
|
3920
4392
|
constructor(apiKey, projectName) {
|
|
3921
4393
|
this.client = new ArkClient({ apiKey });
|
|
4394
|
+
this.memoryApi = new ProviderMemoryApi(this.client, {
|
|
4395
|
+
pathStyle: "absolute",
|
|
4396
|
+
cursorParam: "page",
|
|
4397
|
+
updatePrecondition: "none",
|
|
4398
|
+
prefixParam: "path_prefix",
|
|
4399
|
+
supportsView: false,
|
|
4400
|
+
supportsMemoryMetadata: false,
|
|
4401
|
+
supportsDeletePrecondition: false,
|
|
4402
|
+
supportsIncludeArchived: false
|
|
4403
|
+
});
|
|
3922
4404
|
this.projectName = projectName ?? "";
|
|
3923
4405
|
}
|
|
3924
4406
|
async validate() {
|
|
@@ -4071,22 +4553,49 @@ var ArkAdapter = class _ArkAdapter {
|
|
|
4071
4553
|
await this.client.delete(`/agents/${id}`);
|
|
4072
4554
|
}
|
|
4073
4555
|
async createMemoryStore(name, decl) {
|
|
4074
|
-
const body =
|
|
4556
|
+
const body = mapMemoryStore3(name, decl);
|
|
4075
4557
|
const res = await this.client.post("/memory_stores", body);
|
|
4076
4558
|
const storeId = res.id;
|
|
4077
|
-
|
|
4078
|
-
for (const entry of decl.entries) {
|
|
4079
|
-
await this.
|
|
4080
|
-
content: entry.content,
|
|
4081
|
-
path: entry.key
|
|
4082
|
-
});
|
|
4559
|
+
try {
|
|
4560
|
+
for (const entry of decl.entries ?? []) {
|
|
4561
|
+
await this.memoryApi.createMemory(storeId, { content: entry.content, path: entry.key });
|
|
4083
4562
|
}
|
|
4563
|
+
} catch (error) {
|
|
4564
|
+
await this.client.delete(`/memory_stores/${storeId}`).catch(() => void 0);
|
|
4565
|
+
throw error;
|
|
4084
4566
|
}
|
|
4085
4567
|
return toRemoteResource(res);
|
|
4086
4568
|
}
|
|
4087
4569
|
async deleteMemoryStore(id) {
|
|
4088
4570
|
await this.client.delete(`/memory_stores/${id}`);
|
|
4089
4571
|
}
|
|
4572
|
+
listMemoryStores(options) {
|
|
4573
|
+
return this.memoryApi.listStores(options);
|
|
4574
|
+
}
|
|
4575
|
+
getMemoryStore(id) {
|
|
4576
|
+
return this.memoryApi.getStore(id);
|
|
4577
|
+
}
|
|
4578
|
+
updateMemoryStore(id, input) {
|
|
4579
|
+
return this.memoryApi.updateStore(id, input);
|
|
4580
|
+
}
|
|
4581
|
+
createMemory(storeId, input) {
|
|
4582
|
+
return this.memoryApi.createMemory(storeId, input);
|
|
4583
|
+
}
|
|
4584
|
+
batchCreateMemories(storeId, input) {
|
|
4585
|
+
return this.memoryApi.batchCreateMemories(storeId, input);
|
|
4586
|
+
}
|
|
4587
|
+
listMemories(storeId, options) {
|
|
4588
|
+
return this.memoryApi.listMemories(storeId, options);
|
|
4589
|
+
}
|
|
4590
|
+
getMemory(storeId, memoryId) {
|
|
4591
|
+
return this.memoryApi.getMemory(storeId, memoryId);
|
|
4592
|
+
}
|
|
4593
|
+
updateMemory(storeId, memoryId, input) {
|
|
4594
|
+
return this.memoryApi.updateMemory(storeId, memoryId, input);
|
|
4595
|
+
}
|
|
4596
|
+
deleteMemory(storeId, memoryId, expected) {
|
|
4597
|
+
return this.memoryApi.deleteMemory(storeId, memoryId, expected);
|
|
4598
|
+
}
|
|
4090
4599
|
// --- Deployment (emulated) ---
|
|
4091
4600
|
// Ark has no /deployments endpoint. A deployment is recorded in state with
|
|
4092
4601
|
// remote_id = null and materialized into a session at run time (mirrors qoder).
|
|
@@ -4248,7 +4757,9 @@ var ARK_CAPABILITIES = {
|
|
|
4248
4757
|
tier: "emulated",
|
|
4249
4758
|
reason: "no deployment primitive on Ark; expanded into a session at run time"
|
|
4250
4759
|
},
|
|
4251
|
-
session: { tier: "native", reason: "sessions API" }
|
|
4760
|
+
session: { tier: "native", reason: "sessions API" },
|
|
4761
|
+
identity: { tier: "unsupported", reason: "no mapped Identity primitive on Ark" },
|
|
4762
|
+
channel: { tier: "unsupported", reason: "no mapped messaging Channel primitive on Ark" }
|
|
4252
4763
|
};
|
|
4253
4764
|
|
|
4254
4765
|
// src/internal/providers/ark/config.ts
|
|
@@ -4308,11 +4819,11 @@ async function writeProjectRuntime(input, fn) {
|
|
|
4308
4819
|
);
|
|
4309
4820
|
}
|
|
4310
4821
|
function getRuntimeProvider(ctx, providerName) {
|
|
4311
|
-
const
|
|
4312
|
-
if (!
|
|
4822
|
+
const adapter2 = ctx.providers.get(providerName);
|
|
4823
|
+
if (!adapter2) {
|
|
4313
4824
|
throw new UserError(`Provider '${providerName}' not configured.`);
|
|
4314
4825
|
}
|
|
4315
|
-
return
|
|
4826
|
+
return adapter2;
|
|
4316
4827
|
}
|
|
4317
4828
|
|
|
4318
4829
|
// src/internal/parser/file-resolver.ts
|
|
@@ -4444,6 +4955,7 @@ var memoryEntrySchema = z5.object({
|
|
|
4444
4955
|
var memoryStoreSchema = z5.object({
|
|
4445
4956
|
description: z5.string(),
|
|
4446
4957
|
provider: z5.string().optional(),
|
|
4958
|
+
metadata: z5.record(z5.string(), z5.string()).optional(),
|
|
4447
4959
|
entries: z5.array(memoryEntrySchema).optional()
|
|
4448
4960
|
});
|
|
4449
4961
|
var skillSchema = z5.object({
|
|
@@ -4460,6 +4972,23 @@ var fileSchema = z5.object({
|
|
|
4460
4972
|
purpose: z5.string().optional(),
|
|
4461
4973
|
provider: z5.string().optional()
|
|
4462
4974
|
});
|
|
4975
|
+
var managedIdentitySchema = z5.object({
|
|
4976
|
+
provider: z5.string().optional(),
|
|
4977
|
+
external_id: z5.string().trim().min(1),
|
|
4978
|
+
name: z5.string().trim().min(1).optional(),
|
|
4979
|
+
enabled: z5.boolean().optional(),
|
|
4980
|
+
metadata: z5.record(z5.string(), z5.string()).optional(),
|
|
4981
|
+
identity_id: z5.never().optional()
|
|
4982
|
+
});
|
|
4983
|
+
var externalIdentitySchema = z5.object({
|
|
4984
|
+
provider: z5.string().optional(),
|
|
4985
|
+
identity_id: z5.string().trim().min(1),
|
|
4986
|
+
external_id: z5.never().optional(),
|
|
4987
|
+
name: z5.never().optional(),
|
|
4988
|
+
enabled: z5.never().optional(),
|
|
4989
|
+
metadata: z5.never().optional()
|
|
4990
|
+
});
|
|
4991
|
+
var identitySchema = z5.union([managedIdentitySchema, externalIdentitySchema]);
|
|
4463
4992
|
var urlMcpServerSchema = z5.object({
|
|
4464
4993
|
name: z5.string(),
|
|
4465
4994
|
type: z5.enum(["url", "http"]).optional(),
|
|
@@ -4540,6 +5069,16 @@ var agentSchema = z5.object({
|
|
|
4540
5069
|
metadata: z5.record(z5.string(), z5.string()).optional(),
|
|
4541
5070
|
delivery: z5.record(z5.string(), agentDeliverySchema).optional()
|
|
4542
5071
|
});
|
|
5072
|
+
var channelSchema = z5.object({
|
|
5073
|
+
provider: z5.string().optional(),
|
|
5074
|
+
agent: z5.string().min(1),
|
|
5075
|
+
identity: z5.string().min(1).optional(),
|
|
5076
|
+
type: z5.string().min(1),
|
|
5077
|
+
name: z5.string().trim().min(1).optional(),
|
|
5078
|
+
enabled: z5.boolean().optional(),
|
|
5079
|
+
credentials: z5.record(z5.string(), coerceString).optional(),
|
|
5080
|
+
options: z5.record(z5.string(), z5.unknown()).optional()
|
|
5081
|
+
});
|
|
4543
5082
|
var deploymentFileResourceSchema = z5.object({
|
|
4544
5083
|
type: z5.literal("file"),
|
|
4545
5084
|
file_id: z5.string().optional(),
|
|
@@ -4600,11 +5139,7 @@ var projectConfigSchema = z5.object({
|
|
|
4600
5139
|
providers: z5.record(z5.string(), z5.unknown()),
|
|
4601
5140
|
defaults: z5.object({
|
|
4602
5141
|
provider: z5.string().optional(),
|
|
4603
|
-
|
|
4604
|
-
qoder: z5.object({
|
|
4605
|
-
identity_id: z5.string().min(1).optional()
|
|
4606
|
-
}).optional()
|
|
4607
|
-
}).optional()
|
|
5142
|
+
identity: z5.string().min(1).optional()
|
|
4608
5143
|
}).optional(),
|
|
4609
5144
|
environments: z5.record(z5.string(), environmentSchema).optional(),
|
|
4610
5145
|
tunnels: z5.record(z5.string(), tunnelSchema).optional(),
|
|
@@ -4612,7 +5147,9 @@ var projectConfigSchema = z5.object({
|
|
|
4612
5147
|
memory_stores: z5.record(z5.string(), memoryStoreSchema).optional(),
|
|
4613
5148
|
skills: z5.record(z5.string(), skillSchema).optional(),
|
|
4614
5149
|
files: z5.record(z5.string(), fileSchema).optional(),
|
|
5150
|
+
identities: z5.record(z5.string(), identitySchema).optional(),
|
|
4615
5151
|
agents: z5.record(z5.string(), agentSchema).optional(),
|
|
5152
|
+
channels: z5.record(z5.string(), channelSchema).optional(),
|
|
4616
5153
|
deployments: z5.record(z5.string(), deploymentSchema).optional()
|
|
4617
5154
|
});
|
|
4618
5155
|
|
|
@@ -4728,6 +5265,10 @@ function getResourceDeclaration(address, config) {
|
|
|
4728
5265
|
return config.agents?.[name] ?? null;
|
|
4729
5266
|
case "file":
|
|
4730
5267
|
return config.files?.[name] ?? null;
|
|
5268
|
+
case "identity":
|
|
5269
|
+
return config.identities?.[name] ?? null;
|
|
5270
|
+
case "channel":
|
|
5271
|
+
return config.channels?.[name] ?? null;
|
|
4731
5272
|
case "deployment":
|
|
4732
5273
|
return config.deployments?.[name] ?? null;
|
|
4733
5274
|
default:
|
|
@@ -4784,8 +5325,26 @@ async function computeResourceHash(address, config, basePath, state) {
|
|
|
4784
5325
|
const refs = resolveTemplateReferenceIds(decl, config, address.provider, state);
|
|
4785
5326
|
return contentHash({ decl, refs });
|
|
4786
5327
|
}
|
|
5328
|
+
if (address.type === "channel") {
|
|
5329
|
+
const refs = resolveChannelReferenceIds(
|
|
5330
|
+
decl,
|
|
5331
|
+
config,
|
|
5332
|
+
address.provider,
|
|
5333
|
+
state
|
|
5334
|
+
);
|
|
5335
|
+
return contentHash({ decl, refs });
|
|
5336
|
+
}
|
|
4787
5337
|
return contentHash(decl);
|
|
4788
5338
|
}
|
|
5339
|
+
function resolveChannelReferenceIds(decl, config, provider, state) {
|
|
5340
|
+
const agent = config.agents?.[decl.agent];
|
|
5341
|
+
const agentType = agent?.delivery?.[provider]?.type === "forward" ? "template" : "agent";
|
|
5342
|
+
const identity = decl.identity ?? config.defaults?.identity;
|
|
5343
|
+
return {
|
|
5344
|
+
agent_id: state?.getResource({ type: agentType, name: decl.agent, provider })?.remote_id,
|
|
5345
|
+
identity_id: identity ? state?.getResource({ type: "identity", name: identity, provider })?.remote_id : void 0
|
|
5346
|
+
};
|
|
5347
|
+
}
|
|
4789
5348
|
function resolveTemplateReferenceIds(decl, config, provider, state) {
|
|
4790
5349
|
const environment = decl.environment ? config.environments?.[decl.environment] : void 0;
|
|
4791
5350
|
const tunnel = decl.tunnel ? config.tunnels?.[decl.tunnel] : void 0;
|
|
@@ -4884,14 +5443,14 @@ function structurallyEqual(left, right) {
|
|
|
4884
5443
|
}
|
|
4885
5444
|
|
|
4886
5445
|
// src/internal/providers/drift-support.ts
|
|
4887
|
-
function supportsFullDrift(
|
|
4888
|
-
return
|
|
5446
|
+
function supportsFullDrift(adapter2, type) {
|
|
5447
|
+
return adapter2.getDriftSupport?.(type) === "full" && typeof adapter2.readComparableResource === "function";
|
|
4889
5448
|
}
|
|
4890
|
-
async function readComparableIfSupported(
|
|
4891
|
-
if (!supportsFullDrift(
|
|
4892
|
-
if (typeof
|
|
5449
|
+
async function readComparableIfSupported(adapter2, type, id, name) {
|
|
5450
|
+
if (!supportsFullDrift(adapter2, type)) return null;
|
|
5451
|
+
if (typeof adapter2.readComparableResource !== "function") return null;
|
|
4893
5452
|
try {
|
|
4894
|
-
return await
|
|
5453
|
+
return await adapter2.readComparableResource(type, id, name);
|
|
4895
5454
|
} catch {
|
|
4896
5455
|
return null;
|
|
4897
5456
|
}
|
|
@@ -5026,6 +5585,20 @@ function resolveDeploymentRefs(deploymentName, config, provider, state) {
|
|
|
5026
5585
|
memory_store_ids
|
|
5027
5586
|
};
|
|
5028
5587
|
}
|
|
5588
|
+
function resolveChannelRefs(channelName, config, provider, state) {
|
|
5589
|
+
const channel = config.channels?.[channelName];
|
|
5590
|
+
if (!channel) throw new UserError(`Channel '${channelName}' not found in config`);
|
|
5591
|
+
const agent = config.agents?.[channel.agent];
|
|
5592
|
+
if (!agent) throw new UserError(`Channel '${channelName}' references unknown agent '${channel.agent}'`);
|
|
5593
|
+
const agentType = agent.delivery?.[provider]?.type === "forward" ? "template" : "agent";
|
|
5594
|
+
const agent_id = requireRef(state, { type: agentType, name: channel.agent, provider });
|
|
5595
|
+
const identityName = channel.identity ?? config.defaults?.identity;
|
|
5596
|
+
if (!identityName) {
|
|
5597
|
+
throw new UserError(`Channel '${channelName}' must declare identity or use defaults.identity.`);
|
|
5598
|
+
}
|
|
5599
|
+
const identity_id = requireRef(state, { type: "identity", name: identityName, provider });
|
|
5600
|
+
return { identity_id, agent_id };
|
|
5601
|
+
}
|
|
5029
5602
|
function resolveTunnelIdFromConfig(config, tunnelName, provider) {
|
|
5030
5603
|
if (provider !== "qoder") {
|
|
5031
5604
|
throw new UserError("Tunnels are supported only by Qoder BYOC sessions.");
|
|
@@ -5078,10 +5651,10 @@ async function executePlan(plan, ctx, options = {}) {
|
|
|
5078
5651
|
const failed = /* @__PURE__ */ new Set();
|
|
5079
5652
|
let stateUpdated = false;
|
|
5080
5653
|
for (const action of plan.actions) {
|
|
5081
|
-
if (action.address.type !== "environment") continue;
|
|
5082
|
-
const decl = ctx.config.environments?.[action.address.name];
|
|
5654
|
+
if (action.address.type !== "environment" && action.address.type !== "identity") continue;
|
|
5083
5655
|
const existing = ctx.state.getResource(action.address);
|
|
5084
|
-
|
|
5656
|
+
const externalId = action.address.type === "environment" ? ctx.config.environments?.[action.address.name]?.environment_id : ctx.config.identities?.[action.address.name]?.identity_id;
|
|
5657
|
+
if (externalId && existing && !existing.externally_managed) {
|
|
5085
5658
|
ctx.state.setResource({ ...existing, externally_managed: true });
|
|
5086
5659
|
stateUpdated = true;
|
|
5087
5660
|
}
|
|
@@ -5225,9 +5798,9 @@ async function executeActionInner(action, provider, ctx) {
|
|
|
5225
5798
|
const existing = ctx.state.getResource(address);
|
|
5226
5799
|
if (!existing) return false;
|
|
5227
5800
|
const id = existing.remote_id;
|
|
5228
|
-
if (type === "environment") {
|
|
5229
|
-
const
|
|
5230
|
-
if (existing.externally_managed ||
|
|
5801
|
+
if (type === "environment" || type === "identity") {
|
|
5802
|
+
const externalReference = type === "environment" ? ctx.config.environments?.[name]?.environment_id : ctx.config.identities?.[name]?.identity_id;
|
|
5803
|
+
if (existing.externally_managed || externalReference) {
|
|
5231
5804
|
ctx.state.removeResource(address);
|
|
5232
5805
|
return false;
|
|
5233
5806
|
}
|
|
@@ -5262,6 +5835,16 @@ async function executeActionInner(action, provider, ctx) {
|
|
|
5262
5835
|
case "file":
|
|
5263
5836
|
await provider.deleteFile(id);
|
|
5264
5837
|
break;
|
|
5838
|
+
case "identity":
|
|
5839
|
+
if (!provider.deleteIdentity)
|
|
5840
|
+
throw new UserError(`Provider '${address.provider}' does not support identities`);
|
|
5841
|
+
await provider.deleteIdentity(id);
|
|
5842
|
+
break;
|
|
5843
|
+
case "channel":
|
|
5844
|
+
if (!provider.deleteChannel)
|
|
5845
|
+
throw new UserError(`Provider '${address.provider}' does not support channels`);
|
|
5846
|
+
await provider.deleteChannel(id);
|
|
5847
|
+
break;
|
|
5265
5848
|
}
|
|
5266
5849
|
} catch (err) {
|
|
5267
5850
|
if (!ApiError.isNotFound(err)) throw err;
|
|
@@ -5383,27 +5966,51 @@ async function executeActionInner(action, provider, ctx) {
|
|
|
5383
5966
|
break;
|
|
5384
5967
|
}
|
|
5385
5968
|
case "memory_store": {
|
|
5386
|
-
const
|
|
5387
|
-
const
|
|
5388
|
-
if (!
|
|
5969
|
+
const createMemoryStore2 = provider.createMemoryStore?.bind(provider);
|
|
5970
|
+
const deleteMemoryStore2 = provider.deleteMemoryStore?.bind(provider);
|
|
5971
|
+
if (!createMemoryStore2 || !deleteMemoryStore2) throw memoryStoreUnsupported(address.provider);
|
|
5389
5972
|
const decl = ctx.config.memory_stores[name];
|
|
5390
|
-
if (
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5973
|
+
if (!provider.updateMemoryStore || !provider.listMemories || !provider.createMemory || !provider.updateMemory) {
|
|
5974
|
+
throw memoryStoreUnsupported(address.provider);
|
|
5975
|
+
}
|
|
5976
|
+
const reconcile = async (storeId) => {
|
|
5977
|
+
const store = await provider.updateMemoryStore(storeId, {
|
|
5978
|
+
name,
|
|
5979
|
+
description: decl.description,
|
|
5980
|
+
metadata: decl.metadata ?? {}
|
|
5981
|
+
});
|
|
5982
|
+
const current = /* @__PURE__ */ new Map();
|
|
5983
|
+
let cursor;
|
|
5984
|
+
do {
|
|
5985
|
+
const page2 = await provider.listMemories(storeId, { limit: 100, cursor, view: "basic" });
|
|
5986
|
+
for (const memory of page2.data) {
|
|
5987
|
+
if (memory.type === "memory") current.set(memory.path, memory);
|
|
5988
|
+
}
|
|
5989
|
+
cursor = page2.has_more ? page2.next_cursor : void 0;
|
|
5990
|
+
} while (cursor);
|
|
5991
|
+
for (const entry of decl.entries ?? []) {
|
|
5992
|
+
const existing = current.get(entry.key.replace(/^\/+/, ""));
|
|
5993
|
+
if (existing) {
|
|
5994
|
+
if (existing.content_sha256 !== sha256(entry.content)) {
|
|
5995
|
+
await provider.updateMemory(storeId, existing.id, {
|
|
5996
|
+
content: entry.content,
|
|
5997
|
+
expected_content_sha256: existing.content_sha256
|
|
5998
|
+
});
|
|
5999
|
+
}
|
|
6000
|
+
} else {
|
|
6001
|
+
await provider.createMemory(storeId, { path: entry.key, content: entry.content });
|
|
6002
|
+
}
|
|
5397
6003
|
}
|
|
6004
|
+
return store;
|
|
6005
|
+
};
|
|
6006
|
+
if (isUpdate) {
|
|
6007
|
+
result = await reconcile(existingId);
|
|
5398
6008
|
} else {
|
|
5399
6009
|
try {
|
|
5400
|
-
result = await
|
|
6010
|
+
result = await createMemoryStore2(name, decl);
|
|
5401
6011
|
} catch (err) {
|
|
5402
6012
|
result = await adoptOnConflict(err, address, provider, ctx.onFeedback, {
|
|
5403
|
-
onExisting: async (existing) =>
|
|
5404
|
-
await deleteMemoryStore(existing.id);
|
|
5405
|
-
return createMemoryStore(name, decl);
|
|
5406
|
-
}
|
|
6013
|
+
onExisting: async (existing) => reconcile(existing.id)
|
|
5407
6014
|
});
|
|
5408
6015
|
adopted = true;
|
|
5409
6016
|
}
|
|
@@ -5451,6 +6058,63 @@ async function executeActionInner(action, provider, ctx) {
|
|
|
5451
6058
|
}
|
|
5452
6059
|
break;
|
|
5453
6060
|
}
|
|
6061
|
+
case "identity": {
|
|
6062
|
+
const createIdentity = provider.createIdentity?.bind(provider);
|
|
6063
|
+
const updateIdentity = provider.updateIdentity?.bind(provider);
|
|
6064
|
+
if (!createIdentity || !updateIdentity) {
|
|
6065
|
+
throw new UserError(`Provider '${address.provider}' does not support identities`);
|
|
6066
|
+
}
|
|
6067
|
+
const decl = ctx.config.identities[name];
|
|
6068
|
+
if (decl.identity_id) {
|
|
6069
|
+
const remote2 = await provider.findResource("identity", name, decl.identity_id);
|
|
6070
|
+
if (!remote2?.id) {
|
|
6071
|
+
throw new UserError(
|
|
6072
|
+
`External identity.${name} '${decl.identity_id}' was not found on provider '${address.provider}'.`
|
|
6073
|
+
);
|
|
6074
|
+
}
|
|
6075
|
+
result = remote2;
|
|
6076
|
+
break;
|
|
6077
|
+
}
|
|
6078
|
+
if (isUpdate) {
|
|
6079
|
+
if (ctx.state.getResource(address)?.externally_managed) {
|
|
6080
|
+
throw new UserError(`identity.${name} is recorded as an external reference; refusing to modify it remotely.`);
|
|
6081
|
+
}
|
|
6082
|
+
result = await updateIdentity(existingId, name, decl);
|
|
6083
|
+
} else {
|
|
6084
|
+
try {
|
|
6085
|
+
result = await createIdentity(name, decl);
|
|
6086
|
+
} catch (err) {
|
|
6087
|
+
if (!(err instanceof ConflictError)) throw err;
|
|
6088
|
+
const existing = await provider.findResource("identity", decl.external_id);
|
|
6089
|
+
if (!existing?.id) throw err;
|
|
6090
|
+
result = await updateIdentity(existing.id, name, decl);
|
|
6091
|
+
adopted = true;
|
|
6092
|
+
}
|
|
6093
|
+
}
|
|
6094
|
+
break;
|
|
6095
|
+
}
|
|
6096
|
+
case "channel": {
|
|
6097
|
+
const createChannel = provider.createChannel?.bind(provider);
|
|
6098
|
+
const updateChannel = provider.updateChannel?.bind(provider);
|
|
6099
|
+
if (!createChannel || !updateChannel) {
|
|
6100
|
+
throw new UserError(`Provider '${address.provider}' does not support channels`);
|
|
6101
|
+
}
|
|
6102
|
+
const decl = ctx.config.channels[name];
|
|
6103
|
+
const refs = resolveChannelRefs(name, ctx.config, address.provider, ctx.state);
|
|
6104
|
+
if (isUpdate) {
|
|
6105
|
+
result = await updateChannel(existingId, name, decl, refs);
|
|
6106
|
+
} else {
|
|
6107
|
+
try {
|
|
6108
|
+
result = await createChannel(name, decl, refs);
|
|
6109
|
+
} catch (err) {
|
|
6110
|
+
result = await adoptOnConflict(err, address, provider, ctx.onFeedback, {
|
|
6111
|
+
onExisting: (existing) => updateChannel(existing.id, name, decl, refs)
|
|
6112
|
+
});
|
|
6113
|
+
adopted = true;
|
|
6114
|
+
}
|
|
6115
|
+
}
|
|
6116
|
+
break;
|
|
6117
|
+
}
|
|
5454
6118
|
case "deployment": {
|
|
5455
6119
|
const decl = ctx.config.deployments[name];
|
|
5456
6120
|
const refs = resolveDeploymentRefs(name, ctx.config, address.provider, ctx.state);
|
|
@@ -5503,7 +6167,7 @@ async function executeActionInner(action, provider, ctx) {
|
|
|
5503
6167
|
ctx.state.setResource({
|
|
5504
6168
|
address,
|
|
5505
6169
|
remote_id: result.id,
|
|
5506
|
-
externally_managed: priorResource?.externally_managed || type === "environment" && ctx.config.environments?.[name]?.environment_id ? true : void 0,
|
|
6170
|
+
externally_managed: priorResource?.externally_managed || type === "environment" && ctx.config.environments?.[name]?.environment_id || type === "identity" && ctx.config.identities?.[name]?.identity_id ? true : void 0,
|
|
5507
6171
|
version: result.version,
|
|
5508
6172
|
content_hash: hash,
|
|
5509
6173
|
desired_hash: hash,
|
|
@@ -5637,6 +6301,13 @@ function collectReferenceDiagnostics(config, diagnostics) {
|
|
|
5637
6301
|
const vaultNames = new Set(Object.keys(config.vaults ?? {}));
|
|
5638
6302
|
const memoryNames = new Set(Object.keys(config.memory_stores ?? {}));
|
|
5639
6303
|
const agentNames = new Set(Object.keys(config.agents ?? {}));
|
|
6304
|
+
const identityNames = new Set(Object.keys(config.identities ?? {}));
|
|
6305
|
+
if (config.defaults?.identity && !identityNames.has(config.defaults.identity)) {
|
|
6306
|
+
diagnostics.error(
|
|
6307
|
+
"config.defaults.identity.unknown",
|
|
6308
|
+
`defaults.identity references unknown identity '${config.defaults.identity}'`
|
|
6309
|
+
);
|
|
6310
|
+
}
|
|
5640
6311
|
for (const [name, agent] of Object.entries(config.agents ?? {})) {
|
|
5641
6312
|
if (agent.environment && !envNames.has(agent.environment)) {
|
|
5642
6313
|
diagnostics.error(
|
|
@@ -5686,6 +6357,23 @@ function collectReferenceDiagnostics(config, diagnostics) {
|
|
|
5686
6357
|
);
|
|
5687
6358
|
}
|
|
5688
6359
|
}
|
|
6360
|
+
for (const [name, channel] of Object.entries(config.channels ?? {})) {
|
|
6361
|
+
if (!agentNames.has(channel.agent)) {
|
|
6362
|
+
diagnostics.error("config.channel.agent.unknown", `channel.${name}: references unknown agent '${channel.agent}'`);
|
|
6363
|
+
}
|
|
6364
|
+
const identity = channel.identity ?? config.defaults?.identity;
|
|
6365
|
+
if (!identity) {
|
|
6366
|
+
diagnostics.error(
|
|
6367
|
+
"config.channel.identity.required",
|
|
6368
|
+
`channel.${name}: declare identity or configure defaults.identity`
|
|
6369
|
+
);
|
|
6370
|
+
} else if (!identityNames.has(identity)) {
|
|
6371
|
+
diagnostics.error(
|
|
6372
|
+
"config.channel.identity.unknown",
|
|
6373
|
+
`channel.${name}: references unknown identity '${identity}'`
|
|
6374
|
+
);
|
|
6375
|
+
}
|
|
6376
|
+
}
|
|
5689
6377
|
}
|
|
5690
6378
|
function collectProviderCapabilities(config, providers, diagnostics) {
|
|
5691
6379
|
for (const providerName of providers) {
|
|
@@ -5698,6 +6386,80 @@ function collectProviderCapabilities(config, providers, diagnostics) {
|
|
|
5698
6386
|
continue;
|
|
5699
6387
|
}
|
|
5700
6388
|
const caps = def.capabilities;
|
|
6389
|
+
for (const [name, identity] of Object.entries(config.identities ?? {})) {
|
|
6390
|
+
if (identity.provider && identity.provider !== providerName) continue;
|
|
6391
|
+
if (!isSupported(caps, "identity")) {
|
|
6392
|
+
diagnostics.error(
|
|
6393
|
+
`${providerName}.identity.unsupported`,
|
|
6394
|
+
`${caps.identity.reason}. ${caps.identity.remediation ?? ""}`.trim(),
|
|
6395
|
+
{ type: "identity", name, provider: providerName }
|
|
6396
|
+
);
|
|
6397
|
+
}
|
|
6398
|
+
}
|
|
6399
|
+
for (const [name, channel] of Object.entries(config.channels ?? {})) {
|
|
6400
|
+
if (channel.provider && channel.provider !== providerName) continue;
|
|
6401
|
+
if (!isSupported(caps, "channel")) {
|
|
6402
|
+
diagnostics.error(
|
|
6403
|
+
`${providerName}.channel.unsupported`,
|
|
6404
|
+
`${caps.channel.reason}. ${caps.channel.remediation ?? ""}`.trim(),
|
|
6405
|
+
{ type: "channel", name, provider: providerName }
|
|
6406
|
+
);
|
|
6407
|
+
continue;
|
|
6408
|
+
}
|
|
6409
|
+
if (providerName === "qoder") {
|
|
6410
|
+
const agent = config.agents?.[channel.agent];
|
|
6411
|
+
if (agent?.provider && agent.provider !== providerName) {
|
|
6412
|
+
diagnostics.error(
|
|
6413
|
+
"config.channel.agent.provider_mismatch",
|
|
6414
|
+
`channel.${name}: agent '${channel.agent}' is pinned to provider '${agent.provider}'.`,
|
|
6415
|
+
{ type: "channel", name, provider: providerName }
|
|
6416
|
+
);
|
|
6417
|
+
}
|
|
6418
|
+
const identityName = channel.identity ?? config.defaults?.identity;
|
|
6419
|
+
const identity = identityName ? config.identities?.[identityName] : void 0;
|
|
6420
|
+
if (identity?.provider && identity.provider !== providerName) {
|
|
6421
|
+
diagnostics.error(
|
|
6422
|
+
"config.channel.identity.provider_mismatch",
|
|
6423
|
+
`channel.${name}: identity '${identityName}' is pinned to provider '${identity.provider}'.`,
|
|
6424
|
+
{ type: "channel", name, provider: providerName }
|
|
6425
|
+
);
|
|
6426
|
+
}
|
|
6427
|
+
if (agent && agent.delivery?.qoder?.type !== "forward") {
|
|
6428
|
+
diagnostics.error(
|
|
6429
|
+
"qoder.channel.forward_template.required",
|
|
6430
|
+
`channel.${name}: Qoder Channels require agent '${channel.agent}' to use delivery.qoder.type: forward.`,
|
|
6431
|
+
{ type: "channel", name, provider: providerName }
|
|
6432
|
+
);
|
|
6433
|
+
}
|
|
6434
|
+
const requiredCredentials = {
|
|
6435
|
+
dingtalk: ["client_id", "client_secret"],
|
|
6436
|
+
feishu: ["app_id", "app_secret"],
|
|
6437
|
+
wecom: ["bot_id", "secret"]
|
|
6438
|
+
};
|
|
6439
|
+
if (channel.type === "wechat") {
|
|
6440
|
+
diagnostics.error(
|
|
6441
|
+
"qoder.channel.wechat.credentials.unsupported",
|
|
6442
|
+
`channel.${name}: personal WeChat supports QR binding only; credential-based apply is unavailable.`,
|
|
6443
|
+
{ type: "channel", name, provider: providerName }
|
|
6444
|
+
);
|
|
6445
|
+
} else if (!requiredCredentials[channel.type]) {
|
|
6446
|
+
diagnostics.error(
|
|
6447
|
+
"qoder.channel.type.unsupported",
|
|
6448
|
+
`channel.${name}: unsupported Qoder channel type '${channel.type}'.`,
|
|
6449
|
+
{ type: "channel", name, provider: providerName }
|
|
6450
|
+
);
|
|
6451
|
+
} else {
|
|
6452
|
+
const missing = requiredCredentials[channel.type].filter((key) => !channel.credentials?.[key]);
|
|
6453
|
+
if (missing.length) {
|
|
6454
|
+
diagnostics.error(
|
|
6455
|
+
"qoder.channel.credentials.required",
|
|
6456
|
+
`channel.${name}: '${channel.type}' requires credentials: ${missing.join(", ")}.`,
|
|
6457
|
+
{ type: "channel", name, provider: providerName }
|
|
6458
|
+
);
|
|
6459
|
+
}
|
|
6460
|
+
}
|
|
6461
|
+
}
|
|
6462
|
+
}
|
|
5701
6463
|
for (const [name, agent] of Object.entries(config.agents ?? {})) {
|
|
5702
6464
|
if (agent.provider && agent.provider !== providerName) continue;
|
|
5703
6465
|
const delivery = agent.delivery?.[providerName]?.type ?? "managed";
|
|
@@ -5911,6 +6673,13 @@ function buildDependencyGraph(config, targetProviders) {
|
|
|
5911
6673
|
addNode({ type: "file", name, provider });
|
|
5912
6674
|
}
|
|
5913
6675
|
}
|
|
6676
|
+
if (config.identities && isSupported(caps, "identity")) {
|
|
6677
|
+
for (const name of Object.keys(config.identities)) {
|
|
6678
|
+
const decl = config.identities[name];
|
|
6679
|
+
if (decl.provider && decl.provider !== provider) continue;
|
|
6680
|
+
addNode({ type: "identity", name, provider });
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
5914
6683
|
if (config.agents) {
|
|
5915
6684
|
for (const name of Object.keys(config.agents)) {
|
|
5916
6685
|
const decl = config.agents[name];
|
|
@@ -6002,6 +6771,23 @@ function buildDependencyGraph(config, targetProviders) {
|
|
|
6002
6771
|
}
|
|
6003
6772
|
}
|
|
6004
6773
|
}
|
|
6774
|
+
if (config.channels && isSupported(caps, "channel")) {
|
|
6775
|
+
for (const name of Object.keys(config.channels)) {
|
|
6776
|
+
const decl = config.channels[name];
|
|
6777
|
+
if (decl.provider && decl.provider !== provider) continue;
|
|
6778
|
+
const channelAddr = { type: "channel", name, provider };
|
|
6779
|
+
addNode(channelAddr);
|
|
6780
|
+
const agentDecl = config.agents?.[decl.agent];
|
|
6781
|
+
const agentType = agentDecl ? resolveAgentMaterialization(provider, agentDecl).resourceType : "agent";
|
|
6782
|
+
const agentAddr = { type: agentType, name: decl.agent, provider };
|
|
6783
|
+
if (nodes.has(addressKey(agentAddr))) addEdge(channelAddr, agentAddr);
|
|
6784
|
+
const identityName = decl.identity ?? config.defaults?.identity;
|
|
6785
|
+
if (identityName) {
|
|
6786
|
+
const identityAddr = { type: "identity", name: identityName, provider };
|
|
6787
|
+
if (nodes.has(addressKey(identityAddr))) addEdge(channelAddr, identityAddr);
|
|
6788
|
+
}
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6005
6791
|
}
|
|
6006
6792
|
return { nodes, edges };
|
|
6007
6793
|
}
|
|
@@ -6071,9 +6857,28 @@ async function buildPlan(config, state, options = {}) {
|
|
|
6071
6857
|
);
|
|
6072
6858
|
}
|
|
6073
6859
|
}
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6860
|
+
if (address.type === "identity" && existing) {
|
|
6861
|
+
const identityDecl = config.identities?.[address.name];
|
|
6862
|
+
if (existing.externally_managed && identityDecl && !identityDecl.identity_id) {
|
|
6863
|
+
diagnostics.error(
|
|
6864
|
+
"plan.identity.ownership_transition",
|
|
6865
|
+
`identity.${address.name} is recorded as an external reference (${existing.remote_id ?? "unknown id"}); replacing identity_id with a managed declaration would modify and eventually delete an Identity this project does not own. Restore identity_id or release the state reference first.`,
|
|
6866
|
+
address
|
|
6867
|
+
);
|
|
6868
|
+
stateIndex.delete(key);
|
|
6869
|
+
continue;
|
|
6870
|
+
}
|
|
6871
|
+
if (!existing.externally_managed && existing.remote_id && identityDecl?.identity_id && identityDecl.identity_id !== existing.remote_id) {
|
|
6872
|
+
diagnostics.warning(
|
|
6873
|
+
"plan.identity.ownership_orphan",
|
|
6874
|
+
`identity.${address.name}: switching to external reference '${identityDecl.identity_id}' orphans the previously managed Identity '${existing.remote_id}'.`,
|
|
6875
|
+
address
|
|
6876
|
+
);
|
|
6877
|
+
}
|
|
6878
|
+
}
|
|
6879
|
+
const isExternalReference2 = address.type === "environment" && Boolean(config.environments?.[address.name]?.environment_id) || address.type === "identity" && Boolean(config.identities?.[address.name]?.identity_id);
|
|
6880
|
+
const createReason = isExternalReference2 ? `Record external ${address.type} reference (no remote mutation)` : "Resource does not exist in state";
|
|
6881
|
+
const updateSuffix = isExternalReference2 ? " \u2014 external reference, no remote mutation" : "";
|
|
6077
6882
|
if (!existing) {
|
|
6078
6883
|
actions.push({
|
|
6079
6884
|
action: "create",
|
|
@@ -6319,7 +7124,9 @@ var IMPORTABLE_RESOURCE_TYPES = /* @__PURE__ */ new Set([
|
|
|
6319
7124
|
"memory_store",
|
|
6320
7125
|
"skill",
|
|
6321
7126
|
"agent",
|
|
6322
|
-
"template"
|
|
7127
|
+
"template",
|
|
7128
|
+
"identity",
|
|
7129
|
+
"channel"
|
|
6323
7130
|
]);
|
|
6324
7131
|
async function importResource(ctx, address, remoteId, options = {}) {
|
|
6325
7132
|
if (!IMPORTABLE_RESOURCE_TYPES.has(address.type)) {
|
|
@@ -6482,25 +7289,25 @@ function resolveSyncProvider(config, explicitProvider) {
|
|
|
6482
7289
|
);
|
|
6483
7290
|
}
|
|
6484
7291
|
async function syncProviderResourcesFromEnv(opts) {
|
|
6485
|
-
const
|
|
7292
|
+
const adapter2 = buildProviderFromEnv(opts.provider);
|
|
6486
7293
|
const providers = await providersBlockFromFile(opts.configPath, opts.provider);
|
|
6487
|
-
return assembleSyncedConfig(
|
|
7294
|
+
return assembleSyncedConfig(adapter2, opts.provider, {
|
|
6488
7295
|
types: opts.types,
|
|
6489
7296
|
version: "1",
|
|
6490
7297
|
providers
|
|
6491
7298
|
});
|
|
6492
7299
|
}
|
|
6493
7300
|
async function syncProviderResourcesFromContext(ctx, opts) {
|
|
6494
|
-
const
|
|
7301
|
+
const adapter2 = getRuntimeProvider(ctx, opts.provider);
|
|
6495
7302
|
const providers = await providersBlockFromFile(ctx.configPath ?? opts.configPath, opts.provider);
|
|
6496
|
-
return assembleSyncedConfig(
|
|
7303
|
+
return assembleSyncedConfig(adapter2, opts.provider, {
|
|
6497
7304
|
types: opts.types,
|
|
6498
7305
|
version: ctx.config.version ?? "1",
|
|
6499
7306
|
providers
|
|
6500
7307
|
});
|
|
6501
7308
|
}
|
|
6502
|
-
async function assembleSyncedConfig(
|
|
6503
|
-
if (!
|
|
7309
|
+
async function assembleSyncedConfig(adapter2, provider, opts) {
|
|
7310
|
+
if (!adapter2.exportResources) {
|
|
6504
7311
|
throw new UserError(`Provider '${provider}' does not support sync (no exportResources).`);
|
|
6505
7312
|
}
|
|
6506
7313
|
const types = opts.types ?? ["environment", "vault", "file", "skill", "agent"];
|
|
@@ -6511,7 +7318,7 @@ async function assembleSyncedConfig(adapter, provider, opts) {
|
|
|
6511
7318
|
if (!groupKey) {
|
|
6512
7319
|
throw new UserError(`Resource type '${type}' is not syncable yet.`);
|
|
6513
7320
|
}
|
|
6514
|
-
const exported = await
|
|
7321
|
+
const exported = await adapter2.exportResources(type);
|
|
6515
7322
|
let group = groups[groupKey];
|
|
6516
7323
|
if (!group) {
|
|
6517
7324
|
group = {};
|
|
@@ -6523,8 +7330,8 @@ async function assembleSyncedConfig(adapter, provider, opts) {
|
|
|
6523
7330
|
}
|
|
6524
7331
|
}
|
|
6525
7332
|
let skillFiles;
|
|
6526
|
-
if (types.includes("skill") &&
|
|
6527
|
-
skillFiles = await
|
|
7333
|
+
if (types.includes("skill") && adapter2.downloadAllSkillFiles) {
|
|
7334
|
+
skillFiles = await adapter2.downloadAllSkillFiles();
|
|
6528
7335
|
}
|
|
6529
7336
|
const config = {
|
|
6530
7337
|
version: opts.version ?? "1",
|
|
@@ -6709,9 +7516,9 @@ function listDeploymentsForContext(ctx, providerFilter) {
|
|
|
6709
7516
|
};
|
|
6710
7517
|
});
|
|
6711
7518
|
}
|
|
6712
|
-
async function getDeploymentDetailsForContext(ctx, name,
|
|
7519
|
+
async function getDeploymentDetailsForContext(ctx, name, adapter2, resolvedProvider) {
|
|
6713
7520
|
const provider = resolvedProvider ?? resolveDeploymentProvider(name, ctx.config);
|
|
6714
|
-
const effectiveAdapter =
|
|
7521
|
+
const effectiveAdapter = adapter2 ?? getRuntimeProvider(ctx, provider);
|
|
6715
7522
|
const depCtx = buildDeploymentContext(ctx, name, provider);
|
|
6716
7523
|
return {
|
|
6717
7524
|
name,
|
|
@@ -6725,9 +7532,9 @@ async function getDeploymentDetailsForContext(ctx, name, adapter, resolvedProvid
|
|
|
6725
7532
|
info: await effectiveAdapter.getDeployment(depCtx)
|
|
6726
7533
|
};
|
|
6727
7534
|
}
|
|
6728
|
-
async function runDeploymentForContext(ctx, name,
|
|
7535
|
+
async function runDeploymentForContext(ctx, name, adapter2, resolvedProvider) {
|
|
6729
7536
|
const provider = resolvedProvider ?? resolveDeploymentProvider(name, ctx.config);
|
|
6730
|
-
const effectiveAdapter =
|
|
7537
|
+
const effectiveAdapter = adapter2 ?? getRuntimeProvider(ctx, provider);
|
|
6731
7538
|
const depCtx = buildDeploymentContext(ctx, name, provider);
|
|
6732
7539
|
return {
|
|
6733
7540
|
name,
|
|
@@ -6774,13 +7581,15 @@ function buildDeploymentContext(ctx, name, provider) {
|
|
|
6774
7581
|
// src/internal/core/destroy-runtime.ts
|
|
6775
7582
|
var destroyOrder = {
|
|
6776
7583
|
deployment: 0,
|
|
7584
|
+
channel: 0,
|
|
6777
7585
|
agent: 1,
|
|
6778
7586
|
template: 1,
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
7587
|
+
identity: 2,
|
|
7588
|
+
skill: 3,
|
|
7589
|
+
memory_store: 4,
|
|
7590
|
+
vault: 5,
|
|
7591
|
+
file: 6,
|
|
7592
|
+
environment: 7
|
|
6784
7593
|
};
|
|
6785
7594
|
function planDestroyProjectContext(ctx) {
|
|
6786
7595
|
const resources = [...ctx.state.listResources()].sort(
|
|
@@ -6811,7 +7620,7 @@ async function destroyPlannedProjectResources(planned, options = {}) {
|
|
|
6811
7620
|
};
|
|
6812
7621
|
}
|
|
6813
7622
|
async function destroyOneResource(ctx, resource, options) {
|
|
6814
|
-
if (
|
|
7623
|
+
if (isExternalReference(ctx, resource)) {
|
|
6815
7624
|
ctx.state.removeResource(resource.address);
|
|
6816
7625
|
return successResult(resource, "reference_removed");
|
|
6817
7626
|
}
|
|
@@ -6875,8 +7684,15 @@ async function destroyOneResource(ctx, resource, options) {
|
|
|
6875
7684
|
return failureResult(resource, error);
|
|
6876
7685
|
}
|
|
6877
7686
|
}
|
|
6878
|
-
function
|
|
6879
|
-
|
|
7687
|
+
function isExternalReference(ctx, resource) {
|
|
7688
|
+
if (resource.externally_managed) return true;
|
|
7689
|
+
if (resource.address.type === "environment") {
|
|
7690
|
+
return Boolean(ctx.config.environments?.[resource.address.name]?.environment_id);
|
|
7691
|
+
}
|
|
7692
|
+
if (resource.address.type === "identity") {
|
|
7693
|
+
return Boolean(ctx.config.identities?.[resource.address.name]?.identity_id);
|
|
7694
|
+
}
|
|
7695
|
+
return false;
|
|
6880
7696
|
}
|
|
6881
7697
|
function successResult(resource, reason) {
|
|
6882
7698
|
return { resource, status: "success", reason };
|
|
@@ -6916,6 +7732,17 @@ async function deleteRemoteResource(provider, type, id, cascade) {
|
|
|
6916
7732
|
case "deployment":
|
|
6917
7733
|
await provider.deleteDeployment(id);
|
|
6918
7734
|
return;
|
|
7735
|
+
case "identity":
|
|
7736
|
+
if (!provider.deleteIdentity) throw new UserError(`Provider does not support identities`);
|
|
7737
|
+
await provider.deleteIdentity(id);
|
|
7738
|
+
return;
|
|
7739
|
+
case "channel":
|
|
7740
|
+
if (!provider.deleteChannel) throw new UserError(`Provider does not support channels`);
|
|
7741
|
+
await provider.deleteChannel(id);
|
|
7742
|
+
return;
|
|
7743
|
+
case "file":
|
|
7744
|
+
await provider.deleteFile(id);
|
|
7745
|
+
return;
|
|
6919
7746
|
}
|
|
6920
7747
|
}
|
|
6921
7748
|
function isReferencedError(error) {
|
|
@@ -6930,11 +7757,11 @@ async function listProviderModelsForContext(providers, providerFilter) {
|
|
|
6930
7757
|
const targetProviders = providerFilter ? [providerFilter] : Array.from(providers.keys());
|
|
6931
7758
|
const result = [];
|
|
6932
7759
|
for (const name of targetProviders) {
|
|
6933
|
-
const
|
|
6934
|
-
if (!
|
|
7760
|
+
const adapter2 = providers.get(name);
|
|
7761
|
+
if (!adapter2) {
|
|
6935
7762
|
throw new UserError(`Provider '${name}' is not configured.`);
|
|
6936
7763
|
}
|
|
6937
|
-
if (!
|
|
7764
|
+
if (!adapter2.listModels) {
|
|
6938
7765
|
result.push({
|
|
6939
7766
|
provider: name,
|
|
6940
7767
|
supportsDynamicListing: false,
|
|
@@ -6945,7 +7772,7 @@ async function listProviderModelsForContext(providers, providerFilter) {
|
|
|
6945
7772
|
result.push({
|
|
6946
7773
|
provider: name,
|
|
6947
7774
|
supportsDynamicListing: true,
|
|
6948
|
-
models: await
|
|
7775
|
+
models: await adapter2.listModels()
|
|
6949
7776
|
});
|
|
6950
7777
|
}
|
|
6951
7778
|
return result;
|
|
@@ -6960,6 +7787,89 @@ function listProviderDiscovery() {
|
|
|
6960
7787
|
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
6961
7788
|
}
|
|
6962
7789
|
|
|
7790
|
+
// src/internal/core/memory-runtime.ts
|
|
7791
|
+
function adapter(providers, provider) {
|
|
7792
|
+
const value = providers.get(provider);
|
|
7793
|
+
if (!value) throw new UserError(`Provider '${provider}' is not configured.`);
|
|
7794
|
+
return value;
|
|
7795
|
+
}
|
|
7796
|
+
function method(value, name) {
|
|
7797
|
+
const fn = value[name];
|
|
7798
|
+
if (typeof fn !== "function")
|
|
7799
|
+
throw new UserError(`Provider '${value.name}' does not support memory operation '${String(name)}'.`);
|
|
7800
|
+
return fn.bind(value);
|
|
7801
|
+
}
|
|
7802
|
+
function listMemoryStores(providers, provider, options) {
|
|
7803
|
+
const value = adapter(providers, provider);
|
|
7804
|
+
return method(value, "listMemoryStores")(options);
|
|
7805
|
+
}
|
|
7806
|
+
function getMemoryProviderCapabilities(providers, provider) {
|
|
7807
|
+
const value = adapter(providers, provider);
|
|
7808
|
+
if (!value.memoryCapabilities) throw new UserError(`Provider '${provider}' does not support memory stores.`);
|
|
7809
|
+
return value.memoryCapabilities;
|
|
7810
|
+
}
|
|
7811
|
+
async function createMemoryStore(providers, provider, input) {
|
|
7812
|
+
const value = adapter(providers, provider);
|
|
7813
|
+
const created = await method(value, "createMemoryStore")(input.name, {
|
|
7814
|
+
description: input.description ?? "",
|
|
7815
|
+
metadata: input.metadata
|
|
7816
|
+
});
|
|
7817
|
+
if (!created.id) throw new UserError(`Provider '${provider}' returned no memory store id.`);
|
|
7818
|
+
return method(value, "getMemoryStore")(created.id);
|
|
7819
|
+
}
|
|
7820
|
+
function deleteMemoryStore(providers, provider, id) {
|
|
7821
|
+
const value = adapter(providers, provider);
|
|
7822
|
+
return method(value, "deleteMemoryStore")(id);
|
|
7823
|
+
}
|
|
7824
|
+
function getMemoryStore(providers, provider, id) {
|
|
7825
|
+
const value = adapter(providers, provider);
|
|
7826
|
+
return method(value, "getMemoryStore")(id);
|
|
7827
|
+
}
|
|
7828
|
+
function updateMemoryStore(providers, provider, id, input) {
|
|
7829
|
+
const value = adapter(providers, provider);
|
|
7830
|
+
return method(value, "updateMemoryStore")(id, input);
|
|
7831
|
+
}
|
|
7832
|
+
function archiveMemoryStore(providers, provider, id) {
|
|
7833
|
+
const value = adapter(providers, provider);
|
|
7834
|
+
return method(value, "archiveMemoryStore")(id);
|
|
7835
|
+
}
|
|
7836
|
+
function createMemory(providers, provider, storeId, input) {
|
|
7837
|
+
const value = adapter(providers, provider);
|
|
7838
|
+
return method(value, "createMemory")(storeId, input);
|
|
7839
|
+
}
|
|
7840
|
+
function batchCreateMemories(providers, provider, storeId, input) {
|
|
7841
|
+
const value = adapter(providers, provider);
|
|
7842
|
+
return method(value, "batchCreateMemories")(storeId, input);
|
|
7843
|
+
}
|
|
7844
|
+
function listMemories(providers, provider, storeId, options) {
|
|
7845
|
+
const value = adapter(providers, provider);
|
|
7846
|
+
return method(value, "listMemories")(storeId, options);
|
|
7847
|
+
}
|
|
7848
|
+
function getMemory(providers, provider, storeId, memoryId) {
|
|
7849
|
+
const value = adapter(providers, provider);
|
|
7850
|
+
return method(value, "getMemory")(storeId, memoryId);
|
|
7851
|
+
}
|
|
7852
|
+
function updateMemory(providers, provider, storeId, memoryId, input) {
|
|
7853
|
+
const value = adapter(providers, provider);
|
|
7854
|
+
return method(value, "updateMemory")(storeId, memoryId, input);
|
|
7855
|
+
}
|
|
7856
|
+
function deleteMemory(providers, provider, storeId, memoryId, expected) {
|
|
7857
|
+
const value = adapter(providers, provider);
|
|
7858
|
+
return method(value, "deleteMemory")(storeId, memoryId, expected);
|
|
7859
|
+
}
|
|
7860
|
+
function listMemoryVersions(providers, provider, storeId, options) {
|
|
7861
|
+
const value = adapter(providers, provider);
|
|
7862
|
+
return method(value, "listMemoryVersions")(storeId, options);
|
|
7863
|
+
}
|
|
7864
|
+
function getMemoryVersion(providers, provider, storeId, versionId) {
|
|
7865
|
+
const value = adapter(providers, provider);
|
|
7866
|
+
return method(value, "getMemoryVersion")(storeId, versionId);
|
|
7867
|
+
}
|
|
7868
|
+
function redactMemoryVersion(providers, provider, storeId, versionId) {
|
|
7869
|
+
const value = adapter(providers, provider);
|
|
7870
|
+
return method(value, "redactMemoryVersion")(storeId, versionId);
|
|
7871
|
+
}
|
|
7872
|
+
|
|
6963
7873
|
// src/internal/core/agent-builder.ts
|
|
6964
7874
|
function buildAgentDecl(base, input) {
|
|
6965
7875
|
const model = input.model ?? base?.model;
|
|
@@ -7035,11 +7945,17 @@ function buildSessionBindings(agentName, config, provider, state, options = {})
|
|
|
7035
7945
|
}
|
|
7036
7946
|
if (resolveAgentMaterialization(provider, agent).resourceType === "template") {
|
|
7037
7947
|
const templateId = requireRef(state, { type: "template", name: agentName, provider });
|
|
7038
|
-
const
|
|
7948
|
+
const defaultIdentity = config.defaults?.identity;
|
|
7949
|
+
const identityId = options.identityId ?? (defaultIdentity ? requireRef(state, { type: "identity", name: defaultIdentity, provider }) : void 0);
|
|
7950
|
+
if (!identityId) {
|
|
7951
|
+
throw new UserError(
|
|
7952
|
+
`Forward session for '${agentName}' requires an Identity. Configure defaults.identity or pass --identity-id.`
|
|
7953
|
+
);
|
|
7954
|
+
}
|
|
7039
7955
|
return {
|
|
7040
7956
|
delivery: "forward",
|
|
7041
7957
|
template_id: templateId,
|
|
7042
|
-
|
|
7958
|
+
identity_id: identityId,
|
|
7043
7959
|
files: (options.files ?? []).map((file) => ({ file_id: file.fileId, mount_path: file.mountPath })),
|
|
7044
7960
|
title: options.title,
|
|
7045
7961
|
metadata: options.metadata
|
|
@@ -7123,9 +8039,9 @@ async function listCloudAgents(ctx, options = {}) {
|
|
|
7123
8039
|
throw new UserError("Multiple providers configured. Pass `provider` to list cloud agents.");
|
|
7124
8040
|
}
|
|
7125
8041
|
}
|
|
7126
|
-
const
|
|
7127
|
-
if (!
|
|
7128
|
-
return
|
|
8042
|
+
const adapter2 = getRuntimeProvider(ctx, provider);
|
|
8043
|
+
if (!adapter2.listAgents) return [];
|
|
8044
|
+
return adapter2.listAgents({ prefix: options.prefix, limit: options.limit });
|
|
7129
8045
|
}
|
|
7130
8046
|
function resolveSingleProvider(ctx, provider) {
|
|
7131
8047
|
if (provider) return provider;
|
|
@@ -7134,55 +8050,55 @@ function resolveSingleProvider(ctx, provider) {
|
|
|
7134
8050
|
throw new UserError("Multiple providers configured. Pass `provider` to target one.");
|
|
7135
8051
|
}
|
|
7136
8052
|
async function listCloudEnvironments(ctx, options = {}) {
|
|
7137
|
-
const
|
|
8053
|
+
const adapter2 = getRuntimeProvider(
|
|
7138
8054
|
ctx,
|
|
7139
8055
|
resolveSingleProvider(ctx, options.provider)
|
|
7140
8056
|
);
|
|
7141
|
-
if (!
|
|
7142
|
-
return
|
|
8057
|
+
if (!adapter2.listEnvironments) return [];
|
|
8058
|
+
return adapter2.listEnvironments({ limit: options.limit });
|
|
7143
8059
|
}
|
|
7144
8060
|
async function createCloudEnvironment(ctx, name, decl, options = {}) {
|
|
7145
|
-
const
|
|
8061
|
+
const adapter2 = getRuntimeProvider(
|
|
7146
8062
|
ctx,
|
|
7147
8063
|
resolveSingleProvider(ctx, options.provider)
|
|
7148
8064
|
);
|
|
7149
|
-
return
|
|
8065
|
+
return adapter2.createEnvironment(name, decl);
|
|
7150
8066
|
}
|
|
7151
8067
|
async function deleteCloudEnvironment(ctx, id, options = {}) {
|
|
7152
|
-
const
|
|
8068
|
+
const adapter2 = getRuntimeProvider(
|
|
7153
8069
|
ctx,
|
|
7154
8070
|
resolveSingleProvider(ctx, options.provider)
|
|
7155
8071
|
);
|
|
7156
|
-
await
|
|
8072
|
+
await adapter2.deleteEnvironment(id);
|
|
7157
8073
|
}
|
|
7158
8074
|
async function listCloudVaults(ctx, options = {}) {
|
|
7159
|
-
const
|
|
8075
|
+
const adapter2 = getRuntimeProvider(
|
|
7160
8076
|
ctx,
|
|
7161
8077
|
resolveSingleProvider(ctx, options.provider)
|
|
7162
8078
|
);
|
|
7163
|
-
if (!
|
|
7164
|
-
return
|
|
8079
|
+
if (!adapter2.listVaults) return [];
|
|
8080
|
+
return adapter2.listVaults({ limit: options.limit });
|
|
7165
8081
|
}
|
|
7166
8082
|
async function createCloudVault(ctx, name, decl, options = {}) {
|
|
7167
|
-
const
|
|
8083
|
+
const adapter2 = getRuntimeProvider(
|
|
7168
8084
|
ctx,
|
|
7169
8085
|
resolveSingleProvider(ctx, options.provider)
|
|
7170
8086
|
);
|
|
7171
|
-
return
|
|
8087
|
+
return adapter2.createVault(name, decl);
|
|
7172
8088
|
}
|
|
7173
8089
|
async function deleteCloudVault(ctx, id, options = {}) {
|
|
7174
|
-
const
|
|
8090
|
+
const adapter2 = getRuntimeProvider(
|
|
7175
8091
|
ctx,
|
|
7176
8092
|
resolveSingleProvider(ctx, options.provider)
|
|
7177
8093
|
);
|
|
7178
|
-
await
|
|
8094
|
+
await adapter2.deleteVault(id);
|
|
7179
8095
|
}
|
|
7180
8096
|
async function archiveCloudAgent(ctx, id, options = {}) {
|
|
7181
|
-
const
|
|
8097
|
+
const adapter2 = getRuntimeProvider(
|
|
7182
8098
|
ctx,
|
|
7183
8099
|
resolveSingleProvider(ctx, options.provider)
|
|
7184
8100
|
);
|
|
7185
|
-
await
|
|
8101
|
+
await adapter2.deleteAgent(id);
|
|
7186
8102
|
}
|
|
7187
8103
|
function getAgent(ctx, agentId) {
|
|
7188
8104
|
const agent = ctx.config.agents?.[agentId];
|
|
@@ -7469,11 +8385,11 @@ function isTerminalSessionStatus(status) {
|
|
|
7469
8385
|
function resolveSessionRuntime(ctx, target = {}) {
|
|
7470
8386
|
const agentName = resolveAgentName(ctx.config.agents, target.agent);
|
|
7471
8387
|
const provider = resolveSessionProvider(agentName, ctx.config, target.provider);
|
|
7472
|
-
const
|
|
7473
|
-
return { agentName, provider, adapter };
|
|
8388
|
+
const adapter2 = getRuntimeProvider(ctx, provider);
|
|
8389
|
+
return { agentName, provider, adapter: adapter2 };
|
|
7474
8390
|
}
|
|
7475
8391
|
async function createSessionForAgent(ctx, options = {}) {
|
|
7476
|
-
const { agentName, provider, adapter } = resolveSessionRuntime(ctx, options);
|
|
8392
|
+
const { agentName, provider, adapter: adapter2 } = resolveSessionRuntime(ctx, options);
|
|
7477
8393
|
const bindings = buildSessionBindings(agentName, ctx.config, provider, ctx.state, {
|
|
7478
8394
|
identityId: options.identityId,
|
|
7479
8395
|
environment: options.environment,
|
|
@@ -7487,11 +8403,11 @@ async function createSessionForAgent(ctx, options = {}) {
|
|
|
7487
8403
|
title: options.title,
|
|
7488
8404
|
metadata: options.metadata
|
|
7489
8405
|
});
|
|
7490
|
-
const session = await
|
|
8406
|
+
const session = await adapter2.createSession(bindings);
|
|
7491
8407
|
return { agentName, provider, session };
|
|
7492
8408
|
}
|
|
7493
8409
|
async function startSessionRun(ctx, prompt, options = {}) {
|
|
7494
|
-
const { agentName, provider, adapter } = resolveSessionRuntime(ctx, options);
|
|
8410
|
+
const { agentName, provider, adapter: adapter2 } = resolveSessionRuntime(ctx, options);
|
|
7495
8411
|
const bindings = buildSessionBindings(agentName, ctx.config, provider, ctx.state, {
|
|
7496
8412
|
identityId: options.identityId,
|
|
7497
8413
|
environment: options.environment,
|
|
@@ -7505,48 +8421,48 @@ async function startSessionRun(ctx, prompt, options = {}) {
|
|
|
7505
8421
|
title: options.title,
|
|
7506
8422
|
metadata: options.metadata
|
|
7507
8423
|
});
|
|
7508
|
-
const session = await
|
|
8424
|
+
const session = await adapter2.createSession(bindings);
|
|
7509
8425
|
return {
|
|
7510
8426
|
agentName,
|
|
7511
8427
|
provider,
|
|
7512
8428
|
session,
|
|
7513
|
-
events: streamMessageEvents(
|
|
8429
|
+
events: streamMessageEvents(adapter2, session.id, preparePromptForProvider(prompt, bindings.files, provider))
|
|
7514
8430
|
};
|
|
7515
8431
|
}
|
|
7516
|
-
function streamMessageEvents(
|
|
7517
|
-
if (
|
|
7518
|
-
return streamWithResume(
|
|
8432
|
+
function streamMessageEvents(adapter2, sessionId, message) {
|
|
8433
|
+
if (adapter2.eventResume) {
|
|
8434
|
+
return streamWithResume(adapter2, sessionId, message);
|
|
7519
8435
|
}
|
|
7520
|
-
return streamConnectBeforeSend(
|
|
8436
|
+
return streamConnectBeforeSend(adapter2, sessionId, message);
|
|
7521
8437
|
}
|
|
7522
8438
|
async function sendSessionMessageStreaming(ctx, sessionId, message, options = {}) {
|
|
7523
|
-
const
|
|
7524
|
-
return streamMessageEvents(
|
|
8439
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8440
|
+
return streamMessageEvents(adapter2, sessionId, message);
|
|
7525
8441
|
}
|
|
7526
8442
|
async function startSessionRunPolling(ctx, prompt, options = {}) {
|
|
7527
8443
|
const run = await createSessionForAgent(ctx, options);
|
|
7528
|
-
const
|
|
8444
|
+
const adapter2 = getRuntimeProvider(ctx, run.provider);
|
|
7529
8445
|
const hintedPrompt = preparePromptForProvider(
|
|
7530
8446
|
prompt,
|
|
7531
8447
|
options.files?.map((f) => ({ mount_path: f.mountPath })),
|
|
7532
8448
|
run.provider
|
|
7533
8449
|
);
|
|
7534
|
-
const collected = await sendSessionMessageAndCollectEvents(
|
|
8450
|
+
const collected = await sendSessionMessageAndCollectEvents(adapter2, run.session.id, hintedPrompt, options);
|
|
7535
8451
|
return { ...run, ...collected };
|
|
7536
8452
|
}
|
|
7537
|
-
async function sendSessionMessageAndCollectEvents(
|
|
7538
|
-
const eventId = await
|
|
7539
|
-
return collectEventsUntilTerminal(
|
|
7540
|
-
afterId:
|
|
8453
|
+
async function sendSessionMessageAndCollectEvents(adapter2, sessionId, message, options = {}) {
|
|
8454
|
+
const eventId = await adapter2.sendSessionMessage(sessionId, message);
|
|
8455
|
+
return collectEventsUntilTerminal(adapter2, sessionId, {
|
|
8456
|
+
afterId: adapter2.eventResume ? eventId : void 0,
|
|
7541
8457
|
pollIntervalMs: options.pollIntervalMs,
|
|
7542
8458
|
pollTimeoutMs: options.pollTimeoutMs
|
|
7543
8459
|
}).then((result) => ({ eventId, ...result }));
|
|
7544
8460
|
}
|
|
7545
8461
|
async function sendSessionMessagePolling(ctx, sessionId, message, options = {}) {
|
|
7546
|
-
const
|
|
7547
|
-
return sendSessionMessageAndCollectEvents(
|
|
8462
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8463
|
+
return sendSessionMessageAndCollectEvents(adapter2, sessionId, message, options);
|
|
7548
8464
|
}
|
|
7549
|
-
async function collectEventsUntilTerminal(
|
|
8465
|
+
async function collectEventsUntilTerminal(adapter2, sessionId, options = {}) {
|
|
7550
8466
|
const start = Date.now();
|
|
7551
8467
|
const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
7552
8468
|
const pollTimeoutMs = options.pollTimeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;
|
|
@@ -7555,7 +8471,7 @@ async function collectEventsUntilTerminal(adapter, sessionId, options = {}) {
|
|
|
7555
8471
|
if (options.afterId) {
|
|
7556
8472
|
while (true) {
|
|
7557
8473
|
assertNotTimedOut(start, pollTimeoutMs);
|
|
7558
|
-
result = await
|
|
8474
|
+
result = await adapter2.listSessionEvents(sessionId, {
|
|
7559
8475
|
limit: 100,
|
|
7560
8476
|
after_id: options.afterId
|
|
7561
8477
|
});
|
|
@@ -7571,14 +8487,14 @@ async function collectEventsUntilTerminal(adapter, sessionId, options = {}) {
|
|
|
7571
8487
|
} else {
|
|
7572
8488
|
while (true) {
|
|
7573
8489
|
assertNotTimedOut(start, pollTimeoutMs);
|
|
7574
|
-
const session = await
|
|
8490
|
+
const session = await adapter2.getSession(sessionId);
|
|
7575
8491
|
if (isTerminalSessionStatus(session.status)) {
|
|
7576
8492
|
terminalStatus = session.status;
|
|
7577
8493
|
break;
|
|
7578
8494
|
}
|
|
7579
8495
|
await delay(pollIntervalMs);
|
|
7580
8496
|
}
|
|
7581
|
-
result = await
|
|
8497
|
+
result = await adapter2.listSessionEvents(sessionId, { limit: 100 });
|
|
7582
8498
|
}
|
|
7583
8499
|
return { terminalStatus, result };
|
|
7584
8500
|
}
|
|
@@ -7613,9 +8529,9 @@ async function listSessionsForProject(ctx, options = {}) {
|
|
|
7613
8529
|
throw new UserError("Multiple providers configured. Use --provider to specify one.");
|
|
7614
8530
|
}
|
|
7615
8531
|
}
|
|
7616
|
-
const
|
|
7617
|
-
const result = await
|
|
7618
|
-
return { provider, adapter, agentId, agentName, result };
|
|
8532
|
+
const adapter2 = getRuntimeProvider(ctx, provider);
|
|
8533
|
+
const result = await adapter2.listSessions(agentId ? { ...options.filter, agent_id: agentId } : options.filter);
|
|
8534
|
+
return { provider, adapter: adapter2, agentId, agentName, result };
|
|
7619
8535
|
}
|
|
7620
8536
|
async function listSessionSummaries(ctx, options = {}) {
|
|
7621
8537
|
const listed = await listSessionsForProject(ctx, options);
|
|
@@ -7653,48 +8569,48 @@ async function listSessionEvents(ctx, sessionId, options = {}) {
|
|
|
7653
8569
|
);
|
|
7654
8570
|
}
|
|
7655
8571
|
async function uploadFile(ctx, content, filename, options = {}) {
|
|
7656
|
-
const
|
|
7657
|
-
const purpose = options.purpose ?? defaultFileUploadPurpose(
|
|
7658
|
-
const info = await
|
|
8572
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8573
|
+
const purpose = options.purpose ?? defaultFileUploadPurpose(adapter2.name);
|
|
8574
|
+
const info = await adapter2.uploadFileContent(content, filename, {
|
|
7659
8575
|
mimeType: options.mimeType,
|
|
7660
8576
|
purpose
|
|
7661
8577
|
});
|
|
7662
|
-
return enrichProviderFileInfo(
|
|
8578
|
+
return enrichProviderFileInfo(adapter2.name, info);
|
|
7663
8579
|
}
|
|
7664
8580
|
async function deleteFile(ctx, id, options = {}) {
|
|
7665
8581
|
await resolveDirectAdapter(ctx, options.provider).deleteFile(id);
|
|
7666
8582
|
}
|
|
7667
8583
|
async function getFileInfo(ctx, id, options = {}) {
|
|
7668
|
-
const
|
|
7669
|
-
if (!
|
|
7670
|
-
const info = await
|
|
7671
|
-
return enrichProviderFileInfo(
|
|
8584
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8585
|
+
if (!adapter2.getFileInfo) throw new UserError("Provider does not support file metadata lookup");
|
|
8586
|
+
const info = await adapter2.getFileInfo(id);
|
|
8587
|
+
return enrichProviderFileInfo(adapter2.name, info);
|
|
7672
8588
|
}
|
|
7673
8589
|
async function getFileDownloadUrl(ctx, id, options = {}) {
|
|
7674
|
-
const
|
|
7675
|
-
if (!
|
|
7676
|
-
return
|
|
8590
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8591
|
+
if (!adapter2.getFileDownloadUrl) throw new UserError("Provider does not support file downloads");
|
|
8592
|
+
return adapter2.getFileDownloadUrl(id);
|
|
7677
8593
|
}
|
|
7678
8594
|
async function listFiles(ctx, options = {}) {
|
|
7679
|
-
const
|
|
7680
|
-
if (!
|
|
7681
|
-
const all = await
|
|
7682
|
-
return all.map((info) => enrichProviderFileInfo(
|
|
8595
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8596
|
+
if (!adapter2.listFiles) return [];
|
|
8597
|
+
const all = await adapter2.listFiles();
|
|
8598
|
+
return all.map((info) => enrichProviderFileInfo(adapter2.name, info));
|
|
7683
8599
|
}
|
|
7684
8600
|
async function listSkills(ctx, options = {}) {
|
|
7685
|
-
const
|
|
7686
|
-
if (!
|
|
7687
|
-
return
|
|
8601
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8602
|
+
if (!adapter2.listSkills) return [];
|
|
8603
|
+
return adapter2.listSkills(options.source);
|
|
7688
8604
|
}
|
|
7689
8605
|
async function getSkillInfo(ctx, id, options = {}) {
|
|
7690
|
-
const
|
|
7691
|
-
if (!
|
|
7692
|
-
return
|
|
8606
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8607
|
+
if (!adapter2.getSkillInfo) throw new UserError("Provider does not support skill metadata lookup");
|
|
8608
|
+
return adapter2.getSkillInfo(id);
|
|
7693
8609
|
}
|
|
7694
8610
|
async function createSkillFromFileId(ctx, fileId, options = {}) {
|
|
7695
|
-
const
|
|
7696
|
-
if (!
|
|
7697
|
-
return
|
|
8611
|
+
const adapter2 = resolveDirectAdapter(ctx, options.provider);
|
|
8612
|
+
if (!adapter2.createSkillFromFileId) throw new UserError("Provider does not support skill creation");
|
|
8613
|
+
return adapter2.createSkillFromFileId(fileId);
|
|
7698
8614
|
}
|
|
7699
8615
|
async function deleteSkill(ctx, id, options = {}) {
|
|
7700
8616
|
await resolveDirectAdapter(ctx, options.provider).deleteSkill(id);
|
|
@@ -7722,19 +8638,19 @@ function buildAgentNameByRemoteId(ctx, provider) {
|
|
|
7722
8638
|
}
|
|
7723
8639
|
return names;
|
|
7724
8640
|
}
|
|
7725
|
-
async function* streamWithResume(
|
|
7726
|
-
const eventId = await
|
|
7727
|
-
yield*
|
|
8641
|
+
async function* streamWithResume(adapter2, sessionId, message) {
|
|
8642
|
+
const eventId = await adapter2.sendSessionMessage(sessionId, message);
|
|
8643
|
+
yield* adapter2.streamSessionEvents(sessionId, eventId ? { after_id: eventId } : void 0);
|
|
7728
8644
|
}
|
|
7729
|
-
async function* streamConnectBeforeSend(
|
|
7730
|
-
const iterator =
|
|
8645
|
+
async function* streamConnectBeforeSend(adapter2, sessionId, message) {
|
|
8646
|
+
const iterator = adapter2.streamSessionEvents(sessionId)[Symbol.asyncIterator]();
|
|
7731
8647
|
let sent = false;
|
|
7732
8648
|
try {
|
|
7733
8649
|
while (true) {
|
|
7734
8650
|
const next = iterator.next();
|
|
7735
8651
|
if (!sent) {
|
|
7736
8652
|
sent = true;
|
|
7737
|
-
await
|
|
8653
|
+
await adapter2.sendSessionMessage(sessionId, message);
|
|
7738
8654
|
}
|
|
7739
8655
|
const item = await next;
|
|
7740
8656
|
if (item.done) return;
|
|
@@ -7979,11 +8895,11 @@ var StateManager = class _StateManager {
|
|
|
7979
8895
|
listResources() {
|
|
7980
8896
|
return [...this.state.resources];
|
|
7981
8897
|
}
|
|
7982
|
-
findResource(
|
|
8898
|
+
findResource(query2) {
|
|
7983
8899
|
return this.state.resources.find((resource) => {
|
|
7984
|
-
const matchType = resource.address.type ===
|
|
7985
|
-
const matchName = resource.address.name ===
|
|
7986
|
-
const matchProvider = !
|
|
8900
|
+
const matchType = resource.address.type === query2.type;
|
|
8901
|
+
const matchName = resource.address.name === query2.name;
|
|
8902
|
+
const matchProvider = !query2.provider || resource.address.provider === query2.provider;
|
|
7987
8903
|
return matchType && matchName && matchProvider;
|
|
7988
8904
|
});
|
|
7989
8905
|
}
|
|
@@ -8066,11 +8982,11 @@ var InMemoryStateManager = class _InMemoryStateManager {
|
|
|
8066
8982
|
listResources() {
|
|
8067
8983
|
return [...this.state.resources];
|
|
8068
8984
|
}
|
|
8069
|
-
findResource(
|
|
8985
|
+
findResource(query2) {
|
|
8070
8986
|
return this.state.resources.find((resource) => {
|
|
8071
|
-
const matchType = resource.address.type ===
|
|
8072
|
-
const matchName = resource.address.name ===
|
|
8073
|
-
const matchProvider = !
|
|
8987
|
+
const matchType = resource.address.type === query2.type;
|
|
8988
|
+
const matchName = resource.address.name === query2.name;
|
|
8989
|
+
const matchProvider = !query2.provider || resource.address.provider === query2.provider;
|
|
8074
8990
|
return matchType && matchName && matchProvider;
|
|
8075
8991
|
});
|
|
8076
8992
|
}
|
|
@@ -8117,7 +9033,9 @@ var ResourceTypeSchema = z6.enum([
|
|
|
8117
9033
|
"agent",
|
|
8118
9034
|
"template",
|
|
8119
9035
|
"deployment",
|
|
8120
|
-
"file"
|
|
9036
|
+
"file",
|
|
9037
|
+
"identity",
|
|
9038
|
+
"channel"
|
|
8121
9039
|
]);
|
|
8122
9040
|
var ResourceAddressSchema = z6.object({
|
|
8123
9041
|
type: ResourceTypeSchema,
|
|
@@ -8408,13 +9326,17 @@ export {
|
|
|
8408
9326
|
UserError,
|
|
8409
9327
|
applyProviderConfigToEnv,
|
|
8410
9328
|
archiveCloudAgent,
|
|
9329
|
+
archiveMemoryStore,
|
|
8411
9330
|
areRuntimeCredentialsReady,
|
|
9331
|
+
batchCreateMemories,
|
|
8412
9332
|
bootstrapRuntimeCredentials,
|
|
8413
9333
|
bootstrapRuntimeCredentialsSync,
|
|
8414
9334
|
buildAgentDecl,
|
|
8415
9335
|
collectConfigReferences,
|
|
8416
9336
|
createCloudEnvironment,
|
|
8417
9337
|
createCloudVault,
|
|
9338
|
+
createMemory,
|
|
9339
|
+
createMemoryStore,
|
|
8418
9340
|
createProjectRuntime,
|
|
8419
9341
|
createSessionForAgent,
|
|
8420
9342
|
createSkillFromFileId,
|
|
@@ -8422,6 +9344,8 @@ export {
|
|
|
8422
9344
|
deleteCloudEnvironment,
|
|
8423
9345
|
deleteCloudVault,
|
|
8424
9346
|
deleteFile,
|
|
9347
|
+
deleteMemory,
|
|
9348
|
+
deleteMemoryStore,
|
|
8425
9349
|
deleteSession,
|
|
8426
9350
|
deleteSkill,
|
|
8427
9351
|
destroyPlannedProjectResources,
|
|
@@ -8432,6 +9356,10 @@ export {
|
|
|
8432
9356
|
getDeploymentRuntimeProviderForContext,
|
|
8433
9357
|
getFileDownloadUrl,
|
|
8434
9358
|
getFileInfo,
|
|
9359
|
+
getMemory,
|
|
9360
|
+
getMemoryProviderCapabilities,
|
|
9361
|
+
getMemoryStore,
|
|
9362
|
+
getMemoryVersion,
|
|
8435
9363
|
getSession,
|
|
8436
9364
|
getSkillInfo,
|
|
8437
9365
|
importResource,
|
|
@@ -8442,6 +9370,9 @@ export {
|
|
|
8442
9370
|
listCloudVaults,
|
|
8443
9371
|
listDeploymentsForContext,
|
|
8444
9372
|
listFiles,
|
|
9373
|
+
listMemories,
|
|
9374
|
+
listMemoryStores,
|
|
9375
|
+
listMemoryVersions,
|
|
8445
9376
|
listProviderModelsForContext,
|
|
8446
9377
|
listProviderNames,
|
|
8447
9378
|
listSessionEvents,
|
|
@@ -8458,6 +9389,7 @@ export {
|
|
|
8458
9389
|
prependFileHint,
|
|
8459
9390
|
providerConfigPath,
|
|
8460
9391
|
readProjectRuntime,
|
|
9392
|
+
redactMemoryVersion,
|
|
8461
9393
|
resolveActiveProvider,
|
|
8462
9394
|
resolveProjectConfig,
|
|
8463
9395
|
resolveProjectConfigFromObject,
|
|
@@ -8475,6 +9407,8 @@ export {
|
|
|
8475
9407
|
syncProjectResourcesWithStateBackend,
|
|
8476
9408
|
syncProviderResourcesFromContext,
|
|
8477
9409
|
syncProviderResourcesFromEnv,
|
|
9410
|
+
updateMemory,
|
|
9411
|
+
updateMemoryStore,
|
|
8478
9412
|
uploadFile,
|
|
8479
9413
|
validateProjectConfig,
|
|
8480
9414
|
writeProjectRuntime
|