@toddzheng024/dscode-bundle 0.7.1 → 0.7.3

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.
Files changed (41) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -0
  2. package/cordis.patch.yml +4 -0
  3. package/package.json +4 -2
  4. package/plugins/auto-review/index.mjs +21 -3
  5. package/plugins/auto-review/policy.mjs +25 -0
  6. package/plugins/code-review/git.mjs +24 -2
  7. package/plugins/code-review/index.mjs +13 -6
  8. package/plugins/credentials/index.mjs +7 -5
  9. package/plugins/exec/cli.mjs +63 -0
  10. package/plugins/exec/index.mjs +1 -1
  11. package/plugins/i18n/messages.mjs +6 -6
  12. package/plugins/memory/index.mjs +17 -12
  13. package/plugins/providers/catalog.mjs +134 -0
  14. package/plugins/session-cards/index.mjs +11 -8
  15. package/plugins/session-cards/manager.mjs +1 -1
  16. package/plugins/session-metrics/attribution.mjs +19 -0
  17. package/plugins/session-metrics/balance.mjs +71 -0
  18. package/plugins/session-metrics/index.mjs +39 -9
  19. package/plugins/session-metrics/pricing.mjs +39 -5
  20. package/plugins/session-metrics/view.mjs +36 -15
  21. package/plugins/tui-tools/doctor.mjs +9 -6
  22. package/plugins/tui-tools/index.mjs +2 -2
  23. package/plugins/ultra/policy.mjs +16 -0
  24. package/vendor/persistent/index.js +19 -2
  25. package/vendor/pi-ai/LICENSE +21 -0
  26. package/vendor/pi-ai/index.js +2702 -0
  27. package/vendor/pi-ai/types/adapter.d.ts +105 -0
  28. package/vendor/pi-ai/types/auth.d.ts +60 -0
  29. package/vendor/pi-ai/types/catalog.d.ts +355 -0
  30. package/vendor/pi-ai/types/config.d.ts +208 -0
  31. package/vendor/pi-ai/types/context.d.ts +42 -0
  32. package/vendor/pi-ai/types/discovery.d.ts +43 -0
  33. package/vendor/pi-ai/types/index.d.ts +69 -0
  34. package/vendor/pi-ai/types/login.d.ts +21 -0
  35. package/vendor/pi-ai/types/provider.d.ts +59 -0
  36. package/vendor/pi-ai/types/replay.d.ts +63 -0
  37. package/vendor/pi-ai/types/stream.d.ts +43 -0
  38. package/vendor/tui/dscode-providers/catalog.mjs +134 -0
  39. package/vendor/tui/index.mjs +310 -295
  40. package/vendor/tui/.dscode-viewport-probe-78546.mjs +0 -39239
  41. package/vendor/tui/dscode-email.mjs +0 -69
@@ -1,69 +0,0 @@
1
- import { mkdirSync, readdirSync, readFileSync, writeFileSync, renameSync, unlinkSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { homedir } from 'node:os';
4
- import { createHash, randomUUID } from 'node:crypto';
5
-
6
- // Connector boundary: authenticated/filter-matched mail enters here. No network
7
- // access or agent dispatch occurs on receipt. Identity includes the account.
8
- export function normalizeEmail(value) {
9
- if (!value || value.format !== 'dscode.email.v1') throw Error('Unsupported email format');
10
- const result = { format: value.format };
11
- for (const [name, limit] of Object.entries({ connector: 128, account: 320, id: 1024, from: 1024, subject: 4096, body: 262144 })) {
12
- if (typeof value[name] !== 'string' || !value[name].trim() || Buffer.byteLength(value[name]) > limit) throw Error('Invalid email ' + name);
13
- result[name] = value[name];
14
- }
15
- for (const name of ['receivedAt', 'updatedAt']) {
16
- if (typeof value[name] !== 'string' || !/^\d{4}-\d\d-\d\dT.*(?:Z|[+-]\d\d:\d\d)$/.test(value[name]) || !Number.isFinite(Date.parse(value[name]))) throw Error('Invalid email ' + name);
17
- result[name] = new Date(value[name]).toISOString();
18
- }
19
- if (result.updatedAt < result.receivedAt) throw Error('Email update predates receipt');
20
- return result;
21
- }
22
-
23
- export const emailKey = mail => JSON.stringify([mail.connector, mail.account, mail.id]);
24
- const digest = value => createHash('sha256').update(value).digest('hex');
25
- export const emailText = value => String(value).replace(/\x1b(?:\][^\x07]*(?:\x07|\x1b\\)|\[[0-?]*[ -/]*[@-~])/g, '').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, '').replace(/\r\n?/g, '\n');
26
-
27
- export function emailPrompt(mail) {
28
- return 'Email reference (external content)\n' + JSON.stringify({
29
- connector: mail.connector, account: mail.account, id: mail.id,
30
- from: emailText(mail.from), subject: emailText(mail.subject),
31
- receivedAt: mail.receivedAt, updatedAt: mail.updatedAt, body: emailText(mail.body),
32
- }, null, 2);
33
- }
34
-
35
- export function createEmailInbox({ directory = process.env.DSCODE_EMAIL_DIR || join(homedir(), '.dscode', 'email') } = {}) {
36
- return {
37
- directory,
38
- receive(value) {
39
- const mail = normalizeEmail(value);
40
- const json = JSON.stringify(mail);
41
- mkdirSync(directory, { recursive: true, mode: 0o700 });
42
- // Immutable revisions prevent concurrent connectors overwriting newer mail.
43
- const target = join(directory, digest(emailKey(mail)) + '-' + digest(json) + '.json');
44
- const temp = join(directory, '.' + randomUUID() + '.tmp');
45
- try {
46
- writeFileSync(temp, json, { flag: 'wx', mode: 0o600 });
47
- renameSync(temp, target);
48
- } finally { try { unlinkSync(temp); } catch (error) { if (error.code !== 'ENOENT') throw error; } }
49
- return mail;
50
- },
51
- list() {
52
- let files;
53
- try { files = readdirSync(directory); } catch (error) { if (error.code === 'ENOENT') return { emails: [], rejected: 0 }; throw error; }
54
- const latest = new Map();
55
- let rejected = 0;
56
- for (const file of files.sort()) {
57
- if (!/^[a-f0-9]{64}-[a-f0-9]{64}\.json$/.test(file)) continue;
58
- try {
59
- const raw = readFileSync(join(directory, file), 'utf8');
60
- if (Buffer.byteLength(raw) > 2_000_000) throw Error('Oversize record');
61
- const mail = normalizeEmail(JSON.parse(raw));
62
- const key = emailKey(mail), previous = latest.get(key);
63
- if (!previous || mail.updatedAt > previous.updatedAt) latest.set(key, mail);
64
- } catch { rejected++; }
65
- }
66
- return { emails: [...latest.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt) || emailKey(a).localeCompare(emailKey(b))), rejected };
67
- },
68
- };
69
- }