@capybara-hq/kernel 0.1.0-rc.96 → 0.1.0-rc.98
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/bootstrap.json +3 -3
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.schemas.d.ts +10 -0
- package/dist/channels/channels.schemas.js +7 -0
- package/dist/channels/connections.service.d.ts +7 -0
- package/dist/channels/connections.service.js +4 -0
- package/dist/channels/features.d.ts +18 -1
- package/dist/channels/features.js +22 -0
- package/dist/channels/outbound.d.ts +19 -0
- package/dist/channels/outbound.js +531 -18
- package/dist/channels/phrases.d.ts +10 -0
- package/dist/channels/phrases.js +4 -0
- package/dist/channels/progress.d.ts +75 -0
- package/dist/channels/progress.js +216 -0
- package/dist/conversations/event-log.d.ts +8 -2
- package/dist/conversations/events.d.ts +5 -0
- package/dist/conversations/events.js +5 -1
- package/dist/conversations/prompt-suggestions.js +2 -2
- package/dist/db/kernel-schema.d.ts +16 -0
- package/dist/evals/run-replay.js +2 -2
- package/dist/evals/step-replay.js +2 -2
- package/dist/evals/worker.js +3 -1
- package/dist/extensions/plugin-icons.d.ts +7 -0
- package/dist/extensions/plugin-icons.js +8 -0
- package/dist/models/purposes.js +2 -2
- package/dist/platform/ops/channels.ops.js +24 -5
- package/dist/runtime/model-call.d.ts +23 -2
- package/dist/runtime/model-call.js +64 -9
- package/dist/runtime/run-drafts.d.ts +46 -4
- package/dist/runtime/run-drafts.js +110 -9
- package/dist/runtime/run-steps.d.ts +2 -1
- package/dist/runtime/run-steps.js +6 -2
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/runtime/stream.controller.d.ts +7 -5
- package/dist/runtime/stream.controller.js +10 -6
- package/dist/runtime/stream.js +9 -1
- package/dist/runtime/write-base.d.ts +95 -0
- package/dist/runtime/write-base.js +281 -0
- package/dist/runtime/write-base.service.d.ts +68 -0
- package/dist/runtime/write-base.service.js +184 -0
- package/dist/sandbox/kernel-read.d.ts +39 -9
- package/dist/sandbox/kernel-read.js +33 -3
- package/dist/sandbox/operation-authority.d.ts +16 -12
- package/dist/sandbox/operation-authority.js +33 -20
- package/dist/sandbox/operation-intents.d.ts +10 -4
- package/dist/sandbox/operation-intents.js +31 -11
- package/dist/sandbox/sandbox.service.d.ts +30 -7
- package/dist/sandbox/sandbox.service.js +47 -13
- package/dist/tools/builtins/agent.js +4 -0
- package/dist/tools/builtins/image/generate.js +1 -0
- package/dist/tools/builtins/sandbox/bash.js +1 -0
- package/dist/tools/builtins/sandbox/edit.js +1 -0
- package/dist/tools/builtins/sandbox/write.js +1 -0
- package/dist/tools/builtins/send-message.js +1 -0
- package/dist/tools/info.d.ts +21 -2
- package/dist/tools/info.js +55 -12
- package/dist/tools/pipeline.d.ts +3 -1
- package/dist/tools/pipeline.js +37 -3
- package/dist/tools/registry.d.ts +6 -5
- package/dist/tools/registry.js +6 -5
- package/package.json +3 -3
- package/src/migrations/0185_channel_process_display.sql +13 -0
package/bootstrap.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"schemaVersion": 1,
|
|
4
4
|
"marketplace": {
|
|
5
5
|
"url": "https://github.com/capybara-hq/plugins.git",
|
|
6
|
-
"commit": "
|
|
6
|
+
"commit": "5cb8d1fb8c322661922be66f6a4f83808010ac2e"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"name": "device-docker",
|
|
91
91
|
"source": "npm",
|
|
92
92
|
"npm": "@capybara-hq/plugin-device-docker",
|
|
93
|
-
"version": "0.1.0-rc.
|
|
94
|
-
"integrity": "sha512-
|
|
93
|
+
"version": "0.1.0-rc.33",
|
|
94
|
+
"integrity": "sha512-5gPqMsCQAaVfgtR8CH+DxHnvlNT/1QKu+XXVyiCh4eaKKcwdEDW/Lefs2VI09ERUY3Oo2v2F5B7p9pMf/SeC7w==",
|
|
95
95
|
"required": false
|
|
96
96
|
},
|
|
97
97
|
{
|
|
@@ -208,7 +208,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
208
208
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
209
209
|
export declare const HOST_VERSIONS: {
|
|
210
210
|
readonly kernel: string;
|
|
211
|
-
readonly sdk: "0.1.0-rc.
|
|
211
|
+
readonly sdk: "0.1.0-rc.81";
|
|
212
212
|
};
|
|
213
213
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
214
214
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -13,6 +13,11 @@ export declare const ChannelCreateSchema: z.ZodObject<{
|
|
|
13
13
|
long_connection: "long_connection";
|
|
14
14
|
webhook: "webhook";
|
|
15
15
|
}>>;
|
|
16
|
+
processDisplay: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
17
|
+
brief: "brief";
|
|
18
|
+
detailed: "detailed";
|
|
19
|
+
off: "off";
|
|
20
|
+
}>>>;
|
|
16
21
|
}, z.core.$strict>;
|
|
17
22
|
export declare const ChannelPatchSchema: z.ZodObject<{
|
|
18
23
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -29,6 +34,11 @@ export declare const ChannelPatchSchema: z.ZodObject<{
|
|
|
29
34
|
long_connection: "long_connection";
|
|
30
35
|
webhook: "webhook";
|
|
31
36
|
}>>;
|
|
37
|
+
processDisplay: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
38
|
+
brief: "brief";
|
|
39
|
+
detailed: "detailed";
|
|
40
|
+
off: "off";
|
|
41
|
+
}>>>;
|
|
32
42
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
33
43
|
}, z.core.$strict>;
|
|
34
44
|
/** 「我已更新应用」: the template hash of the setup guide the person was shown. */
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
const Config = z.record(z.string().max(200), z.unknown());
|
|
3
3
|
const Policy = z.enum(["bind", "anonymous"]);
|
|
4
|
+
/**
|
|
5
|
+
* How the channel shows a run's process (one edited progress card per run); null = the default by
|
|
6
|
+
* chat type (direct chats detailed, group chats brief).
|
|
7
|
+
*/
|
|
8
|
+
const ProcessDisplay = z.enum(["detailed", "brief", "off"]).nullable().optional();
|
|
4
9
|
export const ChannelCreateSchema = z
|
|
5
10
|
.object({
|
|
6
11
|
plugin: z.string().min(1).max(214),
|
|
@@ -10,6 +15,7 @@ export const ChannelCreateSchema = z
|
|
|
10
15
|
unboundPolicy: Policy.optional(),
|
|
11
16
|
// default long_connection; webhook needs plugin support and channels.webhookBaseUrl (409)
|
|
12
17
|
inboundMode: z.enum(["long_connection", "webhook"]).optional(),
|
|
18
|
+
processDisplay: ProcessDisplay,
|
|
13
19
|
})
|
|
14
20
|
.strict();
|
|
15
21
|
export const ChannelPatchSchema = z
|
|
@@ -20,6 +26,7 @@ export const ChannelPatchSchema = z
|
|
|
20
26
|
status: z.enum(["active", "disabled"]).optional(),
|
|
21
27
|
// webhook needs plugin support and channels.webhookBaseUrl (409 channel.webhook_unavailable)
|
|
22
28
|
inboundMode: z.enum(["long_connection", "webhook"]).optional(),
|
|
29
|
+
processDisplay: ProcessDisplay,
|
|
23
30
|
config: Config.optional(),
|
|
24
31
|
})
|
|
25
32
|
.strict();
|
|
@@ -13,6 +13,7 @@ import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
|
13
13
|
import { type KernelLogger } from "../log.js";
|
|
14
14
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
15
15
|
import type { OrgRole } from "../orgs/roles.js";
|
|
16
|
+
import { type ProcessDisplay } from "./features.js";
|
|
16
17
|
import { ChannelJobs } from "./jobs.js";
|
|
17
18
|
import type { ChannelLocale } from "./phrases.js";
|
|
18
19
|
/**
|
|
@@ -46,6 +47,8 @@ export interface ChannelConnectionView {
|
|
|
46
47
|
unboundPolicy: UnboundPolicy;
|
|
47
48
|
status: ChannelStatus;
|
|
48
49
|
inboundMode: InboundMode;
|
|
50
|
+
/** How the channel shows a run's process; null = the default by chat type (`processDisplayOf`). */
|
|
51
|
+
processDisplay: ProcessDisplay | null;
|
|
49
52
|
/** The plugin implements `Channel.webhook`, so the connection can switch to webhook mode. */
|
|
50
53
|
webhookSupported: boolean;
|
|
51
54
|
/**
|
|
@@ -91,6 +94,8 @@ export interface CreateChannelInput {
|
|
|
91
94
|
unboundPolicy?: UnboundPolicy | undefined;
|
|
92
95
|
/** Default `long_connection`; `webhook` needs plugin support and `channels.webhookBaseUrl`. */
|
|
93
96
|
inboundMode?: InboundMode | undefined;
|
|
97
|
+
/** Absent or null: the default by chat type. */
|
|
98
|
+
processDisplay?: ProcessDisplay | null | undefined;
|
|
94
99
|
}
|
|
95
100
|
/**
|
|
96
101
|
* Whether a channel plugin's connections can use webhook inbound (channel inbound mode fields spec
|
|
@@ -109,6 +114,8 @@ export interface UpdateChannelInput {
|
|
|
109
114
|
unboundPolicy?: UnboundPolicy | undefined;
|
|
110
115
|
status?: "active" | "disabled" | undefined;
|
|
111
116
|
inboundMode?: InboundMode | undefined;
|
|
117
|
+
/** Absent = unchanged; null = back to the default by chat type. */
|
|
118
|
+
processDisplay?: ProcessDisplay | null | undefined;
|
|
112
119
|
config?: Record<string, unknown> | undefined;
|
|
113
120
|
}
|
|
114
121
|
/**
|
|
@@ -124,6 +124,7 @@ const COLUMNS = [
|
|
|
124
124
|
"unbound_policy",
|
|
125
125
|
"status",
|
|
126
126
|
"inbound_mode",
|
|
127
|
+
"process_display",
|
|
127
128
|
"last_error",
|
|
128
129
|
"bot_user_id",
|
|
129
130
|
"tenant_id",
|
|
@@ -304,6 +305,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
304
305
|
unboundPolicy: r.unbound_policy,
|
|
305
306
|
status: r.status,
|
|
306
307
|
inboundMode: r.inbound_mode,
|
|
308
|
+
processDisplay: r.process_display,
|
|
307
309
|
webhookSupported,
|
|
308
310
|
webhookUrl: webhookSupported && base !== undefined ? webhookUrlOf(base, r.id) : null,
|
|
309
311
|
lastError: r.last_error,
|
|
@@ -437,6 +439,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
437
439
|
config: JSON.stringify(a.plain),
|
|
438
440
|
unbound_policy: input.unboundPolicy ?? "bind",
|
|
439
441
|
inbound_mode: input.inboundMode ?? "long_connection",
|
|
442
|
+
process_display: input.processDisplay ?? null,
|
|
440
443
|
bot_user_id: a.verified.botUserId,
|
|
441
444
|
tenant_id: a.verified.tenantId,
|
|
442
445
|
guide_ack: a.guideAck === null ? null : JSON.stringify(a.guideAck),
|
|
@@ -596,6 +599,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
596
599
|
...(patch.unboundPolicy !== undefined && { unbound_policy: patch.unboundPolicy }),
|
|
597
600
|
...(patch.status !== undefined && { status: patch.status }),
|
|
598
601
|
...(patch.inboundMode !== undefined && { inbound_mode: patch.inboundMode }),
|
|
602
|
+
...(patch.processDisplay !== undefined && { process_display: patch.processDisplay }),
|
|
599
603
|
...(a.guideAck !== undefined && {
|
|
600
604
|
guide_ack: a.guideAck === null ? null : JSON.stringify(a.guideAck),
|
|
601
605
|
}),
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import { type Channel, type ChannelTarget, type OutboundMessage } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type Channel, type ChannelCard, type ChannelTarget, type OutboundMessage } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/** How a channel shows a run's process: a detailed or brief progress card, or none. */
|
|
3
|
+
export type ProcessDisplay = "detailed" | "brief" | "off";
|
|
4
|
+
/**
|
|
5
|
+
* The effective process display of a connection's chat: the stored setting, else the default by
|
|
6
|
+
* chat type (direct chats detailed, group chats brief).
|
|
7
|
+
*/
|
|
8
|
+
export declare function processDisplayOf(v: string | null, chatType: "dm" | "group"): ProcessDisplay;
|
|
9
|
+
/**
|
|
10
|
+
* A run's progress card as the message the channel gets: the native card (titled for the
|
|
11
|
+
* notification preview) only when the plugin declares `features.progress` and `cards`;
|
|
12
|
+
* otherwise its {@link renderCardAsText} text, which the kernel edits in place like the card
|
|
13
|
+
* (process blocks spec §10 Execution rulings: a released plugin without a `progress` branch
|
|
14
|
+
* would throw on it).
|
|
15
|
+
*/
|
|
16
|
+
export declare function progressCardMessage(features: Channel["features"], card: Extract<ChannelCard, {
|
|
17
|
+
kind: "progress";
|
|
18
|
+
}>, locale: "zh" | "en"): OutboundMessage;
|
|
2
19
|
/** `threads: false`: the target loses its `threadId` (the platform has no threads). */
|
|
3
20
|
export declare function adaptTarget(features: Channel["features"], target: ChannelTarget): ChannelTarget;
|
|
4
21
|
/**
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { renderCardAsText, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* The effective process display of a connection's chat: the stored setting, else the default by
|
|
4
|
+
* chat type (direct chats detailed, group chats brief).
|
|
5
|
+
*/
|
|
6
|
+
export function processDisplayOf(v, chatType) {
|
|
7
|
+
if (v === "detailed" || v === "brief" || v === "off")
|
|
8
|
+
return v;
|
|
9
|
+
return chatType === "dm" ? "detailed" : "brief";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A run's progress card as the message the channel gets: the native card (titled for the
|
|
13
|
+
* notification preview) only when the plugin declares `features.progress` and `cards`;
|
|
14
|
+
* otherwise its {@link renderCardAsText} text, which the kernel edits in place like the card
|
|
15
|
+
* (process blocks spec §10 Execution rulings: a released plugin without a `progress` branch
|
|
16
|
+
* would throw on it).
|
|
17
|
+
*/
|
|
18
|
+
export function progressCardMessage(features, card, locale) {
|
|
19
|
+
// `cards: false` would fall the card back to text after its title: the text alone instead
|
|
20
|
+
if (features.progress === true && features.cards)
|
|
21
|
+
return { text: card.title, cards: [card] };
|
|
22
|
+
return { text: renderCardAsText(card, locale) };
|
|
23
|
+
}
|
|
2
24
|
/** `threads: false`: the target loses its `threadId` (the platform has no threads). */
|
|
3
25
|
export function adaptTarget(features, target) {
|
|
4
26
|
if (!features.threads && target.threadId !== undefined) {
|
|
@@ -33,6 +33,12 @@ export declare function closingText(prior: string | undefined, how: DraftClosing
|
|
|
33
33
|
export declare const DELIVER_LOCK_PREFIX = "capk:channel-deliver:";
|
|
34
34
|
/** 草稿更新的最小间隔(毫秒);渠道声明了更大的 `features.minEditIntervalMs` 时取后者。 */
|
|
35
35
|
export declare const DRAFT_INTERVAL_MS = 1000;
|
|
36
|
+
/**
|
|
37
|
+
* A channel without edits gets a milestone message (the pinned card's text) at most this often per
|
|
38
|
+
* run (process blocks spec §10.4); measured between the events' log times, so every replica decides
|
|
39
|
+
* the same.
|
|
40
|
+
*/
|
|
41
|
+
export declare const MILESTONE_INTERVAL_MS = 60000;
|
|
36
42
|
/** 同一事件不可重试地失败这么多次后跳过它(Ruling A14)。 */
|
|
37
43
|
export declare const POISON_FAILURES = 3;
|
|
38
44
|
/**
|
|
@@ -55,6 +61,19 @@ export interface DeliveryAdvance {
|
|
|
55
61
|
persisted: number;
|
|
56
62
|
seq: number;
|
|
57
63
|
draft?: string | null;
|
|
64
|
+
/**
|
|
65
|
+
* A run's progress message was posted (null: a channel without edits, which posts none): its id
|
|
66
|
+
* and run are recorded, the milestone time and the re-post flag cleared (process blocks spec
|
|
67
|
+
* §6.3).
|
|
68
|
+
*/
|
|
69
|
+
progress?: {
|
|
70
|
+
messageId: string | null;
|
|
71
|
+
runId: string;
|
|
72
|
+
};
|
|
73
|
+
/** A milestone message was sent: the log time of its event. */
|
|
74
|
+
milestoneAt?: Date;
|
|
75
|
+
/** The ended run's card got its final edit (or was refused it for good). */
|
|
76
|
+
progressFinal?: true;
|
|
58
77
|
card?: {
|
|
59
78
|
kind: "approval" | "question";
|
|
60
79
|
id: string;
|