@capybara-hq/kernel 0.1.0-rc.135 → 0.1.0-rc.136
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/admin/admin.module.js +3 -0
- package/dist/admin/health.service.d.ts +2 -2
- package/dist/admin/health.service.js +6 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/conversations/access.d.ts +15 -7
- package/dist/conversations/access.js +59 -10
- package/dist/conversations/conversation-agent.d.ts +18 -0
- package/dist/conversations/conversation-agent.js +23 -0
- package/dist/conversations/conversation-ref.d.ts +3 -2
- package/dist/conversations/conversation-ref.js +6 -1
- package/dist/conversations/conversations.controller.d.ts +28 -5
- package/dist/conversations/conversations.controller.js +99 -10
- package/dist/conversations/conversations.module.js +10 -0
- package/dist/conversations/conversations.schemas.d.ts +6 -0
- package/dist/conversations/conversations.schemas.js +15 -0
- package/dist/conversations/conversations.service.d.ts +125 -21
- package/dist/conversations/conversations.service.js +260 -90
- package/dist/conversations/event-log.d.ts +9 -1
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +57 -0
- package/dist/conversations/events.js +73 -1
- package/dist/conversations/external/external-calls.d.ts +75 -0
- package/dist/conversations/external/external-calls.js +91 -0
- package/dist/conversations/external/external-calls.processor.d.ts +45 -0
- package/dist/conversations/external/external-calls.processor.js +144 -0
- package/dist/conversations/external/external-conversations.service.d.ts +266 -0
- package/dist/conversations/external/external-conversations.service.js +1138 -0
- package/dist/conversations/external/external.schemas.d.ts +63 -0
- package/dist/conversations/external/external.schemas.js +52 -0
- package/dist/conversations/external/token.d.ts +6 -0
- package/dist/conversations/external/token.js +6 -0
- package/dist/conversations/permission-profile-store.d.ts +4 -1
- package/dist/conversations/permission-profiles.controller.d.ts +33 -9
- package/dist/conversations/permission-profiles.controller.js +86 -6
- package/dist/conversations/prompt-suggestions.js +2 -1
- package/dist/conversations/queue.js +2 -1
- package/dist/conversations/titles.js +4 -3
- package/dist/ctx/create-ctx.d.ts +7 -0
- package/dist/ctx/create-ctx.js +45 -2
- package/dist/db/kernel-schema.d.ts +31 -4
- package/dist/device-access/host-services.js +3 -2
- package/dist/device-access/person-handles.d.ts +16 -7
- package/dist/device-access/person-handles.js +14 -9
- package/dist/devices/conversation-devices.d.ts +5 -0
- package/dist/devices/conversation-devices.js +16 -0
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/errors.d.ts +34 -0
- package/dist/errors.js +34 -0
- package/dist/evals/snapshot.js +3 -1
- package/dist/evals/trajectory.service.d.ts +2 -2
- package/dist/evals/trajectory.service.js +11 -7
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +7 -0
- package/dist/extensions/host.js +11 -0
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/extensions/point-defaults.d.ts +13 -21
- package/dist/extensions/point-defaults.js +32 -72
- package/dist/extensions/point-serving.d.ts +56 -0
- package/dist/extensions/point-serving.js +120 -0
- package/dist/inbox/inbox-items.service.d.ts +11 -0
- package/dist/inbox/inbox-items.service.js +39 -0
- package/dist/infra/outbox/registry.d.ts +70 -0
- package/dist/infra/outbox/registry.js +44 -0
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -0
- package/dist/kernel.module.js +4 -0
- package/dist/platform/exclusions.js +10 -0
- package/dist/platform/ops/conversations.ops.d.ts +8 -1
- package/dist/platform/ops/conversations.ops.js +52 -14
- package/dist/plugin-reads/plugin-reads.service.js +4 -1
- package/dist/push/recipients.js +5 -2
- package/dist/retention/worker.js +2 -1
- package/dist/roles/worker-role.d.ts +3 -1
- package/dist/roles/worker-role.js +8 -2
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/context/build.js +8 -0
- package/dist/runtime/context/compaction.js +7 -0
- package/dist/runtime/idle-arm.js +3 -1
- package/dist/runtime/idle-compaction.js +2 -1
- package/dist/runtime/run-finish.js +2 -1
- package/dist/runtime/run-jobs.js +2 -1
- package/dist/runtime/run-queue.js +4 -2
- package/dist/runtime/run-worker.js +5 -2
- package/dist/runtime/stream.js +10 -0
- package/dist/runtime/usage-report.js +2 -1
- package/dist/runtime/waits.js +2 -1
- package/dist/tools/approvals.service.js +6 -2
- package/dist/tools/builtins/skill-load.js +3 -2
- package/dist/tools/tool-watch.service.js +3 -1
- package/package.json +3 -3
- package/src/migrations/0227_external_conversations.sql +33 -0
|
@@ -8,7 +8,9 @@ import { Module } from "@nestjs/common";
|
|
|
8
8
|
import { AgentLookupModule } from "../agents/agent-lookup.js";
|
|
9
9
|
import { BackgroundModule } from "../background/background.module.js";
|
|
10
10
|
import { DevicesModule } from "../devices/devices.module.js";
|
|
11
|
+
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
11
12
|
import { LibraryReadModule } from "../files/library-read.module.js";
|
|
13
|
+
import { InboxItemsModule } from "../inbox/inbox-items.service.js";
|
|
12
14
|
import { ProvidersModule } from "../runtime/providers.js";
|
|
13
15
|
import { RuntimeModule } from "../runtime/runtime.module.js";
|
|
14
16
|
import { OperationAuthorityModule } from "../sandbox/operation-authority.module.js";
|
|
@@ -23,6 +25,7 @@ import { AttachmentsModule } from "./attachments.module.js";
|
|
|
23
25
|
import { ConversationsService } from "./conversations.service.js";
|
|
24
26
|
import { ConversationDeviceStatus } from "./device-status.js";
|
|
25
27
|
import { EventLogModule } from "./event-log.js";
|
|
28
|
+
import { ExternalConversationsModule } from "./external/external-conversations.service.js";
|
|
26
29
|
import { ConversationFiles } from "./files.js";
|
|
27
30
|
import { ConversationLeakCheckModule } from "./leak-check.js";
|
|
28
31
|
import { ConversationOutputs } from "./outputs-read.js";
|
|
@@ -62,6 +65,12 @@ ConversationsModule = __decorate([
|
|
|
62
65
|
BackgroundModule,
|
|
63
66
|
// the leak check of a person's card values (its own module: the tools module uses it too)
|
|
64
67
|
ConversationLeakCheckModule,
|
|
68
|
+
// external conversations (their deletion is the conversation's; their routes share ours)
|
|
69
|
+
ExternalConversationsModule,
|
|
70
|
+
// a deleted external conversation's open request items leave the owner's inbox
|
|
71
|
+
InboxItemsModule,
|
|
72
|
+
// whether an external conversation's target serves the org
|
|
73
|
+
ExtensionsModule,
|
|
65
74
|
],
|
|
66
75
|
providers: [
|
|
67
76
|
PermissionProfilesService,
|
|
@@ -86,6 +95,7 @@ ConversationsModule = __decorate([
|
|
|
86
95
|
ConversationFiles,
|
|
87
96
|
ConversationDeviceStatus,
|
|
88
97
|
ConversationLeakCheckModule,
|
|
98
|
+
ExternalConversationsModule,
|
|
89
99
|
],
|
|
90
100
|
})
|
|
91
101
|
], ConversationsModule);
|
|
@@ -32,11 +32,17 @@ export declare const ListQuery: z.ZodObject<{
|
|
|
32
32
|
after: z.ZodOptional<z.ZodString>;
|
|
33
33
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
34
34
|
agentId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
target: z.ZodOptional<z.ZodString>;
|
|
35
36
|
withTotal: z.ZodOptional<z.ZodEnum<{
|
|
36
37
|
false: "false";
|
|
37
38
|
true: "true";
|
|
38
39
|
}>>;
|
|
39
40
|
}, z.core.$strip>;
|
|
41
|
+
/** A list query's `target` (`<extension>/<targetKey>`, already checked) as its parts. */
|
|
42
|
+
export declare function targetRefOf(target: string): {
|
|
43
|
+
extension: string;
|
|
44
|
+
targetKey: string;
|
|
45
|
+
};
|
|
40
46
|
export declare const EventsQuery: z.ZodObject<{
|
|
41
47
|
after: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
42
48
|
before: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"end">, z.ZodCoercedNumber<unknown>]>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { CONTROL_OR_HIDDEN_RE } from "../text.js";
|
|
3
3
|
import { CONVERSATION_TITLE_MAX_CHARS } from "./conversations.service.js";
|
|
4
|
+
import { TARGET_KEY_RE } from "./external/external.schemas.js";
|
|
4
5
|
import { FILES_PAGE_MAX } from "./files.js";
|
|
5
6
|
/**
|
|
6
7
|
* The download routes' answer form: `as=url` answers `{ url }` (the presigned location the 302
|
|
@@ -20,6 +21,15 @@ export const ListQuery = z.object({
|
|
|
20
21
|
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
21
22
|
/** Only this agent's conversations (the sidebar's per-group "More"). */
|
|
22
23
|
agentId: z.string().min(1).max(100).optional(),
|
|
24
|
+
/**
|
|
25
|
+
* Only the external conversations with this target, as `<extension>/<targetKey>` (a target
|
|
26
|
+
* group's "More", local agents spec Part 2).
|
|
27
|
+
*/
|
|
28
|
+
target: z
|
|
29
|
+
.string()
|
|
30
|
+
.max(164)
|
|
31
|
+
.regex(new RegExp(`^[^/]{1,100}/${TARGET_KEY_RE.source.slice(1, -1)}$`), "target must be <extension>/<targetKey>")
|
|
32
|
+
.optional(),
|
|
23
33
|
/**
|
|
24
34
|
* `true`: the first page (no `after`) also returns `total`, the count of every match. Absent or
|
|
25
35
|
* `false`: no count is selected (the count costs O(matches); a polled list never asks for it).
|
|
@@ -27,6 +37,11 @@ export const ListQuery = z.object({
|
|
|
27
37
|
withTotal: z.enum(["true", "false"]).optional(),
|
|
28
38
|
...searchFields,
|
|
29
39
|
});
|
|
40
|
+
/** A list query's `target` (`<extension>/<targetKey>`, already checked) as its parts. */
|
|
41
|
+
export function targetRefOf(target) {
|
|
42
|
+
const at = target.lastIndexOf("/");
|
|
43
|
+
return { extension: target.slice(0, at), targetKey: target.slice(at + 1) };
|
|
44
|
+
}
|
|
30
45
|
export const EventsQuery = z
|
|
31
46
|
.object({
|
|
32
47
|
after: z.coerce.number().int().min(0).optional(),
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type { CacheWriteByTtl, ConversationSource, TriggerSubject } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import type { CacheWriteByTtl, ConversationSource, ExternalConversationState, TriggerSubject } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { AgentLookup } from "../agents/agent-lookup.js";
|
|
3
3
|
import type { AgentDefinition, ModelRef } from "../agents/definition.js";
|
|
4
4
|
import type { AgentAvatarView } from "../agents/profile.js";
|
|
5
5
|
import type { AutomationEventMarker, ScheduleMarker } from "../automations/types.js";
|
|
6
|
-
import type { ConversationSubject, TitleSource } from "../db/kernel-schema.js";
|
|
6
|
+
import type { ConversationKind, ConversationSubject, ExternalRef, TitleSource } from "../db/kernel-schema.js";
|
|
7
7
|
import { ConversationDevices, type NewConversationDevice } from "../devices/conversation-devices.js";
|
|
8
8
|
import { DeviceProjectFilesService } from "../devices/device-project-files.service.js";
|
|
9
9
|
import { DeviceProjectsService } from "../devices/device-projects.service.js";
|
|
10
|
+
import { ExtensionPointDefaults } from "../extensions/point-defaults.js";
|
|
10
11
|
import { LibraryFilesService } from "../files/library-files.service.js";
|
|
11
12
|
import { type PersonRef } from "../identity/account-avatar.js";
|
|
13
|
+
import { InboxItemsService } from "../inbox/inbox-items.service.js";
|
|
12
14
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
13
15
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
14
16
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
@@ -34,7 +36,15 @@ import { type Selection } from "./selection.js";
|
|
|
34
36
|
export interface ConversationView {
|
|
35
37
|
id: string;
|
|
36
38
|
orgId: string;
|
|
37
|
-
|
|
39
|
+
/** What kind of conversation it is: `external` is held with a conversation target (no agent). */
|
|
40
|
+
kind: ConversationKind;
|
|
41
|
+
/** Its agent; null exactly for an external conversation. */
|
|
42
|
+
agentId: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* The conversation target an external conversation is held with (local agents spec Part 2) and
|
|
45
|
+
* the state the target last reported; null for every other kind.
|
|
46
|
+
*/
|
|
47
|
+
external: ExternalConversationView | null;
|
|
38
48
|
accountId: string;
|
|
39
49
|
title: string | null;
|
|
40
50
|
/** Who wrote `title`: the title job, a rename, or nobody yet (UI refresh B). */
|
|
@@ -86,6 +96,13 @@ export interface ConversationView {
|
|
|
86
96
|
*/
|
|
87
97
|
activity: "running" | "waiting" | null;
|
|
88
98
|
}
|
|
99
|
+
/** An external conversation's target and state ({@link ConversationView.external}). */
|
|
100
|
+
export interface ExternalConversationView {
|
|
101
|
+
extension: string;
|
|
102
|
+
targetKey: string;
|
|
103
|
+
label: string;
|
|
104
|
+
state: ExternalConversationState;
|
|
105
|
+
}
|
|
89
106
|
/** The state a conversation's latest `project_root` event records ({@link ConversationView}). */
|
|
90
107
|
export type ProjectState = {
|
|
91
108
|
loaded: true;
|
|
@@ -93,8 +110,15 @@ export type ProjectState = {
|
|
|
93
110
|
} | {
|
|
94
111
|
unavailable: "gone" | "outside_mode" | "unreadable" | "unsupported" | "removed";
|
|
95
112
|
};
|
|
113
|
+
/** The columns of a single-conversation response: {@link COLUMNS} and its project state. */
|
|
114
|
+
export declare const viewColumns: () => readonly ["id", "org_id", "agent_id", "account_id", "title", "title_source", "selection", "last_seq", "created_at", "updated_at", "parent_conversation_id", "subagent_type", "archived_at", "device_id", "automation_id", "subject", "project_name", "project_path", "kind", "external", "external_state", import("kysely").AliasedRawBuilder<ProjectState | null, "project_state">];
|
|
96
115
|
/** Escapes `\`, `%` and `_` so user text is matched literally by `LIKE … ESCAPE '\'`. */
|
|
97
116
|
export declare function escapeLike(s: string): string;
|
|
117
|
+
/** A conversation target as the lists name it (`external.extension`, `external.targetKey`). */
|
|
118
|
+
export interface ConversationTargetRef {
|
|
119
|
+
extension: string;
|
|
120
|
+
targetKey: string;
|
|
121
|
+
}
|
|
98
122
|
/**
|
|
99
123
|
* An agent as the conversation lists carry it: its name and the avatar half of its profile, in the
|
|
100
124
|
* agents API's shape (the web draws it without reading the agents list).
|
|
@@ -112,9 +136,24 @@ export interface ConversationListRow extends ConversationView {
|
|
|
112
136
|
/** Null only when the agent stopped being visible between the page read and the agent read. */
|
|
113
137
|
agent: ConversationAgent | null;
|
|
114
138
|
}
|
|
115
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* One group in the sidebar list: the caller's newest conversations with one agent, or with one
|
|
141
|
+
* conversation target (external conversations, local agents spec Part 2). Exactly one of `agent`
|
|
142
|
+
* and `target` is set.
|
|
143
|
+
*/
|
|
116
144
|
export interface ConversationGroup {
|
|
117
|
-
|
|
145
|
+
/**
|
|
146
|
+
* The group's identity and the groups cursor (`after`): the agent's id, or
|
|
147
|
+
* `target/<extension>/<targetKey>` for a target's group.
|
|
148
|
+
*/
|
|
149
|
+
key: string;
|
|
150
|
+
agent: ConversationAgent | null;
|
|
151
|
+
/** The target of an external conversations' group; its label is its newest conversation's. */
|
|
152
|
+
target: {
|
|
153
|
+
extension: string;
|
|
154
|
+
targetKey: string;
|
|
155
|
+
label: string;
|
|
156
|
+
} | null;
|
|
118
157
|
/** max(updated_at) of the group's conversations. */
|
|
119
158
|
latestAt: Date;
|
|
120
159
|
/** At most `perGroup`, updated_at DESC, id DESC. */
|
|
@@ -314,6 +353,32 @@ export declare const projectFileText: (path: string, root: string) => string;
|
|
|
314
353
|
*/
|
|
315
354
|
export declare function withFileLines(blocks: readonly LogContentBlock[], labels?: ReadonlyMap<string, string>): LogContentBlock[];
|
|
316
355
|
export { userMessageIdemKey } from "./idem-keys.js";
|
|
356
|
+
/** A conversation row (its {@link COLUMNS}) as the {@link ConversationView} the routes answer. */
|
|
357
|
+
export declare function toView(r: {
|
|
358
|
+
id: string;
|
|
359
|
+
org_id: string;
|
|
360
|
+
kind: ConversationKind;
|
|
361
|
+
agent_id: string | null;
|
|
362
|
+
external: ExternalRef | null;
|
|
363
|
+
external_state: ExternalConversationState;
|
|
364
|
+
account_id: string;
|
|
365
|
+
title: string | null;
|
|
366
|
+
title_source: TitleSource | null;
|
|
367
|
+
selection: unknown;
|
|
368
|
+
last_seq: string;
|
|
369
|
+
created_at: Date;
|
|
370
|
+
updated_at: Date;
|
|
371
|
+
parent_conversation_id: string | null;
|
|
372
|
+
subagent_type: string | null;
|
|
373
|
+
archived_at: Date | null;
|
|
374
|
+
device_id: string | null;
|
|
375
|
+
automation_id: string | null;
|
|
376
|
+
subject: ConversationSubject | null;
|
|
377
|
+
project_name: string | null;
|
|
378
|
+
project_path: string | null;
|
|
379
|
+
activity?: "running" | "waiting" | null;
|
|
380
|
+
project_state?: ProjectState | null;
|
|
381
|
+
}): ConversationView;
|
|
317
382
|
/** The longest conversation title (characters, after trimming). */
|
|
318
383
|
export declare const CONVERSATION_TITLE_MAX_CHARS = 120;
|
|
319
384
|
/**
|
|
@@ -426,6 +491,10 @@ export declare class ConversationsService {
|
|
|
426
491
|
private readonly outbox;
|
|
427
492
|
/** The agent's tools for a message naming connectors or resources (inline tokens §3.4). */
|
|
428
493
|
private readonly mentions;
|
|
494
|
+
/** Which extensions serve `conversation-target@1` in the org (external conversations). */
|
|
495
|
+
private readonly points;
|
|
496
|
+
/** A deleted external conversation's open request items are resolved with it. */
|
|
497
|
+
private readonly inbox;
|
|
429
498
|
constructor(permissions: Pick<PermissionProfilesService, "initialize" | "lockInitial" | "defaultProfile">, db: KernelDb, eventLog: EventLog, agents: Pick<AgentLookup, "get">, access: Pick<ConversationAccess, "isAccessible">,
|
|
430
499
|
/** Starts and stops the conversation's runs. */
|
|
431
500
|
runs: RunControl,
|
|
@@ -452,7 +521,11 @@ export declare class ConversationsService {
|
|
|
452
521
|
/** Owes the snapshot deletions of the shares a deletion revokes (file sharing spec §9). */
|
|
453
522
|
outbox: Pick<OutboxService, "add">,
|
|
454
523
|
/** The agent's tools for a message naming connectors or resources (inline tokens §3.4). */
|
|
455
|
-
mentions: Pick<MentionableConnectorsService, "resolveForMessage"
|
|
524
|
+
mentions: Pick<MentionableConnectorsService, "resolveForMessage">,
|
|
525
|
+
/** Which extensions serve `conversation-target@1` in the org (external conversations). */
|
|
526
|
+
points: Pick<ExtensionPointDefaults, "serves" | "providersFor">,
|
|
527
|
+
/** A deleted external conversation's open request items are resolved with it. */
|
|
528
|
+
inbox: Pick<InboxItemsService, "resolveKernelItems">);
|
|
456
529
|
/**
|
|
457
530
|
* Creates an empty conversation bound to its device (`pick`, see
|
|
458
531
|
* {@link ConversationDevices.forNew}); an agent the account cannot use →
|
|
@@ -508,7 +581,7 @@ export declare class ConversationsService {
|
|
|
508
581
|
private startRun;
|
|
509
582
|
private rowView;
|
|
510
583
|
/**
|
|
511
|
-
* Renames a conversation (owner only, as {@link
|
|
584
|
+
* Renames a conversation (owner only, as {@link owned}): `title_source = 'manual'`, so the title
|
|
512
585
|
* job never overwrites it. Publishes `changed: title`. `title` is already trimmed and checked.
|
|
513
586
|
*/
|
|
514
587
|
rename(orgId: string, conversationId: string, accountId: string, title: string): Promise<ConversationView>;
|
|
@@ -540,31 +613,59 @@ export declare class ConversationsService {
|
|
|
540
613
|
/** The root lock excludes dispatch and claimed writes. Lock children in tree order for
|
|
541
614
|
* unfenced writes, then use a fresh READ COMMITTED snapshot for the eligibility decision. */
|
|
542
615
|
private treeExpired;
|
|
543
|
-
/**
|
|
616
|
+
/**
|
|
617
|
+
* Reads a conversation: another person's, or one whose agent the owner can no longer use →
|
|
618
|
+
* `conversation.not_found`. An external conversation (local agents spec Part 2) is read by its
|
|
619
|
+
* owner while its extension serves `conversation-target@1` in the org, else
|
|
620
|
+
* `conversation.not_found` too.
|
|
621
|
+
*/
|
|
544
622
|
get(orgId: string, conversationId: string, viewerAccountId: string): Promise<ConversationView>;
|
|
623
|
+
/**
|
|
624
|
+
* {@link get} for a change of the conversation itself by its owner (rename, archive, delete): a
|
|
625
|
+
* sub-agent's conversation is read-only (sub-agents spec §6.1) → `conversation.read_only`; an
|
|
626
|
+
* external conversation passes.
|
|
627
|
+
*/
|
|
628
|
+
owned(orgId: string, conversationId: string, accountId: string): Promise<ConversationView>;
|
|
545
629
|
getWithOwner(orgId: string, conversationId: string, viewerAccountId: string): Promise<ConversationView & {
|
|
546
630
|
owner: PersonRef | null;
|
|
547
631
|
}>;
|
|
548
632
|
/**
|
|
549
|
-
* {@link
|
|
550
|
-
*
|
|
633
|
+
* {@link owned} for a change that works through Capybara's runs (a message, the queue, a model
|
|
634
|
+
* switch, compaction, an extension UI action): an external conversation is run by its local
|
|
635
|
+
* agent, not by Capybara (its messages and stop go through `ExternalConversationsService`) →
|
|
636
|
+
* `conversation.external_read_only`.
|
|
551
637
|
*/
|
|
552
638
|
writable(orgId: string, conversationId: string, accountId: string): Promise<ConversationView>;
|
|
553
639
|
/** {@link get}'s row, with the conversation's kind. */
|
|
554
640
|
private readable;
|
|
641
|
+
/**
|
|
642
|
+
* {@link readable} for an external conversation (local agents spec Part 2): the viewer's, while
|
|
643
|
+
* its extension serves `conversation-target@1` in the org (the org guard checked the
|
|
644
|
+
* membership); anything else → `conversation.not_found`.
|
|
645
|
+
*/
|
|
646
|
+
private readableExternal;
|
|
555
647
|
/** The stream's visibility check ({@link ConversationAccess.isAccessible}). */
|
|
556
648
|
isAccessible(orgId: string, conversationId: string, viewerAccountId: string): Promise<boolean>;
|
|
557
649
|
/**
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
650
|
+
* The extensions that serve `conversation-target@1` in the org now: the external conversations
|
|
651
|
+
* the lists show (local agents spec Part 2).
|
|
652
|
+
*/
|
|
653
|
+
private servingTargets;
|
|
654
|
+
/**
|
|
655
|
+
* My conversations, most recently updated first: the chat conversations whose agent is in this
|
|
656
|
+
* org, not deleted and visible to me, and the external ones whose extension serves
|
|
657
|
+
* `conversation-target@1` in the org now (local agents spec Part 2). `after` is the previous
|
|
658
|
+
* page's last conversation id, continued after its current (updated_at, id); a cursor that no
|
|
659
|
+
* longer exists gives an empty page. Each row carries its agent (one batch read for the page;
|
|
660
|
+
* null for an external conversation). `agentId` keeps one agent's, `target` one target's. With
|
|
661
|
+
* `total`, also counts every conversation matching the same filters (the cursor aside) in the
|
|
662
|
+
* same statement.
|
|
563
663
|
*/
|
|
564
664
|
listMine(orgId: string, accountId: string, opts: {
|
|
565
665
|
after?: string;
|
|
566
666
|
limit: number;
|
|
567
667
|
agentId?: string;
|
|
668
|
+
target?: ConversationTargetRef;
|
|
568
669
|
archived?: boolean;
|
|
569
670
|
q?: string;
|
|
570
671
|
state?: "running" | "waiting";
|
|
@@ -579,11 +680,13 @@ export declare class ConversationsService {
|
|
|
579
680
|
*/
|
|
580
681
|
private listAgents;
|
|
581
682
|
/**
|
|
582
|
-
* My
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
683
|
+
* My conversations grouped by agent (the sidebar, UI refresh spec §5.9), and my external
|
|
684
|
+
* conversations by target (local agents spec Part 2), in one statement. Only agents that are not
|
|
685
|
+
* deleted and still visible to me and targets whose extension serves `conversation-target@1` in
|
|
686
|
+
* the org now (as {@link listMine}). Groups are ordered by (latestAt DESC, key DESC); each holds
|
|
687
|
+
* up to `perGroup` conversations and says whether it has more. `after` is the last group's key,
|
|
688
|
+
* re-evaluated against that group's current latestAt; a cursor group that is no longer listed
|
|
689
|
+
* gives an empty page.
|
|
587
690
|
*/
|
|
588
691
|
listGroups(orgId: string, accountId: string, opts: {
|
|
589
692
|
perGroup: number;
|
|
@@ -774,7 +877,8 @@ export declare class ConversationsService {
|
|
|
774
877
|
/**
|
|
775
878
|
* {@link resolveExtra}'s referenced conversations (@ conversations spec §1), read as the sender
|
|
776
879
|
* outside any transaction, once each in the body's order. Each must be the sender's own chat in
|
|
777
|
-
* this org, not deleted, its agent still visible ({@link readable} plus `kind = 'chat'`)
|
|
880
|
+
* this org, not deleted, its agent still visible ({@link readable} plus `kind = 'chat'`), or
|
|
881
|
+
* their external conversation whose extension serves the org (local agents spec Part 2); any
|
|
778
882
|
* other → `conversation.reference_unavailable` (`details: [{ id }]`, the same for every case);
|
|
779
883
|
* one with no `user_message` yet → the same code with `reason: "empty"`; the conversation
|
|
780
884
|
* being written in → `conversation.reference_self`.
|