opencode-gateway 0.2.3 → 0.2.5
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/cli.js +0 -0
- package/dist/index.js +36910 -56
- package/dist/runtime/delay.d.ts +1 -0
- package/dist/store/database.d.ts +22 -0
- package/dist/store/migrations.d.ts +2 -2
- package/dist/store/sqlite.d.ts +2 -2
- package/package.json +9 -3
- package/dist/binding/execution.js +0 -1
- package/dist/binding/gateway.js +0 -1
- package/dist/binding/index.js +0 -4
- package/dist/binding/opencode.js +0 -1
- package/dist/cli/args.js +0 -53
- package/dist/cli/doctor.js +0 -49
- package/dist/cli/init.js +0 -40
- package/dist/cli/opencode-config-file.js +0 -18
- package/dist/cli/opencode-config.js +0 -194
- package/dist/cli/paths.js +0 -22
- package/dist/cli/templates.js +0 -41
- package/dist/config/cron.js +0 -52
- package/dist/config/gateway.js +0 -148
- package/dist/config/memory.js +0 -105
- package/dist/config/paths.js +0 -39
- package/dist/config/telegram.js +0 -91
- package/dist/cron/runtime.js +0 -402
- package/dist/delivery/telegram.js +0 -75
- package/dist/delivery/text.js +0 -175
- package/dist/gateway.js +0 -117
- package/dist/host/file-sender.js +0 -59
- package/dist/host/logger.js +0 -53
- package/dist/host/transport.js +0 -35
- package/dist/mailbox/router.js +0 -16
- package/dist/media/mime.js +0 -45
- package/dist/memory/prompt.js +0 -122
- package/dist/opencode/adapter.js +0 -340
- package/dist/opencode/driver-hub.js +0 -82
- package/dist/opencode/event-normalize.js +0 -48
- package/dist/opencode/event-stream.js +0 -65
- package/dist/opencode/events.js +0 -1
- package/dist/questions/client.js +0 -36
- package/dist/questions/format.js +0 -36
- package/dist/questions/normalize.js +0 -45
- package/dist/questions/parser.js +0 -96
- package/dist/questions/runtime.js +0 -195
- package/dist/questions/types.js +0 -1
- package/dist/runtime/attachments.js +0 -12
- package/dist/runtime/conversation-coordinator.js +0 -22
- package/dist/runtime/executor.js +0 -407
- package/dist/runtime/mailbox.js +0 -112
- package/dist/runtime/opencode-runner.js +0 -79
- package/dist/runtime/runtime-singleton.js +0 -28
- package/dist/session/context.js +0 -23
- package/dist/session/conversation-key.js +0 -3
- package/dist/session/switcher.js +0 -59
- package/dist/session/system-prompt.js +0 -52
- package/dist/store/migrations.js +0 -197
- package/dist/store/sqlite.js +0 -777
- package/dist/telegram/client.js +0 -180
- package/dist/telegram/media.js +0 -65
- package/dist/telegram/normalize.js +0 -119
- package/dist/telegram/poller.js +0 -166
- package/dist/telegram/runtime.js +0 -157
- package/dist/telegram/state.js +0 -149
- package/dist/telegram/types.js +0 -1
- package/dist/tools/channel-new-session.js +0 -27
- package/dist/tools/channel-send-file.js +0 -27
- package/dist/tools/channel-target.js +0 -34
- package/dist/tools/cron-run.js +0 -20
- package/dist/tools/cron-upsert.js +0 -51
- package/dist/tools/gateway-dispatch-cron.js +0 -33
- package/dist/tools/gateway-status.js +0 -25
- package/dist/tools/schedule-cancel.js +0 -12
- package/dist/tools/schedule-format.js +0 -48
- package/dist/tools/schedule-list.js +0 -17
- package/dist/tools/schedule-once.js +0 -43
- package/dist/tools/schedule-status.js +0 -23
- package/dist/tools/telegram-send-test.js +0 -26
- package/dist/tools/telegram-status.js +0 -49
- package/dist/tools/time.js +0 -25
- package/dist/utils/error.js +0 -57
package/dist/utils/error.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export function formatError(error) {
|
|
2
|
-
if (error instanceof Error) {
|
|
3
|
-
const errorLike = error;
|
|
4
|
-
const nestedMessage = extractNestedDataMessage(errorLike.data);
|
|
5
|
-
if (nestedMessage !== null) {
|
|
6
|
-
return nestedMessage;
|
|
7
|
-
}
|
|
8
|
-
return error.message;
|
|
9
|
-
}
|
|
10
|
-
if (typeof error === "string") {
|
|
11
|
-
return error;
|
|
12
|
-
}
|
|
13
|
-
if (typeof error === "object" && error !== null) {
|
|
14
|
-
const errorLike = error;
|
|
15
|
-
const nestedMessage = extractNestedDataMessage(errorLike.data);
|
|
16
|
-
if (nestedMessage !== null) {
|
|
17
|
-
return nestedMessage;
|
|
18
|
-
}
|
|
19
|
-
if (typeof errorLike.message === "string" && errorLike.message.length > 0) {
|
|
20
|
-
const detail = compactObject({
|
|
21
|
-
name: errorLike.name,
|
|
22
|
-
code: errorLike.code,
|
|
23
|
-
status: errorLike.status,
|
|
24
|
-
cause: errorLike.cause,
|
|
25
|
-
});
|
|
26
|
-
return detail === null ? errorLike.message : `${errorLike.message} (${detail})`;
|
|
27
|
-
}
|
|
28
|
-
const serialized = safeJsonStringify(error);
|
|
29
|
-
if (serialized !== null) {
|
|
30
|
-
return serialized;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return String(error);
|
|
34
|
-
}
|
|
35
|
-
function extractNestedDataMessage(value) {
|
|
36
|
-
if (typeof value !== "object" || value === null) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const message = value.message;
|
|
40
|
-
return typeof message === "string" && message.length > 0 ? message : null;
|
|
41
|
-
}
|
|
42
|
-
function compactObject(value) {
|
|
43
|
-
const entries = Object.entries(value).filter(([, fieldValue]) => fieldValue !== undefined && fieldValue !== null);
|
|
44
|
-
if (entries.length === 0) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
const serialized = safeJsonStringify(Object.fromEntries(entries));
|
|
48
|
-
return serialized ?? entries.map(([key, fieldValue]) => `${key}=${String(fieldValue)}`).join(", ");
|
|
49
|
-
}
|
|
50
|
-
function safeJsonStringify(value) {
|
|
51
|
-
try {
|
|
52
|
-
return JSON.stringify(value);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|