@reserendipity/dsh-superagent 0.0.0-stage → 0.1.0

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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +50 -0
  3. package/README.md +206 -2
  4. package/cordis.patch.yml +214 -0
  5. package/examples/profile.cordis.patch.yml +31 -0
  6. package/lib/client.js +7695 -0
  7. package/lib/feishu-Dvj-1eJf.js +1325 -0
  8. package/lib/feishu-watch.d.ts +125 -0
  9. package/lib/feishu-watch.js +2 -0
  10. package/lib/github-pull-DRiuuSs8.js +597 -0
  11. package/lib/github-watch.d.ts +2 -0
  12. package/lib/github-watch.js +836 -0
  13. package/lib/host-BIWKSB5j.js +124 -0
  14. package/lib/inbox-watch.d.ts +43 -0
  15. package/lib/inbox-watch.js +343 -0
  16. package/lib/index.d.ts +369 -0
  17. package/lib/index.js +13654 -0
  18. package/lib/instance-status-Cqaju-dw.js +87 -0
  19. package/lib/instances-view.d.ts +164 -0
  20. package/lib/instances-view.js +258 -0
  21. package/lib/intake-TNIkqilh.d.ts +735 -0
  22. package/lib/kind--8woUEex.d.ts +1019 -0
  23. package/lib/poll-Bm5EYA2c.js +819 -0
  24. package/lib/schemas-MhNERx8d.js +4484 -0
  25. package/lib/schemas-lx-F2nnt.d.ts +2134 -0
  26. package/locale/en.json +6 -0
  27. package/locale/zh.json +6 -0
  28. package/package.json +159 -4
  29. package/prompts/admission.md +68 -0
  30. package/prompts/cli.md +17 -0
  31. package/prompts/dispatch.md +59 -0
  32. package/prompts/handoff-orchestrator.md +4 -0
  33. package/prompts/handoff-worker.md +7 -0
  34. package/prompts/handoff.md +6 -0
  35. package/prompts/orchestrator.md +16 -0
  36. package/prompts/presets/brief/communication.md +4 -0
  37. package/prompts/presets/brief/delivery.md +3 -0
  38. package/prompts/presets/brief/scope.md +4 -0
  39. package/prompts/presets/evidence/communication.md +6 -0
  40. package/prompts/presets/evidence/delivery.md +4 -0
  41. package/prompts/presets/evidence/scope.md +5 -0
  42. package/prompts/presets/result/communication.md +4 -0
  43. package/prompts/presets/result/delivery.md +3 -0
  44. package/prompts/presets/result/scope.md +5 -0
  45. package/prompts/replies.md +35 -0
  46. package/prompts/shared.md +9 -0
  47. package/prompts/subscriptions.md +13 -0
  48. package/prompts/team/communication.md +101 -0
  49. package/prompts/team/delivery.md +35 -0
  50. package/prompts/team/scope.md +26 -0
  51. package/prompts/work.md +49 -0
  52. package/prompts/worker.md +10 -0
  53. package/schema/declarative-settings.example.json +26 -0
  54. package/schema/declarative-settings.schema.json +348 -0
  55. package/skills/README.md +14 -0
  56. package/skills/dsh-superagent-feishu/SKILL.md +12 -0
  57. package/skills/dsh-superagent-github/SKILL.md +14 -0
@@ -0,0 +1,1019 @@
1
+ import { _ as output, b as $loose, c as ZodObject, d as ZodRecord, f as ZodString, g as ZodUnknown, i as ZodEnum, l as ZodOptional, m as ZodType, n as ZodBoolean, o as ZodNullable, p as ZodTransform, r as ZodDefault, s as ZodNumber, t as ZodArray, u as ZodPipe, v as $ZodTypeInternals, x as $strict, y as $catchall } from "./schemas-lx-F2nnt.js";
2
+ import { F as Thread, I as ThreadFact, R as ThreadRef, S as ChannelRef, U as Trigger, h as SourceScope, l as OutboundMessage, lt as Deployment, m as ScopeResult, t as ReceiveResult, v as AdmissionCell, z as Ticket } from "./intake-TNIkqilh.js";
3
+ import { Context } from "@deepseek-ai/cordis";
4
+ import { DatabaseSync } from "node:sqlite";
5
+ import { MessageId } from "@deepseek-ai/dsh-llm";
6
+ import { Agent } from "@deepseek-ai/dsh-agent";
7
+ //#region src/infra/commands.d.ts
8
+ interface Tally {
9
+ skipped: number;
10
+ }
11
+ /**
12
+ * Executes gh, lark-cli, and git subprocesses with deployment account credentials, timeouts, and abort signals.
13
+ * Restricts GitHub API calls to the configured repository and translates CLI failures into CliError instances for Sources, MasterAssessor, Outbox, and Settings.
14
+ */
15
+ declare class Commands {
16
+ private readonly resolved;
17
+ private readonly environment;
18
+ private readonly signal;
19
+ /**
20
+ * @param resolved - returns the resolved deployment setup, or throws while setup is still pending.
21
+ * @param environment - variables overriding `process.env` for every command (such as isolated git settings).
22
+ */
23
+ constructor(resolved: () => Deployment, environment: Record<string, string | undefined>, signal: AbortSignal);
24
+ get deployment(): Deployment;
25
+ get repository(): string;
26
+ withSignal(signal?: AbortSignal): Commands;
27
+ run(program: string, args: string[], cwd?: string): Promise<string>;
28
+ /** Runs the agent's GitHub CLI and parses its JSON output; callers should prefer `api`, which is restricted to the configured repository and validates output. */
29
+ gh<T>(args: string[]): Promise<T>;
30
+ /**
31
+ * Calls the GitHub API on a path within the configured repository, validating JSON output when a schema is provided
32
+ * or returning raw CLI output (such as raw files or `--include` headers) when omitted.
33
+ * @throws CliError with GitHub's HTTP status as `code` on failure.
34
+ */
35
+ api<T>(schema: ZodType<T>, path: string, ...flags: string[]): Promise<T>;
36
+ api(path: string, ...flags: string[]): Promise<string>;
37
+ /** Fetches all pages of a GitHub API list within the configured repository, skipping items that fail schema validation. */
38
+ pages<T>(item: ZodType<T>, path: string, tally?: Tally): Promise<T[]>;
39
+ private path;
40
+ /**
41
+ * Runs the Feishu bot's `lark-cli` and returns the JSON `data` payload.
42
+ * @throws CliError with Feishu's error code on failure (rewriting 232011 when the bot is not in the chat).
43
+ */
44
+ lark<T>(args: string[], cwd?: string): Promise<T>;
45
+ /** Runs `git` on PATH using the agent's isolated git environment and credential helper. */
46
+ git(args: string[], cwd: string): Promise<string>;
47
+ }
48
+ //#endregion
49
+ //#region src/admission.d.ts
50
+ declare const ADMISSION_OPTIONS: {
51
+ readonly listedUnaddressed: readonly ["inferred", "ignore"];
52
+ readonly unlistedAddressed: readonly ["explicit", "inferred", "ignore"];
53
+ readonly unlistedUnaddressed: readonly ["inferred", "ignore"];
54
+ };
55
+ type AdmissionRow = { [C in AdmissionCell]?: typeof ADMISSION_OPTIONS[C][number]; };
56
+ //#endregion
57
+ //#region src/infra/health.d.ts
58
+ interface HealthEntry {
59
+ get(): Health | undefined;
60
+ set(health: Health): void;
61
+ /** Unregisters the entry from the board (such as when a Source kind unregisters); subsequent `set` calls become no-ops. */
62
+ release(): void;
63
+ }
64
+ /**
65
+ * Central registry of component health entries, enforcing single-writer ownership per entry name.
66
+ * Claimed by Runtime, Effects, Sessions, DshExecutor, Settings, and SourceRegistry, and read by management HTTP routes.
67
+ */
68
+ declare class HealthBoard {
69
+ private readonly entries;
70
+ private readonly claimed;
71
+ claim(name: string, initial?: Health): HealthEntry;
72
+ get all(): Readonly<Record<string, Health>>;
73
+ }
74
+ //#endregion
75
+ //#region src/policy.d.ts
76
+ declare const SettingsSchema: ZodObject<{
77
+ paused: ZodDefault<ZodBoolean>;
78
+ sources: ZodDefault<ZodRecord<ZodString, ZodObject<{
79
+ kind: ZodOptional<ZodString>;
80
+ enabled: ZodDefault<ZodBoolean>;
81
+ config: ZodDefault<ZodRecord<ZodString, ZodUnknown>>;
82
+ }, $strict>>>;
83
+ policy: ZodDefault<ZodObject<{
84
+ rules: ZodDefault<ZodArray<ZodObject<{
85
+ id: ZodString;
86
+ name: ZodString;
87
+ enabled: ZodBoolean;
88
+ instruction: ZodString;
89
+ }, $strict>>>;
90
+ sources: ZodDefault<ZodRecord<ZodString, ZodObject<{
91
+ allowed: ZodDefault<ZodArray<ZodObject<{
92
+ id: ZodString;
93
+ name: ZodOptional<ZodString>;
94
+ }, $strict>>>;
95
+ admission: ZodDefault<ZodRecord<ZodString, ZodType<AdmissionRow, unknown, $ZodTypeInternals<AdmissionRow, unknown>>>>;
96
+ }, $catchall<ZodUnknown>>>>;
97
+ }, $strict>>;
98
+ eval: ZodDefault<ZodObject<{
99
+ mode: ZodDefault<ZodEnum<{
100
+ off: "off";
101
+ observe: "observe";
102
+ auto: "auto";
103
+ }>>;
104
+ timeoutSeconds: ZodDefault<ZodNumber>;
105
+ model: ZodDefault<ZodNullable<ZodObject<{
106
+ provider: ZodString;
107
+ model: ZodString;
108
+ reasoningEffort: ZodOptional<ZodString>;
109
+ }, $strict>>>;
110
+ }, $strict>>;
111
+ executor: ZodDefault<ZodObject<{
112
+ model: ZodDefault<ZodNullable<ZodObject<{
113
+ provider: ZodString;
114
+ model: ZodString;
115
+ reasoningEffort: ZodOptional<ZodString>;
116
+ }, $strict>>>;
117
+ maxWorkers: ZodDefault<ZodNumber>;
118
+ directory: ZodDefault<ZodString>;
119
+ prepare: ZodDefault<ZodString>;
120
+ blockedCommands: ZodDefault<ZodArray<ZodString>>;
121
+ watchdogMinutes: ZodDefault<ZodNumber>;
122
+ watchdogStallMinutes: ZodDefault<ZodNumber>;
123
+ watchdogGuidance: ZodDefault<ZodString>;
124
+ routerShards: ZodDefault<ZodNumber>;
125
+ }, $strict>>;
126
+ }, $strict>;
127
+ type Settings = output<typeof SettingsSchema>;
128
+ //#endregion
129
+ //#region src/sources/registry.d.ts
130
+ /**
131
+ * Manages registered SourceKind plugins, validates their instance and policy configurations, and implements SourceScope for the Engine.
132
+ * Claims each registered kind's health entries on HealthBoard and mediates access to source channels, links, environment variables, and thread context readers for Runtime, Settings, Outbox, and MasterAssessor.
133
+ */
134
+ declare class SourceRegistry implements SourceScope {
135
+ private readonly settings;
136
+ private readonly board;
137
+ private readonly registered;
138
+ private readonly kinds;
139
+ private readonly health;
140
+ /** Per-instance health entries, keyed by instance id, for instances whose id is not their kind. */
141
+ private readonly instanceEntries;
142
+ constructor(settings: () => Settings, board?: Pick<HealthBoard, 'claim'>, registered?: (kind: SourceKind) => () => void);
143
+ /** Registers a SourceKind, claims its health entries on HealthBoard (rejecting `sync:` prefixes owned by Settings), and returns an unregister disposer. */
144
+ register<C extends Record<string, unknown>>(kind: SourceKind<C>): () => void;
145
+ /**
146
+ * Returns the active health entries for `names`. A Source context writes through the entries it received when built,
147
+ * so reports sent after that registration ended do nothing even if the kind registers again.
148
+ */
149
+ healthEntries(names: readonly string[]): Map<string, HealthEntry>;
150
+ /** The kind an instance id belongs to; an id that names no kind falls back to itself (`github` → `github`). */
151
+ private kindId;
152
+ kind(id: string): SourceKind | undefined;
153
+ /**
154
+ * Health entries for one instance: the kind's own names for its default instance, suffixed with the instance
155
+ * otherwise, so two instances of one kind do not overwrite each other's state. Claimed once and reused.
156
+ */
157
+ instanceHealth(kind: {
158
+ kind: string;
159
+ health: readonly string[];
160
+ }, instance: string): Map<string, HealthEntry>;
161
+ /** Every registered kind's instance ordered by ID, followed by stored instances whose kind is not installed (with their config kept as stored). */
162
+ instances(settings?: {
163
+ paused: boolean;
164
+ sources: Record<string, {
165
+ enabled: boolean;
166
+ config: Record<string, unknown>;
167
+ kind?: string | undefined;
168
+ }>;
169
+ policy: {
170
+ rules: {
171
+ id: string;
172
+ name: string;
173
+ enabled: boolean;
174
+ instruction: string;
175
+ }[];
176
+ sources: Record<string, {
177
+ [x: string]: unknown;
178
+ allowed: {
179
+ id: string;
180
+ name?: string | undefined;
181
+ }[];
182
+ admission: Record<string, AdmissionRow>;
183
+ }>;
184
+ };
185
+ eval: {
186
+ mode: "off" | "observe" | "auto";
187
+ timeoutSeconds: number;
188
+ model: {
189
+ provider: string;
190
+ model: string;
191
+ reasoningEffort?: string | undefined;
192
+ } | null;
193
+ };
194
+ executor: {
195
+ model: {
196
+ provider: string;
197
+ model: string;
198
+ reasoningEffort?: string | undefined;
199
+ } | null;
200
+ maxWorkers: number;
201
+ directory: string;
202
+ prepare: string;
203
+ blockedCommands: string[];
204
+ watchdogMinutes: number;
205
+ watchdogStallMinutes: number;
206
+ watchdogGuidance: string;
207
+ routerShards: number;
208
+ };
209
+ }): (SourceInstance & {
210
+ installed: boolean;
211
+ })[];
212
+ instance<C extends Record<string, unknown>>(id: string, settings?: {
213
+ paused: boolean;
214
+ sources: Record<string, {
215
+ enabled: boolean;
216
+ config: Record<string, unknown>;
217
+ kind?: string | undefined;
218
+ }>;
219
+ policy: {
220
+ rules: {
221
+ id: string;
222
+ name: string;
223
+ enabled: boolean;
224
+ instruction: string;
225
+ }[];
226
+ sources: Record<string, {
227
+ [x: string]: unknown;
228
+ allowed: {
229
+ id: string;
230
+ name?: string | undefined;
231
+ }[];
232
+ admission: Record<string, AdmissionRow>;
233
+ }>;
234
+ };
235
+ eval: {
236
+ mode: "off" | "observe" | "auto";
237
+ timeoutSeconds: number;
238
+ model: {
239
+ provider: string;
240
+ model: string;
241
+ reasoningEffort?: string | undefined;
242
+ } | null;
243
+ };
244
+ executor: {
245
+ model: {
246
+ provider: string;
247
+ model: string;
248
+ reasoningEffort?: string | undefined;
249
+ } | null;
250
+ maxWorkers: number;
251
+ directory: string;
252
+ prepare: string;
253
+ blockedCommands: string[];
254
+ watchdogMinutes: number;
255
+ watchdogStallMinutes: number;
256
+ watchdogGuidance: string;
257
+ routerShards: number;
258
+ };
259
+ }): SourceInstance<C> | undefined;
260
+ validate(id: string, value: {
261
+ enabled: boolean;
262
+ config: unknown;
263
+ }): {
264
+ enabled: boolean;
265
+ config: Record<string, unknown>;
266
+ };
267
+ /** Validates each Source's part of a submitted Policy against its kind; policy parts for uninstalled Source kinds are kept as stored. */
268
+ validatePolicy(parts: Record<string, Record<string, unknown>>): Record<string, Record<string, unknown> & {
269
+ allowed: {
270
+ id: string;
271
+ name?: string;
272
+ }[];
273
+ }>;
274
+ policyPart(id: string, settings?: {
275
+ paused: boolean;
276
+ sources: Record<string, {
277
+ enabled: boolean;
278
+ config: Record<string, unknown>;
279
+ kind?: string | undefined;
280
+ }>;
281
+ policy: {
282
+ rules: {
283
+ id: string;
284
+ name: string;
285
+ enabled: boolean;
286
+ instruction: string;
287
+ }[];
288
+ sources: Record<string, {
289
+ [x: string]: unknown;
290
+ allowed: {
291
+ id: string;
292
+ name?: string | undefined;
293
+ }[];
294
+ admission: Record<string, AdmissionRow>;
295
+ }>;
296
+ };
297
+ eval: {
298
+ mode: "off" | "observe" | "auto";
299
+ timeoutSeconds: number;
300
+ model: {
301
+ provider: string;
302
+ model: string;
303
+ reasoningEffort?: string | undefined;
304
+ } | null;
305
+ };
306
+ executor: {
307
+ model: {
308
+ provider: string;
309
+ model: string;
310
+ reasoningEffort?: string | undefined;
311
+ } | null;
312
+ maxWorkers: number;
313
+ directory: string;
314
+ prepare: string;
315
+ blockedCommands: string[];
316
+ watchdogMinutes: number;
317
+ watchdogStallMinutes: number;
318
+ watchdogGuidance: string;
319
+ routerShards: number;
320
+ };
321
+ }): {
322
+ admission: Record<string, AdmissionRow>;
323
+ allowed: {
324
+ id: string;
325
+ name?: string;
326
+ }[];
327
+ } | undefined;
328
+ channelAllowed(channel: {
329
+ source: string;
330
+ address: Record<string, string>;
331
+ }, settings?: {
332
+ paused: boolean;
333
+ sources: Record<string, {
334
+ enabled: boolean;
335
+ config: Record<string, unknown>;
336
+ kind?: string | undefined;
337
+ }>;
338
+ policy: {
339
+ rules: {
340
+ id: string;
341
+ name: string;
342
+ enabled: boolean;
343
+ instruction: string;
344
+ }[];
345
+ sources: Record<string, {
346
+ [x: string]: unknown;
347
+ allowed: {
348
+ id: string;
349
+ name?: string | undefined;
350
+ }[];
351
+ admission: Record<string, AdmissionRow>;
352
+ }>;
353
+ };
354
+ eval: {
355
+ mode: "off" | "observe" | "auto";
356
+ timeoutSeconds: number;
357
+ model: {
358
+ provider: string;
359
+ model: string;
360
+ reasoningEffort?: string | undefined;
361
+ } | null;
362
+ };
363
+ executor: {
364
+ model: {
365
+ provider: string;
366
+ model: string;
367
+ reasoningEffort?: string | undefined;
368
+ } | null;
369
+ maxWorkers: number;
370
+ directory: string;
371
+ prepare: string;
372
+ blockedCommands: string[];
373
+ watchdogMinutes: number;
374
+ watchdogStallMinutes: number;
375
+ watchdogGuidance: string;
376
+ routerShards: number;
377
+ };
378
+ }): boolean;
379
+ /** Environment variable declarations for every installed kind, whether enabled or disabled. */
380
+ declarations(): {
381
+ kind: string;
382
+ variables: readonly VariableSpec[];
383
+ }[];
384
+ environments(settings?: {
385
+ paused: boolean;
386
+ sources: Record<string, {
387
+ enabled: boolean;
388
+ config: Record<string, unknown>;
389
+ kind?: string | undefined;
390
+ }>;
391
+ policy: {
392
+ rules: {
393
+ id: string;
394
+ name: string;
395
+ enabled: boolean;
396
+ instruction: string;
397
+ }[];
398
+ sources: Record<string, {
399
+ [x: string]: unknown;
400
+ allowed: {
401
+ id: string;
402
+ name?: string | undefined;
403
+ }[];
404
+ admission: Record<string, AdmissionRow>;
405
+ }>;
406
+ };
407
+ eval: {
408
+ mode: "off" | "observe" | "auto";
409
+ timeoutSeconds: number;
410
+ model: {
411
+ provider: string;
412
+ model: string;
413
+ reasoningEffort?: string | undefined;
414
+ } | null;
415
+ };
416
+ executor: {
417
+ model: {
418
+ provider: string;
419
+ model: string;
420
+ reasoningEffort?: string | undefined;
421
+ } | null;
422
+ maxWorkers: number;
423
+ directory: string;
424
+ prepare: string;
425
+ blockedCommands: string[];
426
+ watchdogMinutes: number;
427
+ watchdogStallMinutes: number;
428
+ watchdogGuidance: string;
429
+ routerShards: number;
430
+ };
431
+ }): {
432
+ kind: SourceKind<Record<string, unknown>>;
433
+ environment: {
434
+ variables: readonly VariableSpec[];
435
+ values(input: EnvironmentInput<Record<string, unknown>>): Record<string, string>;
436
+ };
437
+ config: Record<string, unknown>;
438
+ }[];
439
+ /**
440
+ * Sends a message idempotently through its Channel's kind; returns `'waiting'` while the kind is not installed, or
441
+ * `'gone'` when the target (or a kind without channels) can never receive it.
442
+ */
443
+ send(message: OutboundMessage, commands: Commands, delivered?: readonly DeliveredMessage[]): Promise<'sent' | 'gone' | 'waiting'>;
444
+ link(channel: ChannelRef, links: ChannelLinks): ChannelLink;
445
+ find(query: string): {
446
+ threads: string[];
447
+ terms: string[];
448
+ };
449
+ repliesTo(trigger: Trigger): string | undefined;
450
+ threadContext(trigger: Trigger, settings?: {
451
+ paused: boolean;
452
+ sources: Record<string, {
453
+ enabled: boolean;
454
+ config: Record<string, unknown>;
455
+ kind?: string | undefined;
456
+ }>;
457
+ policy: {
458
+ rules: {
459
+ id: string;
460
+ name: string;
461
+ enabled: boolean;
462
+ instruction: string;
463
+ }[];
464
+ sources: Record<string, {
465
+ [x: string]: unknown;
466
+ allowed: {
467
+ id: string;
468
+ name?: string | undefined;
469
+ }[];
470
+ admission: Record<string, AdmissionRow>;
471
+ }>;
472
+ };
473
+ eval: {
474
+ mode: "off" | "observe" | "auto";
475
+ timeoutSeconds: number;
476
+ model: {
477
+ provider: string;
478
+ model: string;
479
+ reasoningEffort?: string | undefined;
480
+ } | null;
481
+ };
482
+ executor: {
483
+ model: {
484
+ provider: string;
485
+ model: string;
486
+ reasoningEffort?: string | undefined;
487
+ } | null;
488
+ maxWorkers: number;
489
+ directory: string;
490
+ prepare: string;
491
+ blockedCommands: string[];
492
+ watchdogMinutes: number;
493
+ watchdogStallMinutes: number;
494
+ watchdogGuidance: string;
495
+ routerShards: number;
496
+ };
497
+ }): TriggerContext | undefined;
498
+ scope(input: {
499
+ source: string;
500
+ meta: Record<string, unknown>;
501
+ }, settings?: {
502
+ paused: boolean;
503
+ sources: Record<string, {
504
+ enabled: boolean;
505
+ config: Record<string, unknown>;
506
+ kind?: string | undefined;
507
+ }>;
508
+ policy: {
509
+ rules: {
510
+ id: string;
511
+ name: string;
512
+ enabled: boolean;
513
+ instruction: string;
514
+ }[];
515
+ sources: Record<string, {
516
+ [x: string]: unknown;
517
+ allowed: {
518
+ id: string;
519
+ name?: string | undefined;
520
+ }[];
521
+ admission: Record<string, AdmissionRow>;
522
+ }>;
523
+ };
524
+ eval: {
525
+ mode: "off" | "observe" | "auto";
526
+ timeoutSeconds: number;
527
+ model: {
528
+ provider: string;
529
+ model: string;
530
+ reasoningEffort?: string | undefined;
531
+ } | null;
532
+ };
533
+ executor: {
534
+ model: {
535
+ provider: string;
536
+ model: string;
537
+ reasoningEffort?: string | undefined;
538
+ } | null;
539
+ maxWorkers: number;
540
+ directory: string;
541
+ prepare: string;
542
+ blockedCommands: string[];
543
+ watchdogMinutes: number;
544
+ watchdogStallMinutes: number;
545
+ watchdogGuidance: string;
546
+ routerShards: number;
547
+ };
548
+ }): ScopeResult;
549
+ /** Falls back to schema defaults and disables the instance when stored configuration fails validation. */
550
+ private resolve;
551
+ }
552
+ //#endregion
553
+ //#region src/setup.d.ts
554
+ type SetupPlace = 'deployment' | 'github' | 'feishu';
555
+ declare const SETUP_PROBLEMS: {
556
+ readonly foreignFile: readonly ["deployment", "{file} was not written by dsh-superagent; move it, or choose another state directory."];
557
+ readonly gitTooOld: readonly ["deployment", "git does not read the github.com credential configuration dsh-superagent writes; dsh-superagent needs git 2.32 or later."];
558
+ readonly multipleSourcesUnsupported: readonly ["deployment", "This process serves one context boundary, but these GitHub Sources were configured: {sources}. Run one instance per repository (or per team sharing memory and credentials) instead of adding repositories here; see docs/011."];
559
+ readonly multiAccountUnsupported: readonly ["deployment", "These GitHub Sources use different agent accounts: {accounts}. One process serves several repositories only when they share one account, until per-instance accounts land (docs/010-multi-source.md)."];
560
+ readonly environmentFailed: readonly ["deployment", "Preparing the agent environment failed."];
561
+ readonly repositoryUnset: readonly ["github", "The GitHub Source names no repository."];
562
+ readonly agentCliUnset: readonly ["github", "The agent GitHub CLI is not set."];
563
+ readonly agentCliMissing: readonly ["github", "The agent GitHub CLI was not found."];
564
+ readonly agentCliSignedOut: readonly ["github", "The agent GitHub CLI cannot read its account."];
565
+ readonly agentCliNoAccount: readonly ["github", "The agent GitHub CLI did not report a GitHub account."];
566
+ readonly repositoryUnreadable: readonly ["github", "@{account} cannot read {repository}."];
567
+ readonly repositoryUnreported: readonly ["github", "The agent GitHub CLI did not return {repository}."];
568
+ readonly repositoryReadOnly: readonly ["github", "@{account} cannot push to {repository}."];
569
+ readonly feishuCliFailed: readonly ["feishu", "The bot lark-cli does not work."];
570
+ readonly feishuNoApp: readonly ["feishu", "auth status of the bot lark-cli did not report the app."];
571
+ readonly feishuBotNotReady: readonly ["feishu", "The bot identity of app {app} is {status}; configure the app secret with lark-cli."];
572
+ readonly feishuUserIdentity: readonly ["feishu", "The bot lark-cli allows user identities (strict mode {mode}); give the bot its own lark-cli configuration in strict mode bot, as docs/006-deployment.md describes."];
573
+ readonly feishuNoBot: readonly ["feishu", "The Feishu bot API did not return the bot's open_id."];
574
+ };
575
+ type SetupCode = keyof typeof SETUP_PROBLEMS;
576
+ interface SetupProblem {
577
+ place: SetupPlace;
578
+ code: SetupCode;
579
+ values: Record<string, string>;
580
+ detail: string;
581
+ }
582
+ //#endregion
583
+ //#region src/app/sessions.d.ts
584
+ declare module '@deepseek-ai/cordis' {
585
+ interface Events {
586
+ /** DSH's agent preset registry selected `agentPreset` for a Session. */
587
+ 'agent-preset/selected'(sessionId: string, agentPreset: string): void;
588
+ }
589
+ }
590
+ //#endregion
591
+ //#region src/sources/github-pull.d.ts
592
+ declare const PullSchema: ZodObject<{
593
+ title: ZodOptional<ZodString>;
594
+ state: ZodString;
595
+ html_url: ZodString;
596
+ user: ZodPipe<ZodNullable<ZodObject<{
597
+ login: ZodString;
598
+ type: ZodOptional<ZodString>;
599
+ }, $loose>>, ZodTransform<{
600
+ [x: string]: unknown;
601
+ login: string;
602
+ type?: string | undefined;
603
+ }, {
604
+ [x: string]: unknown;
605
+ login: string;
606
+ type?: string | undefined;
607
+ } | null>>;
608
+ body: ZodOptional<ZodNullable<ZodString>>;
609
+ created_at: ZodOptional<ZodString>;
610
+ merged: ZodOptional<ZodBoolean>;
611
+ merged_at: ZodOptional<ZodNullable<ZodString>>;
612
+ closed_at: ZodOptional<ZodNullable<ZodString>>;
613
+ auto_merge: ZodOptional<ZodUnknown>;
614
+ head: ZodObject<{
615
+ sha: ZodString;
616
+ ref: ZodString;
617
+ repo: ZodOptional<ZodNullable<ZodObject<{
618
+ full_name: ZodString;
619
+ }, $loose>>>;
620
+ }, $loose>;
621
+ }, $loose>;
622
+ type Pull = output<typeof PullSchema> & {
623
+ number: number;
624
+ };
625
+ //#endregion
626
+ //#region src/sources/github-trigger.d.ts
627
+ /**
628
+ * A GitHub comment or review; a review carries `state` and `commit_id`, and an inline review comment carries its file,
629
+ * line, diff hunk, and `in_reply_to_id` (the root comment ID of its review thread).
630
+ */
631
+ declare const CommentSchema: ZodObject<{
632
+ id: ZodNumber;
633
+ body: ZodOptional<ZodNullable<ZodString>>;
634
+ user: ZodPipe<ZodNullable<ZodObject<{
635
+ login: ZodString;
636
+ type: ZodOptional<ZodString>;
637
+ }, $loose>>, ZodTransform<{
638
+ [x: string]: unknown;
639
+ login: string;
640
+ type?: string | undefined;
641
+ }, {
642
+ [x: string]: unknown;
643
+ login: string;
644
+ type?: string | undefined;
645
+ } | null>>;
646
+ html_url: ZodOptional<ZodNullable<ZodString>>;
647
+ created_at: ZodOptional<ZodNullable<ZodString>>;
648
+ updated_at: ZodOptional<ZodNullable<ZodString>>;
649
+ submitted_at: ZodOptional<ZodNullable<ZodString>>;
650
+ state: ZodOptional<ZodNullable<ZodString>>;
651
+ commit_id: ZodOptional<ZodNullable<ZodString>>;
652
+ path: ZodOptional<ZodNullable<ZodString>>;
653
+ line: ZodOptional<ZodNullable<ZodNumber>>;
654
+ original_line: ZodOptional<ZodNullable<ZodNumber>>;
655
+ diff_hunk: ZodOptional<ZodNullable<ZodString>>;
656
+ in_reply_to_id: ZodOptional<ZodNullable<ZodNumber>>;
657
+ }, $loose>;
658
+ type GithubComment = output<typeof CommentSchema>;
659
+ interface PullRef {
660
+ number: number;
661
+ isPr: boolean;
662
+ url?: string;
663
+ prAuthor?: string;
664
+ }
665
+ /** Builds a trigger for a comment or review; text is empty for a bodyless comment or a `COMMENTED` review without a body. */
666
+ declare function commentTrigger(comment: GithubComment, ref: PullRef, kind: 'conversation' | 'inline' | 'review', agent: string): Trigger;
667
+ //#endregion
668
+ //#region src/sources/github.d.ts
669
+ declare const GithubConfigSchema: ZodObject<{
670
+ repository: ZodDefault<ZodString>;
671
+ cli: ZodDefault<ZodString>;
672
+ pollSeconds: ZodDefault<ZodNumber>;
673
+ failuresBeforeError: ZodDefault<ZodNumber>;
674
+ observeIssues: ZodDefault<ZodBoolean>;
675
+ observePulls: ZodDefault<ZodBoolean>;
676
+ observeComments: ZodDefault<ZodBoolean>;
677
+ observeCi: ZodDefault<ZodBoolean>;
678
+ }, $strict>;
679
+ type GithubConfig = output<typeof GithubConfigSchema>;
680
+ declare const githubKind: SourceKind<GithubConfig>;
681
+ declare const name = "dsh-superagent-github";
682
+ declare const inject: string[];
683
+ declare function apply(ctx: Context): void;
684
+ /** Returns an error health once `failures` consecutive polls fail, or undefined so a single network interruption stays quiet. */
685
+ declare function pollFailure(failures: number, threshold: number, error: unknown): Health | undefined;
686
+ interface Round {
687
+ started: string;
688
+ signal?: AbortSignal | undefined;
689
+ pulls: Map<number, Promise<Pull>>;
690
+ read: Set<number>;
691
+ failures: string[];
692
+ dropped: number[];
693
+ abandoned: number[];
694
+ tally: Tally;
695
+ }
696
+ interface Retry {
697
+ since: string;
698
+ pr: boolean;
699
+ failedAt?: string;
700
+ attempts?: number;
701
+ }
702
+ /**
703
+ * One polling round: notifications, then observed repository streams, then the PRs of open tickets with their CI, then
704
+ * subscribed Threads. Each step and each Issue, PR, or Thread fails independently so all steps run before the round fails.
705
+ * Other read failures (including 404) fail the round toward the error threshold, whereas deleted (410) or abandoned
706
+ * (24h+) threads are recorded only on the thread and in health detail.
707
+ * @returns the polling interval requested by GitHub, in seconds.
708
+ */
709
+ declare function pollRound(ctx: SourceContext, signal?: AbortSignal): Promise<number>;
710
+ declare function pollTicketPulls(ctx: SourceContext, signal?: AbortSignal, round?: Round): Promise<void>;
711
+ /** Polls subscribed Issue and PR Threads not already read in this round; a deleted (410) Issue is still polled within the horizon (costing one read) and does not fail the round. */
712
+ declare function pollThreads(ctx: SourceContext, signal?: AbortSignal, round?: Round): Promise<void>;
713
+ //#endregion
714
+ //#region src/kv.d.ts
715
+ /** Key of a KV record whose value has type `V`; a plain string represents an untyped key. */
716
+ type Key<V> = string & {
717
+ readonly __value?: V;
718
+ };
719
+ /** Family of KV records sharing a prefix: callable to build a key from its name parts, and exposing `prefix` for listing. */
720
+ type Family<V, A extends unknown[]> = ((...name: A) => Key<V>) & {
721
+ readonly prefix: string;
722
+ };
723
+ //#endregion
724
+ //#region src/sources/host.d.ts
725
+ /** Fixed English health templates (`{name}` placeholders); the panel localizes each `code` in the interface language. */
726
+ declare const HEALTH_TEXT: {
727
+ readonly setupPending: "Waiting for the deployment check";
728
+ readonly sourceOff: "Off";
729
+ readonly feishuCliUnset: "The Source is on, and its bot lark-cli is not set";
730
+ readonly feishuBotMissing: "Waiting for the Feishu bot";
731
+ readonly pollFailures: "{count} consecutive failed polls; last: {error}";
732
+ };
733
+ type HealthCode = keyof typeof HEALTH_TEXT;
734
+ type Health = {
735
+ state: 'starting' | 'ready' | 'paused' | 'error';
736
+ detail: string;
737
+ at?: string;
738
+ code?: HealthCode;
739
+ values?: Record<string, string>;
740
+ };
741
+ interface SourceHost {
742
+ readonly sources: SourceRegistry;
743
+ /** Returns the context for one Source kind; its `report` writes only the health entries declared by the kind. */
744
+ context(kind: {
745
+ kind: string;
746
+ health: readonly string[];
747
+ }, instance?: string): SourceContext;
748
+ }
749
+ /** Display label, URL, and facts (`null` removes a fact) that a Source publishes on a Thread. */
750
+ interface ThreadDescription {
751
+ label?: string;
752
+ url?: string;
753
+ facts?: Record<string, ThreadFact | null>;
754
+ }
755
+ /** Application capabilities exposed to a Source kind for reading state, ingesting triggers, managing threads/tickets, and reporting health. */
756
+ interface SourceContext {
757
+ /** This instance's Source id: the kind for its default instance, otherwise the configured instance id. */
758
+ readonly source: string;
759
+ readonly deployment: Deployment;
760
+ readonly commands: Commands;
761
+ readonly ready: Promise<void>;
762
+ /** True once setup resolved the repository and accounts; Sources poll only then. */
763
+ configured(): boolean;
764
+ /** Setup problem keeping this Source's account from running; only the Feishu bot check reports one. */
765
+ readonly problem?: SetupProblem | undefined;
766
+ /** Returns a Source's configuration while enabled, or undefined while disabled or uninstalled. */
767
+ config<C extends Record<string, unknown>>(kind: string): C | undefined;
768
+ /** Ingests a trigger into the Engine and schedules the next evaluation pass; callers should await completion before advancing read cursors. */
769
+ receive(trigger: Trigger): ReceiveResult | Promise<ReceiveResult>;
770
+ atomic<T>(work: () => T): T;
771
+ /** Source-scoped KV records (such as read cursors); setting `undefined` removes an entry. */
772
+ state: {
773
+ get<V>(key: Key<V>): V | undefined;
774
+ set<V>(key: Key<V>, value: V | undefined): void;
775
+ keys<V>(family: Family<V, never>): Key<V>[];
776
+ };
777
+ threads: {
778
+ get(key: string): Thread | undefined;
779
+ subscribed(source: string): Thread[];
780
+ describe(key: string, description: ThreadDescription): void;
781
+ /** Sets or removes (`undefined`) keys in a Thread's `meta` after rereading it; a missing Thread is left alone. */
782
+ patch(key: string, meta: Record<string, unknown>): void;
783
+ };
784
+ tickets: {
785
+ get(id: string): Ticket | undefined;
786
+ /** Open tickets, newest first. */
787
+ open(): Ticket[];
788
+ /** Binds an open ticket to follow a Source Thread (`own` when opened by the ticket) so the Thread's close, not a ready report, ends the ticket. */
789
+ bindThread(id: string, thread: ThreadRef, own: boolean): void;
790
+ /** Reports that a followed Thread closed at `at`; each open ticket following it ends once no `own` Thread remains open and no resumed work is still running. */
791
+ threadClosed(thread: ThreadRef, outcome: 'merged' | 'closed', at: string): void;
792
+ };
793
+ triggers: {
794
+ get(id: string): Trigger | undefined; /** The newest Trigger on a Thread. */
795
+ latest(thread: string): Trigger | undefined;
796
+ };
797
+ notify(message: OutboundMessage): void;
798
+ /** Reports the state of one of this kind's declared health entries; throws for undeclared entry names. */
799
+ report(entry: string, health: Health): void;
800
+ }
801
+ //#endregion
802
+ //#region src/sources/kind.d.ts
803
+ interface Localized {
804
+ zh: string;
805
+ en: string;
806
+ }
807
+ /** `advanced` folds a rarely changed field (such as a polling tunable) behind the card's Advanced section. */
808
+ interface FieldBase {
809
+ key: string;
810
+ label: Localized;
811
+ hint?: Localized;
812
+ advanced?: true;
813
+ }
814
+ /**
815
+ * Configuration field specification; `rows` edits a list of records keyed by its first column, `choose` picks from
816
+ * resolved source labels, and `fact` displays a read-only value from `facts`.
817
+ */
818
+ type FieldSpec = FieldBase & {
819
+ type: 'switch';
820
+ } | FieldBase & {
821
+ type: 'select';
822
+ options: {
823
+ value: string;
824
+ label: Localized;
825
+ }[];
826
+ } | FieldBase & {
827
+ type: 'number';
828
+ min: number;
829
+ max: number;
830
+ } | FieldBase & {
831
+ type: 'text';
832
+ pattern?: string;
833
+ readonly?: boolean;
834
+ choose?: Localized;
835
+ } | FieldBase & {
836
+ type: 'fact';
837
+ settings?: 'deployment';
838
+ } | FieldBase & {
839
+ type: 'rows';
840
+ columns: ({
841
+ key: string;
842
+ label: Localized;
843
+ type: 'text';
844
+ pattern?: string;
845
+ optional?: boolean;
846
+ choose?: Localized;
847
+ refresh?: Localized;
848
+ } | {
849
+ key: string;
850
+ label: Localized;
851
+ type: 'select';
852
+ options: {
853
+ value: string;
854
+ label: Localized;
855
+ }[];
856
+ })[];
857
+ };
858
+ interface VariableSpec {
859
+ key: string;
860
+ description: Localized;
861
+ }
862
+ interface EnvironmentInput<C> {
863
+ deployment: Deployment;
864
+ config: C;
865
+ trigger?: Trigger;
866
+ }
867
+ interface AdmissionRowView {
868
+ id: string;
869
+ label: Localized | string;
870
+ note: Localized;
871
+ cells: {
872
+ listedUnaddressed: boolean;
873
+ unlistedAddressed: boolean;
874
+ unlistedUnaddressed: boolean;
875
+ };
876
+ }
877
+ /** Policy extension for a source kind, defining allowed senders, admission table rows, and optional external roster sync. */
878
+ interface SourcePolicyPart<P extends Record<string, unknown>> {
879
+ /** Validates the Source's part of the Policy, including `allowed` (senders who may originate work). */
880
+ schema: ZodType<P>;
881
+ /** Form fields of the policy part; the first is `allowed`. */
882
+ fields: FieldSpec[];
883
+ /** Describes what the Source marks as addressed to the agent, which an allowed sender's explicit request requires. */
884
+ explicit: Localized;
885
+ /** Fallback display labels for unlisted human or bot senders when raw sender IDs are not human-readable. */
886
+ unnamed?: {
887
+ person: Localized;
888
+ bot: Localized;
889
+ };
890
+ /** Receiving scopes of the Policy's admission table under `config` (matching `scope().row`); kinds without `rows` use the table's defaults. */
891
+ rows?(config: Record<string, unknown>): AdmissionRowView[];
892
+ /** Optional external roster sync (such as chat members); `ready` reports whether `part` names a target to refresh from. */
893
+ sync?: {
894
+ label: Localized;
895
+ ready(part: P): boolean;
896
+ run(host: SourceHost, part: P, signal: AbortSignal): Promise<P>;
897
+ };
898
+ }
899
+ /** UI link for a channel address; `triggerId` names the Trigger whose own deep link is preferred when available. */
900
+ interface ChannelLink {
901
+ url: string;
902
+ label: Localized;
903
+ triggerId?: string;
904
+ }
905
+ type ChannelLinks = Partial<Pick<Deployment, 'repository' | 'feishu'>>;
906
+ /** Outbound messaging adapter for a source kind's threads. */
907
+ /** A message already delivered to the same conversation, carrying the moment it went out; the receipt it comes from is the only proof of delivery. */
908
+ type DeliveredMessage = OutboundMessage & {
909
+ sentAt?: string;
910
+ };
911
+ interface SourceChannel<C> {
912
+ /** Whether a reply may still go to `address`; without it, every address may receive replies. */
913
+ allowed?(address: Record<string, string>, config: C): boolean;
914
+ /**
915
+ * Sends a message idempotently by ID; returns `'gone'` when the target conversation no longer accepts replies.
916
+ * @param delivered - messages of the same conversation already settled as sent, oldest first, excluding this one.
917
+ * A channel whose record is a local file may render that record from `delivered` plus `message`, so content written
918
+ * outside the pipeline cannot survive the next delivery. Channels that post to a remote thread ignore it.
919
+ * @throws when delivery failed but may succeed on a later retry.
920
+ */
921
+ send(host: Pick<SourceContext, 'commands'>, message: OutboundMessage, delivered?: readonly DeliveredMessage[]): Promise<'sent' | 'gone'>;
922
+ /** Returns the URL and label for `address`; `url` is empty when `links` lack the required deployment info. */
923
+ link(address: Record<string, string>, links: ChannelLinks): ChannelLink;
924
+ }
925
+ /** Normalized message returned by thread context readers; `bot` marks a non-human sender whose message can never authorize work on its own (at most an inferred candidate). */
926
+ interface ContextMessage {
927
+ id: string;
928
+ from: string;
929
+ at: string;
930
+ text: string;
931
+ bot?: true;
932
+ deleted?: true;
933
+ reply_to?: string;
934
+ url?: string;
935
+ path?: string;
936
+ line?: number;
937
+ }
938
+ type ContextPartName = 'thread' | 'root' | 'parent';
939
+ interface ContextPart {
940
+ messages: ContextMessage[];
941
+ next?: string | undefined;
942
+ body: Record<string, unknown>;
943
+ status?: string;
944
+ }
945
+ /** Bounded thread context reader used by assessments to inspect messages and images around a trigger. */
946
+ interface ThreadContext<C> {
947
+ /** The ID of the Trigger's own message among the messages of its Thread. */
948
+ messageId(trigger: Trigger): string;
949
+ /** Reads a page of thread messages (`thread`, first page when `cursor` is omitted), the topic root (`root`), or the replied-to message (`parent`). */
950
+ read(commands: Commands, trigger: Trigger, part: ContextPartName, cursor: string | undefined, config: C): Promise<ContextPart>;
951
+ /** Extracts image keys from message text that `image` can read; omitted for kinds without image support. */
952
+ images?(text: string): string[];
953
+ /** Reads one image of a message in the Trigger's Thread as an attachment for `agent`. */
954
+ image?(agent: Agent, commands: Commands, trigger: Trigger, message: {
955
+ id: string;
956
+ text: string;
957
+ }, key: string, stateDir: string, signal: AbortSignal): Promise<unknown>;
958
+ }
959
+ interface TriggerContext {
960
+ readonly messageId: string;
961
+ read(commands: Commands, part: ContextPartName, cursor?: string): Promise<ContextPart>;
962
+ images(text: string): string[];
963
+ /** @throws for a kind without image support. */
964
+ image(agent: Agent, commands: Commands, message: {
965
+ id: string;
966
+ text: string;
967
+ }, key: string, stateDir: string, signal: AbortSignal): Promise<unknown>;
968
+ }
969
+ /** Pluggable source kind descriptor registered with SourceRegistry. */
970
+ interface SourceKind<C extends Record<string, unknown> = Record<string, unknown>> {
971
+ /** Stable ID; a default instance with the same ID exists when none is stored. */
972
+ kind: string;
973
+ title: Localized;
974
+ description: Localized;
975
+ /** Read-only status facts derived from `deployment` (undefined while waiting for setup), keyed by field key. */
976
+ facts?(deployment: Deployment | undefined): Record<string, Localized | string>;
977
+ /** Validates stored and submitted configuration and fills defaults. */
978
+ schema: ZodType<C>;
979
+ fields: FieldSpec[];
980
+ /** Health entry names owned by this kind under `health[...]`; no other kind or core loop may report them. */
981
+ health: string[];
982
+ /** Listening rule for a trigger (or recorded Mandate basis) of this kind; kinds without `scope` listen to everything they produce and observe none of it. */
983
+ scope?(input: {
984
+ meta: Record<string, unknown>;
985
+ }, config: C): ScopeResult;
986
+ /** Outbound reply adapter; kinds without `channel` produce no replies or channel checks. */
987
+ channel?: SourceChannel<C>;
988
+ /** Bounded context reader for assessments; assessments of a kind without `threadContext` read none. */
989
+ threadContext?: ThreadContext<C>;
990
+ /** Maps a search query to candidate Thread keys (such as `github:12`) and Trigger search terms (such as a Feishu `om_` ID). */
991
+ find?(query: string): {
992
+ threads: string[];
993
+ terms: string[];
994
+ };
995
+ /** Returns the ID of the Trigger whose message this Trigger replies to, when derivable without a network read. */
996
+ repliesTo?(trigger: Trigger): string | undefined;
997
+ /** Policy section for kinds whose senders have their own identity. */
998
+ policy?: SourcePolicyPart<Record<string, unknown> & {
999
+ allowed: {
1000
+ id: string;
1001
+ name?: string;
1002
+ }[];
1003
+ }>;
1004
+ /** Rereads display names for row keys (such as chat names), stores the resolved names in `KV.sources.labels(kind)`, and returns them. */
1005
+ refreshLabels?(host: SourceHost, signal?: AbortSignal): Promise<Record<string, string>>;
1006
+ /** Variables the kind registers with the execution environment and how their values are computed. */
1007
+ environment?: {
1008
+ variables: readonly VariableSpec[];
1009
+ values(input: EnvironmentInput<C>): Record<string, string>;
1010
+ };
1011
+ }
1012
+ interface SourceInstance<C extends Record<string, unknown> = Record<string, unknown>> {
1013
+ id: string;
1014
+ kind: string;
1015
+ enabled: boolean;
1016
+ config: C;
1017
+ }
1018
+ //#endregion
1019
+ export { Tally as _, Retry as a, inject as c, pollRound as d, pollThreads as f, SourceRegistry as g, commentTrigger as h, GithubConfig as i, name as l, GithubComment as m, SourceKind as n, apply as o, pollTicketPulls as p, SourceContext as r, githubKind as s, DeliveredMessage as t, pollFailure as u };