@prismer/sdk 1.8.2 → 1.9.6
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/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/cli.js +397 -5
- package/dist/index.d.mts +646 -2
- package/dist/index.d.ts +646 -2
- package/dist/index.js +404 -5
- package/dist/index.mjs +5105 -50
- package/dist/webhook.d.mts +114 -0
- package/dist/webhook.d.ts +114 -0
- package/dist/webhook.js +200 -0
- package/dist/webhook.mjs +175 -0
- package/package.json +1 -1
- package/dist/chunk-BWZXMXL7.mjs +0 -4762
- package/dist/chunk-VSAVCMMZ.mjs +0 -4761
- package/dist/cli.d.mts +0 -15
- package/dist/cli.d.ts +0 -15
- package/dist/cli.mjs +0 -3838
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
AIPIdentity: () => import_aip_sdk.AIPIdentity,
|
|
34
34
|
AccountClient: () => AccountClient,
|
|
35
|
+
AssetsClient: () => AssetsClient,
|
|
35
36
|
AttachmentQueue: () => AttachmentQueue,
|
|
36
37
|
BindingsClient: () => BindingsClient,
|
|
37
38
|
CommunityHub: () => CommunityHub,
|
|
@@ -58,11 +59,14 @@ __export(index_exports, {
|
|
|
58
59
|
PrismerClient: () => PrismerClient,
|
|
59
60
|
RealtimeSSEClient: () => RealtimeSSEClient,
|
|
60
61
|
RealtimeWSClient: () => RealtimeWSClient,
|
|
62
|
+
RuntimeInstallationsClient: () => RuntimeInstallationsClient,
|
|
61
63
|
SQLiteStorage: () => SQLiteStorage,
|
|
62
64
|
SecurityClient: () => SecurityClient,
|
|
63
65
|
TabCoordinator: () => TabCoordinator,
|
|
64
66
|
TasksClient: () => TasksClient,
|
|
65
67
|
WorkspaceClient: () => WorkspaceClient,
|
|
68
|
+
WorkspaceFilesClient: () => WorkspaceFilesClient,
|
|
69
|
+
WorkspacesClient: () => WorkspacesClient,
|
|
66
70
|
createClient: () => createClient,
|
|
67
71
|
createEnrichedExtractor: () => createEnrichedExtractor,
|
|
68
72
|
decryptContext: () => decryptContext,
|
|
@@ -3330,6 +3334,23 @@ var AccountClient = class {
|
|
|
3330
3334
|
async refreshToken() {
|
|
3331
3335
|
return this._r("POST", "/api/im/token/refresh");
|
|
3332
3336
|
}
|
|
3337
|
+
/**
|
|
3338
|
+
* List agents owned by the current human user (v1.9.3).
|
|
3339
|
+
* Mobile clients call this on launch to populate the Profile/agent runtime card.
|
|
3340
|
+
* Returns `[]` for non-human / api-key-proxy callers without a cloudUserId.
|
|
3341
|
+
*/
|
|
3342
|
+
async listAgents() {
|
|
3343
|
+
return this._r("GET", "/api/im/me/agents");
|
|
3344
|
+
}
|
|
3345
|
+
/**
|
|
3346
|
+
* Self-service account deletion (v1.9.3).
|
|
3347
|
+
* Soft-deletes the IMUser, cascades owned conversations + open tasks,
|
|
3348
|
+
* revokes pc_api_keys, and blacklists the request token.
|
|
3349
|
+
* The caller can only delete themselves — there is no target id parameter.
|
|
3350
|
+
*/
|
|
3351
|
+
async deleteAccount() {
|
|
3352
|
+
return this._r("DELETE", "/api/im/me");
|
|
3353
|
+
}
|
|
3333
3354
|
};
|
|
3334
3355
|
var DirectClient = class {
|
|
3335
3356
|
constructor(_r) {
|
|
@@ -3652,6 +3673,9 @@ var TasksClient = class {
|
|
|
3652
3673
|
/** List tasks with optional filters */
|
|
3653
3674
|
async list(options) {
|
|
3654
3675
|
const query = {};
|
|
3676
|
+
query.view = options?.view ?? "board";
|
|
3677
|
+
if (options?.kind) query.kind = options.kind;
|
|
3678
|
+
if (!options?.kind && query.view === "board") query.kind = "work_item,goal";
|
|
3655
3679
|
if (options?.status) query.status = options.status;
|
|
3656
3680
|
if (options?.capability) query.capability = options.capability;
|
|
3657
3681
|
if (options?.assigneeId) query.assigneeId = options.assigneeId;
|
|
@@ -3659,12 +3683,38 @@ var TasksClient = class {
|
|
|
3659
3683
|
if (options?.scheduleType) query.scheduleType = options.scheduleType;
|
|
3660
3684
|
if (options?.limit != null) query.limit = String(options.limit);
|
|
3661
3685
|
if (options?.cursor) query.cursor = options.cursor;
|
|
3686
|
+
if (options?.workspaceId) query.workspaceId = options.workspaceId;
|
|
3687
|
+
if (options?.conversationId) query.conversationId = options.conversationId;
|
|
3662
3688
|
return this._r("GET", "/api/im/tasks", void 0, query);
|
|
3663
3689
|
}
|
|
3664
3690
|
/** Get task details with logs */
|
|
3665
3691
|
async get(taskId) {
|
|
3666
3692
|
return this._r("GET", `/api/im/tasks/${taskId}`);
|
|
3667
3693
|
}
|
|
3694
|
+
/**
|
|
3695
|
+
* Wave-9 (v1.9.4) — fetch the canonical task result.
|
|
3696
|
+
*
|
|
3697
|
+
* Replaces the legacy "list IMAssets where kind=task-result + sourceTaskId"
|
|
3698
|
+
* pattern. Returns the locked shape defined by `IMTaskResult`; in
|
|
3699
|
+
* particular `assetIds` is always an array (possibly empty) so callers
|
|
3700
|
+
* can iterate without a null-check.
|
|
3701
|
+
*
|
|
3702
|
+
* Access: creator, assignee, or marketplace visibility on the task.
|
|
3703
|
+
*/
|
|
3704
|
+
async getResult(taskId) {
|
|
3705
|
+
return this._r("GET", `/api/im/tasks/${taskId}/result`);
|
|
3706
|
+
}
|
|
3707
|
+
/**
|
|
3708
|
+
* Wave-9 (v1.9.4) — fetch the canonical run result.
|
|
3709
|
+
*
|
|
3710
|
+
* Same shape as `getResult` but reads from IMTaskRun.output instead of
|
|
3711
|
+
* IMTask.result. Use this for chat-mention dispatches whose result lives
|
|
3712
|
+
* on a run row rather than a board task. The `taskId` field of the
|
|
3713
|
+
* returned object is the run.id.
|
|
3714
|
+
*/
|
|
3715
|
+
async getRunResult(runId) {
|
|
3716
|
+
return this._r("GET", `/api/im/runs/${runId}/result`);
|
|
3717
|
+
}
|
|
3668
3718
|
/** Update a task */
|
|
3669
3719
|
async update(taskId, options) {
|
|
3670
3720
|
return this._r("PATCH", `/api/im/tasks/${taskId}`, options);
|
|
@@ -3743,6 +3793,18 @@ var MemoryClient = class {
|
|
|
3743
3793
|
async getKnowledgeLinks() {
|
|
3744
3794
|
return this._r("GET", "/api/im/memory/links");
|
|
3745
3795
|
}
|
|
3796
|
+
/**
|
|
3797
|
+
* Get a CC-style always-load digest of all memory files (v1.9.3).
|
|
3798
|
+
* The digest is a Markdown bundle suitable for prepending to LLM context.
|
|
3799
|
+
* Server clamps `maxLines` to 10–1000 and `maxBytes` to 500–30000.
|
|
3800
|
+
*/
|
|
3801
|
+
async digest(options) {
|
|
3802
|
+
const query = {};
|
|
3803
|
+
if (options?.scope) query.scope = options.scope;
|
|
3804
|
+
if (options?.maxLines != null) query.maxLines = String(options.maxLines);
|
|
3805
|
+
if (options?.maxBytes != null) query.maxBytes = String(options.maxBytes);
|
|
3806
|
+
return this._r("GET", "/api/im/memory/digest", void 0, query);
|
|
3807
|
+
}
|
|
3746
3808
|
};
|
|
3747
3809
|
var KnowledgeLinkClient = class {
|
|
3748
3810
|
constructor(_r) {
|
|
@@ -4280,6 +4342,226 @@ var EvolutionClient = class {
|
|
|
4280
4342
|
function safeSlug(input) {
|
|
4281
4343
|
return input.replace(/[\/\\]/g, "").replace(/\.\./g, "").replace(/\0/g, "");
|
|
4282
4344
|
}
|
|
4345
|
+
var WorkspacesClient = class {
|
|
4346
|
+
constructor(_r) {
|
|
4347
|
+
this._r = _r;
|
|
4348
|
+
}
|
|
4349
|
+
/** List active workspaces owned by the caller. */
|
|
4350
|
+
async list() {
|
|
4351
|
+
return this._r("GET", "/api/im/workspaces");
|
|
4352
|
+
}
|
|
4353
|
+
/**
|
|
4354
|
+
* Create a workspace. In 1.9.x most callers don't need this — registration
|
|
4355
|
+
* auto-creates a default workspace. The first workspace per owner is
|
|
4356
|
+
* always default; subsequent ones must omit `isDefault` (server returns 409).
|
|
4357
|
+
*/
|
|
4358
|
+
async create(options) {
|
|
4359
|
+
return this._r("POST", "/api/im/workspaces", options);
|
|
4360
|
+
}
|
|
4361
|
+
/** Daemon delta-sync workspaces since an ISO timestamp. */
|
|
4362
|
+
async sync(since) {
|
|
4363
|
+
const query = {};
|
|
4364
|
+
if (since) query.since = since;
|
|
4365
|
+
return this._r("GET", "/api/im/workspaces/sync", void 0, query);
|
|
4366
|
+
}
|
|
4367
|
+
/** Get a single workspace by id (caller must own). */
|
|
4368
|
+
async get(workspaceId) {
|
|
4369
|
+
return this._r("GET", `/api/im/workspaces/${workspaceId}`);
|
|
4370
|
+
}
|
|
4371
|
+
/** Update workspace name and/or metadata. `slug` and `isDefault` are immutable in 1.9.x. */
|
|
4372
|
+
async update(workspaceId, options) {
|
|
4373
|
+
return this._r("PATCH", `/api/im/workspaces/${workspaceId}`, options);
|
|
4374
|
+
}
|
|
4375
|
+
/**
|
|
4376
|
+
* Archive (delete) a workspace. Server returns 405 in 1.9.x — workspace
|
|
4377
|
+
* deletion equals account close, which goes through `account.deleteAccount()`.
|
|
4378
|
+
* Provided for forward-compat; will become real in 1.10+.
|
|
4379
|
+
*/
|
|
4380
|
+
async archive(workspaceId) {
|
|
4381
|
+
return this._r("DELETE", `/api/im/workspaces/${workspaceId}`);
|
|
4382
|
+
}
|
|
4383
|
+
};
|
|
4384
|
+
var WorkspaceFilesClient = class {
|
|
4385
|
+
constructor(_r) {
|
|
4386
|
+
this._r = _r;
|
|
4387
|
+
}
|
|
4388
|
+
/** List the active file tree for a workspace, or look up a single file by path. */
|
|
4389
|
+
async list(workspaceId, options) {
|
|
4390
|
+
const query = {};
|
|
4391
|
+
if (options?.path) query.path = options.path;
|
|
4392
|
+
return this._r("GET", `/api/im/workspaces/${workspaceId}/files`, void 0, query);
|
|
4393
|
+
}
|
|
4394
|
+
/**
|
|
4395
|
+
* Bind `path → assetId`. Idempotent if `(path, assetId)` matches the existing
|
|
4396
|
+
* active binding. Asset must already exist in the same workspace.
|
|
4397
|
+
*/
|
|
4398
|
+
async create(workspaceId, options) {
|
|
4399
|
+
return this._r("POST", `/api/im/workspaces/${workspaceId}/files`, options);
|
|
4400
|
+
}
|
|
4401
|
+
/** Soft-delete the active binding at `path`. */
|
|
4402
|
+
async delete(workspaceId, path) {
|
|
4403
|
+
return this._r("DELETE", `/api/im/workspaces/${workspaceId}/files`, void 0, { path });
|
|
4404
|
+
}
|
|
4405
|
+
/** Daemon delta-sync workspace files since an ISO timestamp. */
|
|
4406
|
+
async sync(workspaceId, since) {
|
|
4407
|
+
const query = {};
|
|
4408
|
+
if (since) query.since = since;
|
|
4409
|
+
return this._r("GET", `/api/im/workspaces/${workspaceId}/files/sync`, void 0, query);
|
|
4410
|
+
}
|
|
4411
|
+
/** Get the version chain for a file (walks `parentVersionId`). */
|
|
4412
|
+
async history(workspaceId, fileId) {
|
|
4413
|
+
return this._r("GET", `/api/im/workspaces/${workspaceId}/files/${fileId}/history`);
|
|
4414
|
+
}
|
|
4415
|
+
};
|
|
4416
|
+
var AssetsClient = class {
|
|
4417
|
+
constructor(_r, _baseUrl, _fetchFn, _getAuthHeaders) {
|
|
4418
|
+
this._r = _r;
|
|
4419
|
+
this._baseUrl = _baseUrl;
|
|
4420
|
+
this._fetchFn = _fetchFn;
|
|
4421
|
+
this._getAuthHeaders = _getAuthHeaders;
|
|
4422
|
+
}
|
|
4423
|
+
/** List assets in a workspace (filterable by task and kind). */
|
|
4424
|
+
async list(options) {
|
|
4425
|
+
const query = {};
|
|
4426
|
+
if (options.workspaceId) query.workspaceId = options.workspaceId;
|
|
4427
|
+
if (options.taskId) query.taskId = options.taskId;
|
|
4428
|
+
if (options.kind) query.kind = options.kind;
|
|
4429
|
+
if (options.limit != null) query.limit = String(options.limit);
|
|
4430
|
+
return this._r("GET", "/api/im/assets", void 0, query);
|
|
4431
|
+
}
|
|
4432
|
+
/**
|
|
4433
|
+
* Look up an asset by content hash within a workspace. Useful for dedupe
|
|
4434
|
+
* checks ("do I already have this file?") before uploading.
|
|
4435
|
+
*/
|
|
4436
|
+
async byHash(hash, workspaceId) {
|
|
4437
|
+
return this._r("GET", `/api/im/assets/by-hash/${encodeURIComponent(hash)}`, void 0, { wsId: workspaceId });
|
|
4438
|
+
}
|
|
4439
|
+
/**
|
|
4440
|
+
* Get full asset metadata + a freshly-signed URL (5 min TTL, S3 backend only).
|
|
4441
|
+
* For `kind === 'photo-memory-segment'` this also includes a `photoRefs`
|
|
4442
|
+
* reverse-lookup of memory references.
|
|
4443
|
+
*/
|
|
4444
|
+
async detail(assetId) {
|
|
4445
|
+
return this._r("GET", `/api/im/assets/${assetId}/detail`);
|
|
4446
|
+
}
|
|
4447
|
+
/**
|
|
4448
|
+
* Soft-delete an asset (the underlying S3 object is retained). Idempotent.
|
|
4449
|
+
*/
|
|
4450
|
+
async delete(assetId) {
|
|
4451
|
+
return this._r("DELETE", `/api/im/assets/${assetId}`);
|
|
4452
|
+
}
|
|
4453
|
+
/**
|
|
4454
|
+
* Build a download URL for an asset. Filesystem backend streams bytes
|
|
4455
|
+
* directly; S3 backend returns a 302 to a 5-minute presigned URL.
|
|
4456
|
+
* Use `download()` for a one-shot fetch returning bytes.
|
|
4457
|
+
*/
|
|
4458
|
+
url(assetId) {
|
|
4459
|
+
return `${this._baseUrl}/api/im/assets/${assetId}`;
|
|
4460
|
+
}
|
|
4461
|
+
/**
|
|
4462
|
+
* Download an asset's bytes. Authentication is forwarded; for S3 backend
|
|
4463
|
+
* the server returns a 302 which `fetch` follows automatically.
|
|
4464
|
+
*/
|
|
4465
|
+
async download(assetId) {
|
|
4466
|
+
const resp = await this._fetchFn(this.url(assetId), {
|
|
4467
|
+
method: "GET",
|
|
4468
|
+
headers: this._getAuthHeaders()
|
|
4469
|
+
});
|
|
4470
|
+
if (!resp.ok) {
|
|
4471
|
+
throw new Error(`Asset download failed (${resp.status}): ${await resp.text()}`);
|
|
4472
|
+
}
|
|
4473
|
+
const ab = await resp.arrayBuffer();
|
|
4474
|
+
const sizeHeader = resp.headers.get("content-length");
|
|
4475
|
+
return {
|
|
4476
|
+
bytes: new Uint8Array(ab),
|
|
4477
|
+
mime: resp.headers.get("content-type"),
|
|
4478
|
+
sizeBytes: sizeHeader ? Number(sizeHeader) : null
|
|
4479
|
+
};
|
|
4480
|
+
}
|
|
4481
|
+
/**
|
|
4482
|
+
* Upload bytes as an asset (multipart). 100 MB hard cap; >50 MB returns
|
|
4483
|
+
* 413 with `USE_PRESIGNED` — use S3 presign flow for those (not yet wrapped).
|
|
4484
|
+
*/
|
|
4485
|
+
async upload(input, options) {
|
|
4486
|
+
let bytes;
|
|
4487
|
+
let fileName;
|
|
4488
|
+
if (typeof input === "string") {
|
|
4489
|
+
const fs = await import("fs");
|
|
4490
|
+
const path = await import("path");
|
|
4491
|
+
const buf = await fs.promises.readFile(input);
|
|
4492
|
+
bytes = new Uint8Array(buf);
|
|
4493
|
+
fileName = options.fileName || path.basename(input);
|
|
4494
|
+
} else if (typeof Blob !== "undefined" && input instanceof Blob) {
|
|
4495
|
+
const ab2 = await input.arrayBuffer();
|
|
4496
|
+
bytes = new Uint8Array(ab2);
|
|
4497
|
+
fileName = options.fileName || (input instanceof File ? input.name : "");
|
|
4498
|
+
if (!fileName) throw new Error("fileName is required when uploading Blob without name");
|
|
4499
|
+
} else if (input instanceof Uint8Array) {
|
|
4500
|
+
bytes = input;
|
|
4501
|
+
fileName = options.fileName || "";
|
|
4502
|
+
if (!fileName) throw new Error("fileName is required when uploading Buffer or Uint8Array");
|
|
4503
|
+
} else {
|
|
4504
|
+
throw new Error("Unsupported input type");
|
|
4505
|
+
}
|
|
4506
|
+
const mimeType = options.mimeType || guessMimeType(fileName);
|
|
4507
|
+
const sizeBytes = bytes.byteLength;
|
|
4508
|
+
if (sizeBytes > 100 * 1024 * 1024) {
|
|
4509
|
+
throw new Error("Asset exceeds 100 MB cap");
|
|
4510
|
+
}
|
|
4511
|
+
const formData = new FormData();
|
|
4512
|
+
const ab = new ArrayBuffer(bytes.byteLength);
|
|
4513
|
+
new Uint8Array(ab).set(bytes);
|
|
4514
|
+
formData.append("file", new Blob([ab], { type: mimeType }), fileName);
|
|
4515
|
+
formData.append("workspaceId", options.workspaceId);
|
|
4516
|
+
if (options.kind) formData.append("kind", options.kind);
|
|
4517
|
+
if (options.sourceAgentImUserId) formData.append("sourceAgentImUserId", options.sourceAgentImUserId);
|
|
4518
|
+
if (options.sourceTaskId) formData.append("sourceTaskId", options.sourceTaskId);
|
|
4519
|
+
if (options.metadata) formData.append("metadata", JSON.stringify(options.metadata));
|
|
4520
|
+
const resp = await this._fetchFn(`${this._baseUrl}/api/im/assets`, {
|
|
4521
|
+
method: "POST",
|
|
4522
|
+
body: formData,
|
|
4523
|
+
headers: this._getAuthHeaders()
|
|
4524
|
+
});
|
|
4525
|
+
options.onProgress?.(sizeBytes, sizeBytes);
|
|
4526
|
+
const data = await resp.json().catch(() => ({}));
|
|
4527
|
+
if (!resp.ok) {
|
|
4528
|
+
return {
|
|
4529
|
+
ok: false,
|
|
4530
|
+
error: data?.error || { code: "HTTP_ERROR", message: `Upload failed (${resp.status})` }
|
|
4531
|
+
};
|
|
4532
|
+
}
|
|
4533
|
+
return data;
|
|
4534
|
+
}
|
|
4535
|
+
};
|
|
4536
|
+
var RuntimeInstallationsClient = class {
|
|
4537
|
+
constructor(_r) {
|
|
4538
|
+
this._r = _r;
|
|
4539
|
+
}
|
|
4540
|
+
/** List runtime installations in a workspace. */
|
|
4541
|
+
async list(workspaceId, options) {
|
|
4542
|
+
const query = { workspaceId };
|
|
4543
|
+
if (options?.limit != null) query.limit = String(options.limit);
|
|
4544
|
+
return this._r("GET", "/api/workspace/runtime-installations", void 0, query);
|
|
4545
|
+
}
|
|
4546
|
+
/**
|
|
4547
|
+
* Create a new runtime installation. Mints a durable runtime API key,
|
|
4548
|
+
* RPCs the sandbox controller, and persists an `IMContainer` row.
|
|
4549
|
+
* The daemon receives `PRISMER_API_KEY`, `PRISMER_DAEMON_ID`,
|
|
4550
|
+
* `PRISMER_BASE_URL`, `PRISMER_WORKSPACE_ID`, and
|
|
4551
|
+
* `PRISMER_RUNTIME_KIND=workspace-daemon` env vars.
|
|
4552
|
+
*/
|
|
4553
|
+
async create(options) {
|
|
4554
|
+
return this._r("POST", "/api/workspace/runtime-installations", options);
|
|
4555
|
+
}
|
|
4556
|
+
/**
|
|
4557
|
+
* Install an agent onto a runtime daemon. Resolves or creates the agent
|
|
4558
|
+
* profile, calls the controller's `installAgent` RPC, and stamps
|
|
4559
|
+
* `IMAgentCard.metadata.daemonId` + `runtimeInstallationId`.
|
|
4560
|
+
*/
|
|
4561
|
+
async installAgent(runtimeInstallationId, options) {
|
|
4562
|
+
return this._r("POST", `/api/workspace/runtime-installations/${runtimeInstallationId}/agents`, options);
|
|
4563
|
+
}
|
|
4564
|
+
};
|
|
4283
4565
|
function guessMimeType(fileName) {
|
|
4284
4566
|
const ext = fileName.split(".").pop()?.toLowerCase() || "";
|
|
4285
4567
|
const map = {
|
|
@@ -4486,8 +4768,9 @@ var FilesClient = class {
|
|
|
4486
4768
|
}
|
|
4487
4769
|
};
|
|
4488
4770
|
var IMRealtimeClient = class {
|
|
4489
|
-
constructor(_wsBase) {
|
|
4771
|
+
constructor(_wsBase, _fetchFn = fetch) {
|
|
4490
4772
|
this._wsBase = _wsBase;
|
|
4773
|
+
this._fetchFn = _fetchFn;
|
|
4491
4774
|
}
|
|
4492
4775
|
/** Get the WebSocket URL */
|
|
4493
4776
|
wsUrl(token) {
|
|
@@ -4498,6 +4781,14 @@ var IMRealtimeClient = class {
|
|
|
4498
4781
|
sseUrl(token) {
|
|
4499
4782
|
return token ? `${this._wsBase}/sse?token=${token}` : `${this._wsBase}/sse`;
|
|
4500
4783
|
}
|
|
4784
|
+
/**
|
|
4785
|
+
* Get the URL for the v1.8.2 task SSE stream
|
|
4786
|
+
* (`GET /api/im/tasks/events?token=...`).
|
|
4787
|
+
* Supports `Last-Event-ID` for replay.
|
|
4788
|
+
*/
|
|
4789
|
+
taskEventsUrl(token) {
|
|
4790
|
+
return `${this._wsBase}/api/im/tasks/events?token=${encodeURIComponent(token)}`;
|
|
4791
|
+
}
|
|
4501
4792
|
/** Create a WebSocket client. Call .connect() to establish connection. */
|
|
4502
4793
|
connectWS(config) {
|
|
4503
4794
|
return new RealtimeWSClient(this._wsBase, config);
|
|
@@ -4506,6 +4797,101 @@ var IMRealtimeClient = class {
|
|
|
4506
4797
|
connectSSE(config) {
|
|
4507
4798
|
return new RealtimeSSEClient(this._wsBase, config);
|
|
4508
4799
|
}
|
|
4800
|
+
/**
|
|
4801
|
+
* Subscribe to the task events SSE stream (v1.8.2/v1.9.3).
|
|
4802
|
+
*
|
|
4803
|
+
* Resolves with a `disconnect()` function for cleanup. Emits envelopes of
|
|
4804
|
+
* shape `{ id?, type, payload }` for each parsed `event:` block. Ignores
|
|
4805
|
+
* comment lines (`:` heartbeats).
|
|
4806
|
+
*
|
|
4807
|
+
* @example
|
|
4808
|
+
* const sub = await client.im.realtime.subscribeTaskEvents(apiKey, (evt) => {
|
|
4809
|
+
* if (evt.type === 'task.completed') console.log('done:', evt.payload);
|
|
4810
|
+
* });
|
|
4811
|
+
* // ... later:
|
|
4812
|
+
* sub.disconnect();
|
|
4813
|
+
*/
|
|
4814
|
+
async subscribeTaskEvents(token, onEvent, options) {
|
|
4815
|
+
const controller = new AbortController();
|
|
4816
|
+
const onAbort = () => controller.abort();
|
|
4817
|
+
options?.signal?.addEventListener("abort", onAbort);
|
|
4818
|
+
const headers = { Accept: "text/event-stream" };
|
|
4819
|
+
if (options?.lastEventId) headers["Last-Event-ID"] = options.lastEventId;
|
|
4820
|
+
const resp = await this._fetchFn(this.taskEventsUrl(token), {
|
|
4821
|
+
method: "GET",
|
|
4822
|
+
headers,
|
|
4823
|
+
signal: controller.signal
|
|
4824
|
+
});
|
|
4825
|
+
if (!resp.ok || !resp.body) {
|
|
4826
|
+
options?.signal?.removeEventListener("abort", onAbort);
|
|
4827
|
+
throw new Error(`Task events SSE failed: ${resp.status}`);
|
|
4828
|
+
}
|
|
4829
|
+
void (async () => {
|
|
4830
|
+
const reader = resp.body.getReader();
|
|
4831
|
+
const decoder = new TextDecoder();
|
|
4832
|
+
let buffer = "";
|
|
4833
|
+
let pending = { data: [] };
|
|
4834
|
+
const flush = () => {
|
|
4835
|
+
if (!pending.type && pending.data.length === 0) return;
|
|
4836
|
+
const dataStr = pending.data.join("\n");
|
|
4837
|
+
let payload = {};
|
|
4838
|
+
if (dataStr) {
|
|
4839
|
+
try {
|
|
4840
|
+
payload = JSON.parse(dataStr);
|
|
4841
|
+
} catch {
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
try {
|
|
4845
|
+
onEvent({
|
|
4846
|
+
id: pending.id,
|
|
4847
|
+
type: pending.type ?? "task.updated",
|
|
4848
|
+
payload
|
|
4849
|
+
});
|
|
4850
|
+
} catch {
|
|
4851
|
+
}
|
|
4852
|
+
pending = { data: [] };
|
|
4853
|
+
};
|
|
4854
|
+
try {
|
|
4855
|
+
while (true) {
|
|
4856
|
+
const { done, value } = await reader.read();
|
|
4857
|
+
if (done) break;
|
|
4858
|
+
buffer += decoder.decode(value, { stream: true });
|
|
4859
|
+
let lineEnd;
|
|
4860
|
+
while ((lineEnd = buffer.indexOf("\n")) !== -1) {
|
|
4861
|
+
const line = buffer.slice(0, lineEnd).replace(/\r$/, "");
|
|
4862
|
+
buffer = buffer.slice(lineEnd + 1);
|
|
4863
|
+
if (line === "") {
|
|
4864
|
+
flush();
|
|
4865
|
+
continue;
|
|
4866
|
+
}
|
|
4867
|
+
if (line.startsWith(":")) continue;
|
|
4868
|
+
const colon = line.indexOf(":");
|
|
4869
|
+
const field = colon === -1 ? line : line.slice(0, colon);
|
|
4870
|
+
const valueStr = colon === -1 ? "" : line.slice(colon + 1).replace(/^ /, "");
|
|
4871
|
+
if (field === "event") pending.type = valueStr;
|
|
4872
|
+
else if (field === "id") pending.id = valueStr;
|
|
4873
|
+
else if (field === "data") pending.data.push(valueStr);
|
|
4874
|
+
}
|
|
4875
|
+
}
|
|
4876
|
+
flush();
|
|
4877
|
+
} catch {
|
|
4878
|
+
} finally {
|
|
4879
|
+
try {
|
|
4880
|
+
reader.releaseLock();
|
|
4881
|
+
} catch {
|
|
4882
|
+
}
|
|
4883
|
+
options?.signal?.removeEventListener("abort", onAbort);
|
|
4884
|
+
}
|
|
4885
|
+
})();
|
|
4886
|
+
return {
|
|
4887
|
+
disconnect: () => {
|
|
4888
|
+
try {
|
|
4889
|
+
controller.abort();
|
|
4890
|
+
} catch {
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
};
|
|
4894
|
+
}
|
|
4509
4895
|
};
|
|
4510
4896
|
var IMClient = class {
|
|
4511
4897
|
constructor(request, wsBase, fetchFn, getAuthHeaders, offlineManager, communityHubConfig) {
|
|
@@ -4518,6 +4904,10 @@ var IMClient = class {
|
|
|
4518
4904
|
this.bindings = new BindingsClient(request);
|
|
4519
4905
|
this.credits = new CreditsClient(request);
|
|
4520
4906
|
this.workspace = new WorkspaceClient(request);
|
|
4907
|
+
this.workspaces = new WorkspacesClient(request);
|
|
4908
|
+
this.workspaceFiles = new WorkspaceFilesClient(request);
|
|
4909
|
+
this.assets = new AssetsClient(request, wsBase, fetchFn, getAuthHeaders);
|
|
4910
|
+
this.runtimeInstallations = new RuntimeInstallationsClient(request);
|
|
4521
4911
|
this.tasks = new TasksClient(request);
|
|
4522
4912
|
this.memory = new MemoryClient(request);
|
|
4523
4913
|
this.knowledge = new KnowledgeLinkClient(request);
|
|
@@ -4526,7 +4916,7 @@ var IMClient = class {
|
|
|
4526
4916
|
this.evolution = new EvolutionClient(request);
|
|
4527
4917
|
this.community = new CommunityHub(request, communityHubConfig ?? void 0);
|
|
4528
4918
|
this.files = new FilesClient(request, wsBase, fetchFn, getAuthHeaders);
|
|
4529
|
-
this.realtime = new IMRealtimeClient(wsBase);
|
|
4919
|
+
this.realtime = new IMRealtimeClient(wsBase, fetchFn);
|
|
4530
4920
|
this.offline = offlineManager ?? null;
|
|
4531
4921
|
}
|
|
4532
4922
|
/** IM health check */
|
|
@@ -4751,6 +5141,14 @@ var PrismerClient = class {
|
|
|
4751
5141
|
return this._request("GET", `/api/parse/result/${taskId}`);
|
|
4752
5142
|
}
|
|
4753
5143
|
// --------------------------------------------------------------------------
|
|
5144
|
+
// Models API (LLM proxy model listing)
|
|
5145
|
+
// --------------------------------------------------------------------------
|
|
5146
|
+
/** List LLM models exposed by the cloud LLM proxy (OpenAI format). */
|
|
5147
|
+
async listModels() {
|
|
5148
|
+
const res = await this._request("GET", "/api/v1/models");
|
|
5149
|
+
return res.data ?? [];
|
|
5150
|
+
}
|
|
5151
|
+
// --------------------------------------------------------------------------
|
|
4754
5152
|
// Convenience
|
|
4755
5153
|
// --------------------------------------------------------------------------
|
|
4756
5154
|
/** Search for content (convenience wrapper around load with query mode) */
|
|
@@ -4771,6 +5169,7 @@ function createClient(config) {
|
|
|
4771
5169
|
0 && (module.exports = {
|
|
4772
5170
|
AIPIdentity,
|
|
4773
5171
|
AccountClient,
|
|
5172
|
+
AssetsClient,
|
|
4774
5173
|
AttachmentQueue,
|
|
4775
5174
|
BindingsClient,
|
|
4776
5175
|
CommunityHub,
|
|
@@ -4797,11 +5196,14 @@ function createClient(config) {
|
|
|
4797
5196
|
PrismerClient,
|
|
4798
5197
|
RealtimeSSEClient,
|
|
4799
5198
|
RealtimeWSClient,
|
|
5199
|
+
RuntimeInstallationsClient,
|
|
4800
5200
|
SQLiteStorage,
|
|
4801
5201
|
SecurityClient,
|
|
4802
5202
|
TabCoordinator,
|
|
4803
5203
|
TasksClient,
|
|
4804
5204
|
WorkspaceClient,
|
|
5205
|
+
WorkspaceFilesClient,
|
|
5206
|
+
WorkspacesClient,
|
|
4805
5207
|
createClient,
|
|
4806
5208
|
createEnrichedExtractor,
|
|
4807
5209
|
decryptContext,
|
|
@@ -4815,6 +5217,3 @@ function createClient(config) {
|
|
|
4815
5217
|
guessMimeType,
|
|
4816
5218
|
safeSlug
|
|
4817
5219
|
});
|
|
4818
|
-
ype,
|
|
4819
|
-
safeSlug
|
|
4820
|
-
});
|