@toddzheng024/dscode-bundle 0.3.0 → 0.5.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 (113) hide show
  1. package/THIRD_PARTY_NOTICES.md +15 -0
  2. package/cordis.patch.yml +5 -3
  3. package/package.json +14 -1
  4. package/plugins/clipboard-image/clipboard-image.swift +56 -0
  5. package/plugins/clipboard-image/index.mjs +70 -0
  6. package/plugins/code-review/git.mjs +95 -0
  7. package/plugins/code-review/index.mjs +88 -0
  8. package/plugins/dscode/index.mjs +17 -3
  9. package/plugins/email/cli.mjs +32 -0
  10. package/plugins/email/contacts.mjs +36 -0
  11. package/plugins/email/gmail-oauth.mjs +69 -0
  12. package/plugins/email/gmail-store.mjs +2 -0
  13. package/plugins/email/gmail.mjs +194 -0
  14. package/plugins/email/imap.mjs +136 -0
  15. package/plugins/email/inbox.d.mts +25 -0
  16. package/plugins/email/inbox.mjs +76 -0
  17. package/plugins/email/smtp.mjs +69 -0
  18. package/plugins/email/store.mjs +32 -0
  19. package/plugins/email-tools/index.mjs +44 -0
  20. package/plugins/session-metrics/index.mjs +6 -2
  21. package/plugins/session-metrics/rate.mjs +62 -0
  22. package/plugins/session-metrics/view.mjs +15 -9
  23. package/plugins/tui-tools/doctor-cli.mjs +22 -0
  24. package/plugins/tui-tools/doctor.mjs +141 -0
  25. package/plugins/tui-tools/index.mjs +14 -6
  26. package/plugins/ultra/policy.mjs +12 -1
  27. package/plugins/worktree-subagent/worktree.mjs +50 -0
  28. package/presets/dscode/agent.cordis.yml +7 -2
  29. package/vendor/deepseek/index.js +12 -2
  30. package/vendor/subagent/index.js +29 -9
  31. package/vendor/subagent-core/LICENSE +21 -0
  32. package/vendor/subagent-core/index.js +3232 -0
  33. package/vendor/subagent-core/invariant.js +76 -0
  34. package/vendor/subagent-core/typert.host.d.ts +3 -0
  35. package/vendor/subagent-core/typert.host.js +964 -0
  36. package/vendor/subagent-core/typert.remote-client.d.ts +27 -0
  37. package/vendor/subagent-core/typert.remote-client.js +160 -0
  38. package/vendor/subagent-core/types/assistant-output.d.ts +48 -0
  39. package/vendor/subagent-core/types/assistant-output.js +73 -0
  40. package/vendor/subagent-core/types/catalog.d.ts +77 -0
  41. package/vendor/subagent-core/types/catalog.js +103 -0
  42. package/vendor/subagent-core/types/child-agent.d.ts +150 -0
  43. package/vendor/subagent-core/types/child-agent.js +207 -0
  44. package/vendor/subagent-core/types/client.d.ts +8 -0
  45. package/vendor/subagent-core/types/client.js +7 -0
  46. package/vendor/subagent-core/types/continuation-activation.d.ts +251 -0
  47. package/vendor/subagent-core/types/continuation-activation.js +663 -0
  48. package/vendor/subagent-core/types/continuation-messages.d.ts +62 -0
  49. package/vendor/subagent-core/types/continuation-messages.js +102 -0
  50. package/vendor/subagent-core/types/continuation.d.ts +124 -0
  51. package/vendor/subagent-core/types/continuation.js +455 -0
  52. package/vendor/subagent-core/types/control-types.d.ts +146 -0
  53. package/vendor/subagent-core/types/control-types.js +9 -0
  54. package/vendor/subagent-core/types/control.d.ts +71 -0
  55. package/vendor/subagent-core/types/control.js +116 -0
  56. package/vendor/subagent-core/types/depth.d.ts +31 -0
  57. package/vendor/subagent-core/types/depth.js +39 -0
  58. package/vendor/subagent-core/types/descriptor.d.ts +144 -0
  59. package/vendor/subagent-core/types/descriptor.js +193 -0
  60. package/vendor/subagent-core/types/error.d.ts +11 -0
  61. package/vendor/subagent-core/types/error.js +14 -0
  62. package/vendor/subagent-core/types/inbox.d.ts +43 -0
  63. package/vendor/subagent-core/types/inbox.js +61 -0
  64. package/vendor/subagent-core/types/index.d.ts +316 -0
  65. package/vendor/subagent-core/types/index.js +511 -0
  66. package/vendor/subagent-core/types/internal.d.ts +58 -0
  67. package/vendor/subagent-core/types/internal.js +58 -0
  68. package/vendor/subagent-core/types/invariant.d.ts +13 -0
  69. package/vendor/subagent-core/types/invariant.js +91 -0
  70. package/vendor/subagent-core/types/lifecycle.d.ts +113 -0
  71. package/vendor/subagent-core/types/lifecycle.js +178 -0
  72. package/vendor/subagent-core/types/list-children.d.ts +65 -0
  73. package/vendor/subagent-core/types/list-children.js +381 -0
  74. package/vendor/subagent-core/types/out-of-process.d.ts +118 -0
  75. package/vendor/subagent-core/types/out-of-process.js +219 -0
  76. package/vendor/subagent-core/types/projection-types.d.ts +74 -0
  77. package/vendor/subagent-core/types/projection-types.js +7 -0
  78. package/vendor/subagent-core/types/projection.d.ts +95 -0
  79. package/vendor/subagent-core/types/projection.js +151 -0
  80. package/vendor/subagent-core/types/run-settlement.d.ts +17 -0
  81. package/vendor/subagent-core/types/run-settlement.js +70 -0
  82. package/vendor/subagent-core/types/types.d.ts +377 -0
  83. package/vendor/subagent-core/types/types.js +19 -0
  84. package/vendor/subagent-driver/LICENSE +21 -0
  85. package/vendor/subagent-driver/index.js +255 -0
  86. package/vendor/subagent-driver/types/index.d.ts +33 -0
  87. package/vendor/subagent-driver/types/structured.d.ts +42 -0
  88. package/vendor/subagent-fork/LICENSE +21 -0
  89. package/vendor/subagent-fork/index.js +61 -0
  90. package/vendor/subagent-fork/types/index.d.ts +20 -0
  91. package/vendor/subagent-spawn/LICENSE +21 -0
  92. package/vendor/subagent-spawn/index.js +45 -0
  93. package/vendor/subagent-spawn/types/index.d.ts +19 -0
  94. package/vendor/terminal/LICENSE +21 -0
  95. package/vendor/terminal/index.js +1013 -0
  96. package/vendor/terminal/types/config.d.ts +71 -0
  97. package/vendor/terminal/types/index.d.ts +36 -0
  98. package/vendor/terminal/types/sanitize.d.ts +47 -0
  99. package/vendor/terminal/types/session.d.ts +87 -0
  100. package/vendor/tui/dscode-clipboard-image/clipboard-image.swift +56 -0
  101. package/vendor/tui/dscode-clipboard-image/index.mjs +70 -0
  102. package/vendor/tui/dscode-email/cli.mjs +32 -0
  103. package/vendor/tui/dscode-email/contacts.mjs +36 -0
  104. package/vendor/tui/dscode-email/gmail-oauth.mjs +69 -0
  105. package/vendor/tui/dscode-email/gmail-store.mjs +2 -0
  106. package/vendor/tui/dscode-email/gmail.mjs +194 -0
  107. package/vendor/tui/dscode-email/imap.mjs +136 -0
  108. package/vendor/tui/dscode-email/inbox.d.mts +25 -0
  109. package/vendor/tui/dscode-email/inbox.mjs +76 -0
  110. package/vendor/tui/dscode-email/smtp.mjs +69 -0
  111. package/vendor/tui/dscode-email/store.mjs +32 -0
  112. package/vendor/tui/dscode-email.mjs +69 -0
  113. package/vendor/tui/index.mjs +473 -82
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Model-visible messages owned by continuable-subagent orchestration.
3
+ *
4
+ * @module @deepseek-ai/dsh-subagent/continuation-messages
5
+ */
6
+ import type { Agent } from '@deepseek-ai/dsh-agent';
7
+ import { createUserMessage } from '@deepseek-ai/dsh-llm';
8
+ import type { ContentBlock } from '@deepseek-ai/dsh-llm';
9
+ import type { SessionId } from '@deepseek-ai/dsh-session';
10
+ import type { ActivationTerminal } from './lifecycle.ts';
11
+ /** Durable attribution for one model-authored message between adjacent Agents. */
12
+ export interface AgentMessageSource {
13
+ readonly kind: 'agent-message';
14
+ /** A message another agent addressed to this one (`relay` context form). */
15
+ readonly form: 'relay';
16
+ /** Session id of the Agent whose tool call produced the message. */
17
+ readonly senderSessionId: SessionId;
18
+ }
19
+ /**
20
+ * Durable attribution for the runtime's own account of a continuable child
21
+ * settling. Deliberately a different kind from
22
+ * {@link AgentMessageSource}: an Agent message is content the sender chose,
23
+ * while this message is the manager stating what became of the child, and a
24
+ * transcript that merged them would credit the child with words it never wrote.
25
+ */
26
+ export interface SubagentSettledMessageSource {
27
+ readonly kind: 'subagent-settled';
28
+ /** A runtime account shown without expanding the row (`notice` context form). */
29
+ readonly form: 'notice';
30
+ /** One-line account of how the child ended. */
31
+ readonly summary: string;
32
+ /** Session id of the child that settled. */
33
+ readonly senderSessionId: SessionId;
34
+ }
35
+ declare module '@deepseek-ai/dsh-llm' {
36
+ interface MessageSourceMap {
37
+ 'agent-message': AgentMessageSource;
38
+ 'subagent-settled': SubagentSettledMessageSource;
39
+ }
40
+ }
41
+ /**
42
+ * Build the model-visible and durable representation of one adjacent-Agent message.
43
+ * @param sender - exact live Agent that authored the message.
44
+ * @param content - model-visible message blocks supplied by the sender.
45
+ * @returns the durable user-message representation delivered to the recipient.
46
+ */
47
+ export declare function createAgentMessage(sender: Agent, content: ContentBlock[]): ReturnType<typeof createUserMessage>;
48
+ /**
49
+ * Append adjacent-Agent return guidance to a continuable child's initial task.
50
+ * @param parentId - durable parent session id named in the guidance.
51
+ * @param prompt - initial model-visible task blocks.
52
+ * @returns task blocks followed by the continuable return guidance.
53
+ */
54
+ export declare function withContinuableReturnGuidance(parentId: SessionId, prompt: ContentBlock[]): ContentBlock[];
55
+ /**
56
+ * Build the runtime-owned settlement notice delivered to a child's parent.
57
+ * @param childId - durable child session id named in the notice.
58
+ * @param terminal - recorded terminal state for the settled Activation.
59
+ * @returns the durable user-message representation delivered to the parent.
60
+ */
61
+ export declare function createSettlementMessage(childId: SessionId, terminal: ActivationTerminal): ReturnType<typeof createUserMessage>;
62
+ //# sourceMappingURL=continuation-messages.d.ts.map
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Model-visible messages owned by continuable-subagent orchestration.
3
+ *
4
+ * @module @deepseek-ai/dsh-subagent/continuation-messages
5
+ */
6
+ import { boundContextSummary, createUserMessage } from '@deepseek-ai/dsh-llm';
7
+ /** Build durable attribution for one adjacent-Agent message. */
8
+ function agentMessageSource(sender) {
9
+ return {
10
+ kind: 'agent-message',
11
+ form: 'relay',
12
+ senderSessionId: sender.id,
13
+ };
14
+ }
15
+ /**
16
+ * Build the model-visible and durable representation of one adjacent-Agent message.
17
+ * @param sender - exact live Agent that authored the message.
18
+ * @param content - model-visible message blocks supplied by the sender.
19
+ * @returns the durable user-message representation delivered to the recipient.
20
+ */
21
+ export function createAgentMessage(sender, content) {
22
+ return createUserMessage({
23
+ content: [
24
+ { type: 'text', text: `Agent ${sender.id} sent a message: ` },
25
+ ...content,
26
+ ],
27
+ source: agentMessageSource(sender),
28
+ });
29
+ }
30
+ /**
31
+ * Append adjacent-Agent return guidance to a continuable child's initial task.
32
+ * @param parentId - durable parent session id named in the guidance.
33
+ * @param prompt - initial model-visible task blocks.
34
+ * @returns task blocks followed by the continuable return guidance.
35
+ */
36
+ export function withContinuableReturnGuidance(parentId, prompt) {
37
+ const encodedParentId = JSON.stringify(parentId);
38
+ return [
39
+ ...prompt,
40
+ {
41
+ type: 'text',
42
+ text: `Your parent agent id is ${encodedParentId}. Before you finish, send your result to that agent with `
43
+ + `send_message({ agent_id: ${encodedParentId}, message: "<self-contained result>" }). The parent shares `
44
+ + 'your workspace but does not automatically receive your transcript, tool output, or reasoning. Send '
45
+ + 'earlier messages as well when a finding changes what the parent should do next; sending a message '
46
+ + 'does not end your turn.',
47
+ },
48
+ ];
49
+ }
50
+ /**
51
+ * One line telling a parent that a background child is finished and why, in
52
+ * the parent's own task vocabulary.
53
+ * @param childId - the durable child the parent knows by id.
54
+ * @param stopReason - how the child's last ordinary turn ended.
55
+ * @returns the model-facing opening line of the settlement notice.
56
+ */
57
+ function settlementSummary(childId, stopReason) {
58
+ const subject = `Background subagent ${childId}`;
59
+ switch (stopReason) {
60
+ case 'completed':
61
+ return `${subject} finished and will do no further work unless you send it more.`;
62
+ case 'aborted':
63
+ return `${subject} was stopped before it finished.`;
64
+ case 'max-tokens':
65
+ return `${subject} ran out of room before it finished.`;
66
+ // A pre-step rejection — a hook deny, a policy plugin — discarded input
67
+ // the child had claimed, so the parent must not treat the task as done.
68
+ case 'refusal':
69
+ return `${subject} declined the task.`;
70
+ case 'error':
71
+ return `${subject} failed before it finished.`;
72
+ /* v8 ignore next 4 -- `SubagentResult['stopReason']` is merge-extensible, so this arm
73
+ * needs a backend that adds a variant; an unnameable ending is reported as unfinished
74
+ * rather than silently as success. */
75
+ default:
76
+ return `${subject} ended abnormally (${String(stopReason)}) before it finished.`;
77
+ }
78
+ }
79
+ /**
80
+ * Build the runtime-owned settlement notice delivered to a child's parent.
81
+ * @param childId - durable child session id named in the notice.
82
+ * @param terminal - recorded terminal state for the settled Activation.
83
+ * @returns the durable user-message representation delivered to the parent.
84
+ */
85
+ export function createSettlementMessage(childId, terminal) {
86
+ const summary = settlementSummary(childId, terminal.stopReason);
87
+ return createUserMessage({
88
+ content: [
89
+ { type: 'text', text: summary },
90
+ ...terminal.output === undefined
91
+ ? [{ type: 'text', text: 'It left no closing message.' }]
92
+ : [{ type: 'text', text: 'Its closing message:' }, ...terminal.output],
93
+ ],
94
+ source: {
95
+ kind: 'subagent-settled',
96
+ form: 'notice',
97
+ summary: boundContextSummary(summary),
98
+ senderSessionId: childId,
99
+ },
100
+ });
101
+ }
102
+ //# sourceMappingURL=continuation-messages.js.map
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Continuable-subagent orchestration behind `ctx.subagents`: stable child ids,
3
+ * descriptor persistence, provider preparation, cold resume, authorization,
4
+ * and message routing. {@link ContinuableActivationRegistry} owns the mutable
5
+ * process-local Activation graph and its settlement and disposal lifecycle.
6
+ *
7
+ * A continuable child has one durable Session and at most one process-local
8
+ * Activation. The Agent inbox is the only turn queue, so this manager owns
9
+ * durable orchestration while the Agent loop owns all turn ordering and
10
+ * execution. No continuable path creates a Task or an intermediate
11
+ * result-bearing wrapper.
12
+ *
13
+ * @module @deepseek-ai/dsh-subagent
14
+ */
15
+ import type { Context } from '@deepseek-ai/cordis';
16
+ import type { Agent } from '@deepseek-ai/dsh-agent';
17
+ import type { ContentBlock, MessageId, MessageSource } from '@deepseek-ai/dsh-llm';
18
+ import type { SessionId } from '@deepseek-ai/dsh-session';
19
+ import type { ActivationObserver } from './lifecycle.ts';
20
+ import type { ContinuableCreateRequest, ContinuableCreateSpec, ContinuableStart, ContinuableStartSpec, SubagentInterruptAuthority, SubagentSendMessageOptions } from './types.ts';
21
+ /** Package-private hooks supplied by the owning service. */
22
+ interface ContinuationHost {
23
+ /** Resolve one provider's detached continuable-creation contribution. */
24
+ prepareContinuable(name: string, request: ContinuableCreateRequest): Promise<ContinuableCreateSpec>;
25
+ /** Build the lifecycle observer for one Activation residency epoch. */
26
+ observeActivation(provider: string, childId: SessionId, parent: Agent): ActivationObserver;
27
+ }
28
+ /**
29
+ * The continuable-subagent orchestration service behind `ctx.subagents`. Tool
30
+ * schema and host adapters are consumers of this one contract; foreground
31
+ * one-shot delegation keeps calling `ctx.subagents.start()` and never enters
32
+ * this lifecycle.
33
+ */
34
+ export declare class SubagentContinuationManager {
35
+ private readonly ctx;
36
+ private readonly host;
37
+ private readonly activations;
38
+ constructor(ctx: Context, host: ContinuationHost);
39
+ /**
40
+ * Start one continuable background child and resolve at initial inbox acceptance.
41
+ * Every earlier failure disposes any created handle and rolls back Activation
42
+ * and parent ownership without returning either id.
43
+ * @param spec - provider, delegation request, and caller cancellation.
44
+ * @returns the durable child id and accepted initial prompt message id.
45
+ */
46
+ startContinuable(spec: ContinuableStartSpec): Promise<ContinuableStart>;
47
+ /**
48
+ * Deliver one model-authored message to a direct continuable child or to the
49
+ * sender's direct parent. A missing direct child cold-resumes through the
50
+ * ordinary continuation lifecycle.
51
+ * @param sender - exact live Agent authorizing and originating the message.
52
+ * @param targetId - durable direct-parent or direct-child session id.
53
+ * @param content - model-authored content to deliver.
54
+ * @param options - caller cancellation before acceptance.
55
+ * @returns the accepted message's inbox id.
56
+ */
57
+ sendMessage(sender: Agent, targetId: SessionId, content: ContentBlock[], options: SubagentSendMessageOptions): Promise<MessageId>;
58
+ /**
59
+ * Queue one human-authored prompt as a distinct direct-child turn.
60
+ * @param parent - exact live direct parent authorizing delivery.
61
+ * @param childId - durable direct-child session id.
62
+ * @param content - model-visible prompt blocks.
63
+ * @param source - durable attribution for the human prompt.
64
+ * @param signal - caller cancellation before inbox acceptance.
65
+ * @returns the accepted durable message id.
66
+ */
67
+ queuePrompt(parent: Agent, childId: SessionId, content: ContentBlock[], source: MessageSource, signal: AbortSignal): Promise<MessageId>;
68
+ /**
69
+ * Steer one host-authored prompt to a direct continuable child.
70
+ * @param parent - exact live direct parent authorizing delivery.
71
+ * @param childId - durable direct-child session id.
72
+ * @param content - model-visible prompt blocks.
73
+ * @param source - durable attribution for the host prompt.
74
+ * @param signal - caller cancellation before inbox acceptance.
75
+ * @returns the accepted durable message id.
76
+ */
77
+ steerPrompt(parent: Agent, childId: SessionId, content: ContentBlock[], source: MessageSource, signal: AbortSignal): Promise<MessageId>;
78
+ /** Route one parent-originated delivery through residency and cold resume. */
79
+ private deliverToChild;
80
+ /** The delivery loop behind {@link deliverToChild}, run under the parent hold. */
81
+ private deliverFollowup;
82
+ /**
83
+ * Interrupt one live continuable child's current turn. Admission is
84
+ * synchronous and the cancellation effect is asynchronous. An absent or
85
+ * already-closing target is an accepted no-op after authority checks.
86
+ * @param targetSessionId - the durable child session id to interrupt.
87
+ * @param authority - the human parent address or exact live ancestor Agent.
88
+ */
89
+ interrupt(targetSessionId: SessionId, authority: SubagentInterruptAuthority): void;
90
+ /** Deliver one resident continuable child's message to its live direct parent. */
91
+ private sendToParent;
92
+ /** Send one Agent message while translating only the target's own rejection. */
93
+ private sendAgentMessage;
94
+ /** Close manager-wide admission and release every live Activation. */
95
+ drain(): Promise<void>;
96
+ /**
97
+ * Stop only the continuable descendants of exact live host-owned parents.
98
+ * @param parents - exact live roots whose continuable descendants must stop.
99
+ */
100
+ drainDescendants(parents: readonly Agent[]): Promise<void>;
101
+ /**
102
+ * Release selected resident direct children of one exact live parent.
103
+ * @param parent - exact live direct parent authorizing the selected release.
104
+ * @param childIds - durable direct-child ids to release when resident.
105
+ */
106
+ drainChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
107
+ /**
108
+ * Cold-resume a persisted child and submit the waiting turn. The descriptor
109
+ * supplies every reconstruction input; no subagent provider is dispatched.
110
+ */
111
+ private coldResume;
112
+ /** Admit a materialized child, commit its creation fact, and release it on failure. */
113
+ private submitMaterialized;
114
+ /** Build and submit one message across the final synchronous admission cutoff. */
115
+ private submitAdmitted;
116
+ /** Refuse image content for a child whose fixed model accepts text only. */
117
+ private assertImageCapable;
118
+ /** Resolve the persistence service continuable children require, or fail loud. */
119
+ private requirePersistence;
120
+ /** Resolve the Session query service used for cold child observations. */
121
+ private requireSessionQuery;
122
+ }
123
+ export default SubagentContinuationManager;
124
+ //# sourceMappingURL=continuation.d.ts.map