@capybara-hq/kernel 0.1.0-rc.97 → 0.1.0-rc.99
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 +17 -17
- package/dist/catalog/git-source.d.ts +5 -0
- package/dist/catalog/git-source.js +9 -5
- package/dist/catalog/marketplace-fetch.d.ts +9 -0
- package/dist/catalog/marketplace-fetch.js +9 -5
- 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 +6 -0
- package/dist/conversations/events.js +7 -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/net/safe-fetch.d.ts +22 -4
- package/dist/net/safe-fetch.js +74 -0
- package/dist/platform/file-ref.d.ts +2 -0
- package/dist/platform/file-ref.js +1 -3
- 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/platform.js +4 -3
- package/dist/tools/builtins/sandbox/bash.d.ts +3 -1
- package/dist/tools/builtins/sandbox/bash.js +23 -11
- package/dist/tools/builtins/sandbox/common.d.ts +4 -1
- package/dist/tools/builtins/sandbox/common.js +5 -2
- package/dist/tools/builtins/sandbox/edit.js +1 -0
- package/dist/tools/builtins/sandbox/glob.js +2 -1
- package/dist/tools/builtins/sandbox/grep.js +2 -1
- package/dist/tools/builtins/sandbox/search-command.d.ts +4 -3
- package/dist/tools/builtins/sandbox/search-command.js +11 -3
- 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/network-asks.d.ts +23 -0
- package/dist/tools/network-asks.js +24 -5
- package/dist/tools/pipeline.d.ts +3 -1
- package/dist/tools/pipeline.js +76 -12
- package/dist/tools/registry.d.ts +12 -11
- 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,15 +3,15 @@
|
|
|
3
3
|
"schemaVersion": 1,
|
|
4
4
|
"marketplace": {
|
|
5
5
|
"url": "https://github.com/capybara-hq/plugins.git",
|
|
6
|
-
"commit": "
|
|
6
|
+
"commit": "1f142e1cebba0b54d94ba69b97004609d9c03cc4"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
10
10
|
"name": "openai-compatible",
|
|
11
11
|
"source": "npm",
|
|
12
12
|
"npm": "@capybara-hq/plugin-openai-compatible",
|
|
13
|
-
"version": "0.1.0-rc.
|
|
14
|
-
"integrity": "sha512-
|
|
13
|
+
"version": "0.1.0-rc.13",
|
|
14
|
+
"integrity": "sha512-IXdGfR9nhUXFWcF+3Bpmemn6M2e/EgC7x1jhKg84H23vKANviVcGvyTugyAjyd7K3vd0DD8aYAW1CMnTksUpJg==",
|
|
15
15
|
"required": false
|
|
16
16
|
},
|
|
17
17
|
{
|
|
@@ -26,40 +26,40 @@
|
|
|
26
26
|
"name": "anthropic",
|
|
27
27
|
"source": "npm",
|
|
28
28
|
"npm": "@capybara-hq/plugin-anthropic",
|
|
29
|
-
"version": "0.1.0-rc.
|
|
30
|
-
"integrity": "sha512-
|
|
29
|
+
"version": "0.1.0-rc.11",
|
|
30
|
+
"integrity": "sha512-du0wCj2z3asIZk1mpDOBAtlZSmqB1WQTr8doHb8uPSKGCqfkcCgSVrJWP8dbqW//BHO8un0uWLs74TBvk+f9ug==",
|
|
31
31
|
"required": false
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"name": "openai",
|
|
35
35
|
"source": "npm",
|
|
36
36
|
"npm": "@capybara-hq/plugin-openai",
|
|
37
|
-
"version": "0.1.0-rc.
|
|
38
|
-
"integrity": "sha512-
|
|
37
|
+
"version": "0.1.0-rc.13",
|
|
38
|
+
"integrity": "sha512-96cLlSSDPNlAjeFjHYYVfupqUDYYmePMThmB1nhwDoNO15F3OXEUECRGUR8PbUSjjthZTQ7gmb+HfCx9CqBweg==",
|
|
39
39
|
"required": false
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "deepseek",
|
|
43
43
|
"source": "npm",
|
|
44
44
|
"npm": "@capybara-hq/plugin-deepseek",
|
|
45
|
-
"version": "0.1.0-rc.
|
|
46
|
-
"integrity": "sha512-
|
|
45
|
+
"version": "0.1.0-rc.12",
|
|
46
|
+
"integrity": "sha512-bDl3SWO/SO23PaY7Jc9km79kctaGYKqjWOTaXcb+olJNHCNwP4lEXuAY7jylBMaDxL3WttWdHDS6c/QjHFbUeA==",
|
|
47
47
|
"required": false
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
"name": "bailian",
|
|
51
51
|
"source": "npm",
|
|
52
52
|
"npm": "@capybara-hq/plugin-bailian",
|
|
53
|
-
"version": "0.1.0-rc.
|
|
54
|
-
"integrity": "sha512-
|
|
53
|
+
"version": "0.1.0-rc.12",
|
|
54
|
+
"integrity": "sha512-bEO6UTSlFJq5F+4ht/FQtgM2pOhRzaVY2+URWegR7lZ7utd9AhkTEoRAFnECUq3e7kI7/pJMoNyNX6KTMd9Xpw==",
|
|
55
55
|
"required": false
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": "ark",
|
|
59
59
|
"source": "npm",
|
|
60
60
|
"npm": "@capybara-hq/plugin-ark",
|
|
61
|
-
"version": "0.1.0-rc.
|
|
62
|
-
"integrity": "sha512-
|
|
61
|
+
"version": "0.1.0-rc.13",
|
|
62
|
+
"integrity": "sha512-dmS7jJcPGTsWBzRC8rIe5T/GUrqfNNzlQeS5iIfoZdXGNPJqNrylHLp12eRZspaTPkZzpGgowV0MOhiQvwDzMA==",
|
|
63
63
|
"required": false
|
|
64
64
|
},
|
|
65
65
|
{
|
|
@@ -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.34",
|
|
94
|
+
"integrity": "sha512-FOYFio9VPBzGic0RqpFDN6qMmyuWEA2PHl2ZsIknHfvHYqMQsv6NCoESbWo2SAVGzmt6c3YRC1u8C02m3SDAEg==",
|
|
95
95
|
"required": false
|
|
96
96
|
},
|
|
97
97
|
{
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"name": "todo",
|
|
108
108
|
"source": "npm",
|
|
109
109
|
"npm": "@capybara-hq/plugin-todo",
|
|
110
|
-
"version": "0.1.0-rc.
|
|
111
|
-
"integrity": "sha512-
|
|
110
|
+
"version": "0.1.0-rc.14",
|
|
111
|
+
"integrity": "sha512-HtGVlONC/l11Pw0lctdOMQc29ccUaVuU86LYx6cIq/plvfGKUXzSO9K/fAM3ED64eHNPSAUUYGRutloQY6HsfA==",
|
|
112
112
|
"required": false
|
|
113
113
|
},
|
|
114
114
|
{
|
|
@@ -57,6 +57,11 @@ export type GitOptions = {
|
|
|
57
57
|
maxBytes: number;
|
|
58
58
|
/** Where the temp object store is created (default the OS temp dir); tests only. */
|
|
59
59
|
tempRoot?: string;
|
|
60
|
+
/** Retry of transient failures (connection errors, HTTP 502 / 503 / 504); tests shorten it. */
|
|
61
|
+
retry?: {
|
|
62
|
+
attempts?: number;
|
|
63
|
+
backoffMs?: number;
|
|
64
|
+
};
|
|
60
65
|
};
|
|
61
66
|
export type GitSourceErrorCode = "marketplace.git_failed" | "marketplace.git_too_large" | "marketplace.git_unsupported_entry";
|
|
62
67
|
/**
|
|
@@ -6,7 +6,7 @@ import { inflateSync } from "node:zlib";
|
|
|
6
6
|
import { GIT_MARKETPLACE_USERNAME_DEFAULT, GIT_USERNAME_RE } from "@capybara-hq/plugin-sdk";
|
|
7
7
|
import git, {} from "isomorphic-git";
|
|
8
8
|
import { NetDeniedError } from "../net/public-address.js";
|
|
9
|
-
import { NetBodyTooLargeError, safeFetch } from "../net/safe-fetch.js";
|
|
9
|
+
import { describeFetchError, NetBodyTooLargeError, safeFetch } from "../net/safe-fetch.js";
|
|
10
10
|
import { marketplaceNetCode, marketplaceUrlProblem, } from "./marketplace-fetch.js";
|
|
11
11
|
/**
|
|
12
12
|
* Reading plugins from git (spec §5.1, §5.2; Decision 2): isomorphic-git (pure JS, any smart-HTTP
|
|
@@ -138,7 +138,9 @@ function startOp(loc, o) {
|
|
|
138
138
|
headers.authorization = auth;
|
|
139
139
|
const method = req.method ?? "GET";
|
|
140
140
|
const body = req.body === undefined ? undefined : await collect(req.body);
|
|
141
|
-
const res = await safeFetch(target.href, { method, headers, ...(body !== undefined && { body }), signal }, o.net,
|
|
141
|
+
const res = await safeFetch(target.href, { method, headers, ...(body !== undefined && { body }), signal }, o.net,
|
|
142
|
+
// both git requests only read (`info/refs`, `git-upload-pack`) and the body is a Buffer
|
|
143
|
+
{ maxBytes: o.maxBytes, retry: o.retry ?? {} });
|
|
142
144
|
const stream = res.body;
|
|
143
145
|
async function* chunks() {
|
|
144
146
|
if (stream === null)
|
|
@@ -191,9 +193,11 @@ function mapError(e, op, o, what) {
|
|
|
191
193
|
if (cause instanceof NetDeniedError)
|
|
192
194
|
return mapError(cause, op, o, what);
|
|
193
195
|
const status = e?.data?.statusCode;
|
|
194
|
-
if (typeof status === "number")
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
if (typeof status === "number") {
|
|
197
|
+
const text = e.data?.statusMessage;
|
|
198
|
+
return failed(`${what}: the git server answered ${status}${typeof text === "string" && text !== "" ? ` ${text}` : ""}`, e);
|
|
199
|
+
}
|
|
200
|
+
return failed(`${what}: ${describeFetchError(e)}`, e);
|
|
197
201
|
}
|
|
198
202
|
/**
|
|
199
203
|
* The commit to read (40 lower-case hex): `commit` when given (it wins over `ref`), otherwise the
|
|
@@ -60,6 +60,11 @@ export interface MarketplaceFetchOptions {
|
|
|
60
60
|
net: NetPolicy;
|
|
61
61
|
/** Tests only: replaces the DNS lookup. */
|
|
62
62
|
lookup?: LookupFn;
|
|
63
|
+
/** Retry of transient failures (connection errors, HTTP 502 / 503 / 504); tests shorten it. */
|
|
64
|
+
retry?: {
|
|
65
|
+
attempts?: number;
|
|
66
|
+
backoffMs?: number;
|
|
67
|
+
};
|
|
63
68
|
signal: AbortSignal;
|
|
64
69
|
}
|
|
65
70
|
export type MarketplaceFetchResult = {
|
|
@@ -95,6 +100,10 @@ export declare function fetchMarketplaceArchive(archive: {
|
|
|
95
100
|
timeoutMs: number;
|
|
96
101
|
net: NetPolicy;
|
|
97
102
|
lookup?: LookupFn;
|
|
103
|
+
retry?: {
|
|
104
|
+
attempts?: number;
|
|
105
|
+
backoffMs?: number;
|
|
106
|
+
};
|
|
98
107
|
signal?: AbortSignal;
|
|
99
108
|
}): Promise<{
|
|
100
109
|
bytes: Uint8Array;
|
|
@@ -2,7 +2,7 @@ import { createHash, timingSafeEqual } from "node:crypto";
|
|
|
2
2
|
import { parseMarketplaceManifest } from "@capybara-hq/plugin-sdk";
|
|
3
3
|
import { ApiError } from "../errors.js";
|
|
4
4
|
import { NetDeniedError } from "../net/public-address.js";
|
|
5
|
-
import { safeFetch } from "../net/safe-fetch.js";
|
|
5
|
+
import { describeFetchError, safeFetch } from "../net/safe-fetch.js";
|
|
6
6
|
import { isLoopback, readCapped } from "../packages/npm.js";
|
|
7
7
|
/**
|
|
8
8
|
* The API error for a refused download, or undefined when the refusal is not one of the two
|
|
@@ -96,6 +96,7 @@ export async function fetchMarketplaceManifest(url, o) {
|
|
|
96
96
|
try {
|
|
97
97
|
res = await safeFetch(target.href, { headers, signal }, o.net, {
|
|
98
98
|
...(o.lookup !== undefined && { lookup: o.lookup }),
|
|
99
|
+
retry: o.retry ?? {},
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
catch (e) {
|
|
@@ -106,7 +107,9 @@ export async function fetchMarketplaceManifest(url, o) {
|
|
|
106
107
|
...(code !== undefined && { code, host: e.host }),
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
|
-
throw new MarketplaceFetchError(`cannot fetch the marketplace: ${
|
|
110
|
+
throw new MarketplaceFetchError(`cannot fetch the marketplace: ${describeFetchError(e)}`, {
|
|
111
|
+
cause: e,
|
|
112
|
+
});
|
|
110
113
|
}
|
|
111
114
|
if (res.status === 304) {
|
|
112
115
|
await res.body?.cancel().catch(() => { });
|
|
@@ -114,7 +117,7 @@ export async function fetchMarketplaceManifest(url, o) {
|
|
|
114
117
|
}
|
|
115
118
|
if (!res.ok) {
|
|
116
119
|
await res.body?.cancel().catch(() => { });
|
|
117
|
-
throw new MarketplaceFetchError(`the marketplace responded with HTTP ${res.status}`);
|
|
120
|
+
throw new MarketplaceFetchError(`the marketplace responded with HTTP ${res.status}${res.statusText !== "" ? ` ${res.statusText}` : ""}${res.status >= 500 ? " (the upstream host failed; try again later)" : ""}`);
|
|
118
121
|
}
|
|
119
122
|
let raw;
|
|
120
123
|
try {
|
|
@@ -171,6 +174,7 @@ export async function fetchMarketplaceArchive(archive, o) {
|
|
|
171
174
|
try {
|
|
172
175
|
res = await safeFetch(new URL(archive.url).href, { signal }, o.net, {
|
|
173
176
|
...(o.lookup !== undefined && { lookup: o.lookup }),
|
|
177
|
+
retry: o.retry ?? {},
|
|
174
178
|
});
|
|
175
179
|
}
|
|
176
180
|
catch (e) {
|
|
@@ -180,11 +184,11 @@ export async function fetchMarketplaceArchive(archive, o) {
|
|
|
180
184
|
throw new ApiError(code, `Archive download refused: ${e.message}`, [{ host: e.host }]);
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
|
-
throw failed(`cannot fetch the archive: ${
|
|
187
|
+
throw failed(`cannot fetch the archive ${archive.url}: ${describeFetchError(e)}`);
|
|
184
188
|
}
|
|
185
189
|
if (!res.ok) {
|
|
186
190
|
await res.body?.cancel().catch(() => { });
|
|
187
|
-
throw failed(`the archive URL responded with HTTP ${res.status}`);
|
|
191
|
+
throw failed(`the archive URL ${archive.url} responded with HTTP ${res.status}`);
|
|
188
192
|
}
|
|
189
193
|
const tooLarge = new ApiError("extension.package_too_large", `the package is larger than ${o.maxBytes} bytes`);
|
|
190
194
|
let bytes;
|
|
@@ -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.82";
|
|
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;
|