@deepseek-ai/dsh-subagent 0.2.1-alpha.1 → 0.2.1-alpha.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 (44) hide show
  1. package/README.i18n.yaml +40 -34
  2. package/README.md +43 -26
  3. package/README.zh.md +43 -26
  4. package/lib/index.js +1480 -1349
  5. package/lib/typert.host.js +230 -76
  6. package/lib/typert.remote-client.d.ts +6 -2
  7. package/lib/typert.remote-client.js +82 -28
  8. package/lib/types/activation.d.ts +114 -0
  9. package/lib/types/activation.js +112 -0
  10. package/lib/types/catalog.d.ts +14 -6
  11. package/lib/types/catalog.js +34 -30
  12. package/lib/types/child-agent.d.ts +16 -32
  13. package/lib/types/child-agent.js +25 -30
  14. package/lib/types/continuation-messages.d.ts +4 -3
  15. package/lib/types/continuation-messages.js +13 -5
  16. package/lib/types/control-types.d.ts +7 -0
  17. package/lib/types/descriptor.d.ts +7 -46
  18. package/lib/types/descriptor.js +20 -21
  19. package/lib/types/index.d.ts +52 -51
  20. package/lib/types/index.js +81 -98
  21. package/lib/types/internal.d.ts +1 -1
  22. package/lib/types/lifecycle.d.ts +28 -58
  23. package/lib/types/lifecycle.js +9 -74
  24. package/lib/types/list-children.js +1 -1
  25. package/lib/types/manager.d.ts +247 -0
  26. package/lib/types/manager.js +1316 -0
  27. package/lib/types/out-of-process.d.ts +3 -29
  28. package/lib/types/out-of-process.js +5 -47
  29. package/lib/types/projection-types.d.ts +3 -0
  30. package/lib/types/structured.d.ts +49 -0
  31. package/lib/types/structured.js +130 -0
  32. package/lib/types/types.d.ts +66 -100
  33. package/lib/types/types.js +1 -1
  34. package/locale/en.json +5 -0
  35. package/locale/zh.json +6 -0
  36. package/package.json +56 -53
  37. package/lib/types/continuation-activation.d.ts +0 -267
  38. package/lib/types/continuation-activation.js +0 -700
  39. package/lib/types/continuation.d.ts +0 -124
  40. package/lib/types/continuation.js +0 -455
  41. package/lib/types/inbox.d.ts +0 -43
  42. package/lib/types/inbox.js +0 -61
  43. package/lib/types/run-settlement.d.ts +0 -17
  44. package/lib/types/run-settlement.js +0 -70
@@ -1,61 +0,0 @@
1
- /**
2
- * Activation-local admission around one continuable subagent's Agent inbox.
3
- *
4
- * @module @deepseek-ai/dsh-subagent/inbox
5
- */
6
- import { SubagentError } from "./error.js";
7
- /** Delegate Queue and Steer to one live Agent until its Activation starts closing. */
8
- export class SubagentInbox {
9
- agent;
10
- closingPromise;
11
- /**
12
- * Wrap one live continuable Agent.
13
- * @param agent - the Agent whose inbox receives accepted deliveries.
14
- */
15
- constructor(agent) {
16
- this.agent = agent;
17
- }
18
- /**
19
- * Read the Activation's close transaction.
20
- * @returns the memoized transaction, or `undefined` while delivery remains open.
21
- */
22
- get closing() {
23
- return this.closingPromise;
24
- }
25
- /**
26
- * Read whether the underlying Agent still has accepted work to claim.
27
- * @returns whether either Agent inbox destination is non-empty.
28
- */
29
- get hasPending() {
30
- return this.agent.inbox.nextTurn.length > 0 || this.agent.inbox.nextStep.length > 0;
31
- }
32
- /**
33
- * Submit through the Agent only while its Activation remains resident.
34
- * @param message - the accepted input to submit.
35
- * @param delivery - whether to queue a distinct turn or steer the nearest step.
36
- */
37
- deliver(message, delivery) {
38
- if (this.closingPromise !== undefined) {
39
- throw new SubagentError(`subagent "${this.agent.id}" activation is being disposed; the message was not accepted`, 'ACTIVATION_CLOSING');
40
- }
41
- if (delivery === 'steer')
42
- this.agent.steer(message);
43
- else
44
- this.agent.followup(message);
45
- }
46
- /**
47
- * Close delivery synchronously and share one asynchronous release.
48
- * @param release - the one release operation to start after closing admission.
49
- * @returns the memoized release transaction.
50
- */
51
- close(release) {
52
- const existing = this.closingPromise;
53
- if (existing !== undefined)
54
- return existing;
55
- const completion = Promise.withResolvers();
56
- this.closingPromise = completion.promise;
57
- void release().then(completion.resolve, completion.reject);
58
- return completion.promise;
59
- }
60
- }
61
- //# sourceMappingURL=inbox.js.map
@@ -1,17 +0,0 @@
1
- /**
2
- * Settlement of one ONE-SHOT subagent run into a background-Task outcome. Only
3
- * the one-shot background path uses Jobs; continuable children have no Task,
4
- * no per-message result, and no Task cancellation.
5
- *
6
- * @module @deepseek-ai/dsh-subagent/run-settlement
7
- */
8
- import type { JobOutcome } from '@deepseek-ai/dsh-jobs';
9
- import type { SubagentRun } from './types.ts';
10
- /**
11
- * Await the child result, dispose the run, then return its task outcome. Result
12
- * and disposal failures become `failed`; when both fail, both details survive.
13
- * @param run - live run to settle and release.
14
- * @returns outcome after child resources are released.
15
- */
16
- export declare function settleRun(run: SubagentRun): Promise<JobOutcome>;
17
- //# sourceMappingURL=run-settlement.d.ts.map
@@ -1,70 +0,0 @@
1
- /**
2
- * Settlement of one ONE-SHOT subagent run into a background-Task outcome. Only
3
- * the one-shot background path uses Jobs; continuable children have no Task,
4
- * no per-message result, and no Task cancellation.
5
- *
6
- * @module @deepseek-ai/dsh-subagent/run-settlement
7
- */
8
- /** Flatten a child's final output blocks to the task's final text. */
9
- function finalText(blocks) {
10
- return blocks
11
- .filter((block) => block.type === 'text')
12
- .map(block => block.text)
13
- .join('');
14
- }
15
- /** Render a failed stop reason with optional provider-authored detail. */
16
- function failureDetail(result) {
17
- const stopReason = result.stopReason;
18
- return result.diagnostic === undefined
19
- ? stopReason
20
- : `${stopReason}; diagnostic: ${result.diagnostic}`;
21
- }
22
- /**
23
- * Map a child result to the task outcome: completed carries final text, local
24
- * cancellation (`aborted` without a diagnostic) is killed, and provider-
25
- * diagnosed remote aborts plus every other reason are failed without partial
26
- * output.
27
- * @param result - child terminal result.
28
- * @returns outcome for the `ctx.jobs` registration.
29
- */
30
- function runOutcome(result) {
31
- switch (result.stopReason) {
32
- case 'completed':
33
- return { status: 'completed', result: finalText(result.output) };
34
- case 'aborted':
35
- return result.diagnostic === undefined
36
- ? { status: 'killed' }
37
- : { status: 'failed', detail: failureDetail(result) };
38
- case 'error':
39
- case 'max-tokens':
40
- case 'refusal':
41
- return { status: 'failed', detail: failureDetail(result) };
42
- // Merge-extensible reasons remain failures with provider-authored detail.
43
- default:
44
- return { status: 'failed', detail: failureDetail(result) };
45
- }
46
- }
47
- /**
48
- * Await the child result, dispose the run, then return its task outcome. Result
49
- * and disposal failures become `failed`; when both fail, both details survive.
50
- * @param run - live run to settle and release.
51
- * @returns outcome after child resources are released.
52
- */
53
- export async function settleRun(run) {
54
- let outcome;
55
- try {
56
- outcome = runOutcome(await run.result);
57
- }
58
- catch (error) {
59
- outcome = { status: 'failed', detail: String(error) };
60
- }
61
- try {
62
- await run.dispose();
63
- }
64
- catch (error) {
65
- const prefix = outcome.detail === undefined ? '' : `${outcome.detail}; `;
66
- return { status: 'failed', detail: `${prefix}dispose failed: ${String(error)}` };
67
- }
68
- return outcome;
69
- }
70
- //# sourceMappingURL=run-settlement.js.map