@soimy/dingtalk 3.6.6 → 3.6.8

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 (40) hide show
  1. package/dist/index.js +1433 -344
  2. package/dist/index.js.map +4 -4
  3. package/dist/src/card/ask-user-question-context.d.ts +5 -2
  4. package/dist/src/card/ask-user-question-context.d.ts.map +1 -1
  5. package/dist/src/card/ask-user-question-store.d.ts +42 -0
  6. package/dist/src/card/ask-user-question-store.d.ts.map +1 -0
  7. package/dist/src/card/ask-user-question.d.ts +20 -0
  8. package/dist/src/card/ask-user-question.d.ts.map +1 -1
  9. package/dist/src/card/card-action-handler.d.ts +1 -0
  10. package/dist/src/card/card-action-handler.d.ts.map +1 -1
  11. package/dist/src/card-service.d.ts +4 -1
  12. package/dist/src/card-service.d.ts.map +1 -1
  13. package/dist/src/gateway/channel-gateway.d.ts.map +1 -1
  14. package/dist/src/gateway/inbound-session-queue-dispatcher.d.ts +23 -0
  15. package/dist/src/gateway/inbound-session-queue-dispatcher.d.ts.map +1 -0
  16. package/dist/src/gateway/inbound-session-queue.d.ts +46 -0
  17. package/dist/src/gateway/inbound-session-queue.d.ts.map +1 -0
  18. package/dist/src/gateway/reply-session-conflict.d.ts +22 -0
  19. package/dist/src/gateway/reply-session-conflict.d.ts.map +1 -0
  20. package/dist/src/inbound-handler.d.ts.map +1 -1
  21. package/dist/src/onboarding.d.ts.map +1 -1
  22. package/dist/src/targeting/agent-routing.d.ts +17 -1
  23. package/dist/src/targeting/agent-routing.d.ts.map +1 -1
  24. package/dist/src/types.d.ts +35 -0
  25. package/dist/src/types.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/access-control.ts +1 -1
  28. package/src/card/ask-user-question-context.ts +9 -1
  29. package/src/card/ask-user-question-store.ts +294 -0
  30. package/src/card/ask-user-question.ts +398 -37
  31. package/src/card/card-action-handler.ts +2 -0
  32. package/src/card-service.ts +55 -3
  33. package/src/gateway/channel-gateway.ts +51 -30
  34. package/src/gateway/inbound-session-queue-dispatcher.ts +304 -0
  35. package/src/gateway/inbound-session-queue.ts +244 -0
  36. package/src/gateway/reply-session-conflict.ts +82 -0
  37. package/src/inbound-handler.ts +254 -57
  38. package/src/onboarding.ts +6 -2
  39. package/src/targeting/agent-routing.ts +84 -19
  40. package/src/types.ts +36 -0
package/src/types.ts CHANGED
@@ -462,6 +462,16 @@ export interface SubAgentOptions {
462
462
  commandText?: string;
463
463
  }
464
464
 
465
+ /**
466
+ * A trusted route resolved by the plugin before recursive or synthetic inbound handling.
467
+ * It is runtime-only and must never be populated from DingTalk callback payload fields.
468
+ */
469
+ export interface ResolvedDingTalkRoute {
470
+ agentId: string;
471
+ sessionKey: string;
472
+ mainSessionKey: string;
473
+ }
474
+
465
475
  /**
466
476
  * Message handler parameters
467
477
  */
@@ -472,6 +482,16 @@ export interface HandleDingTalkMessageParams {
472
482
  sessionWebhook: string;
473
483
  log?: Logger;
474
484
  dingtalkConfig: DingTalkConfig;
485
+ /** Distinguishes real Stream messages from Ask User callback reinjection. */
486
+ inboundOrigin?: "stream" | "ask-user";
487
+ /**
488
+ * Explicitly enables handler-owned queueing for a real gateway Stream
489
+ * callback. Direct/synthetic callers must not be inferred from raw message
490
+ * shape, because they may already be inside another handler lifecycle.
491
+ */
492
+ inboundQueueEligible?: boolean;
493
+ /** Reuses an already-resolved trusted route for recursive or synthetic handling. */
494
+ routeOverride?: ResolvedDingTalkRoute;
475
495
  /**
476
496
  * When set, routes message to the specified sub-agent instead of main agent.
477
497
  * This enables reuse of the main message handling logic for sub-agents.
@@ -487,6 +507,22 @@ export interface HandleDingTalkMessageParams {
487
507
  mediaPaths?: string[];
488
508
  mediaTypes?: string[];
489
509
  };
510
+ /**
511
+ * A pre-created AI Card to reuse instead of creating a new one. Set by the
512
+ * inbound session-queue dispatcher when a message was queued behind an active
513
+ * run: the card was already created and is showing a "已排队" acknowledgement,
514
+ * so the handler streams the real reply INTO this same card (in-place update)
515
+ * rather than spawning a second card. When unset, the handler creates a fresh
516
+ * card as usual.
517
+ */
518
+ preCreatedCard?: AICardInstance;
519
+ /**
520
+ * Internal recursion guard for the authorized inbound session queue. The
521
+ * first handler pass performs access control and trusted route resolution;
522
+ * the queued continuation re-enters with this set so it can consume the
523
+ * pre-created card without queueing itself again.
524
+ */
525
+ inboundQueueHandled?: boolean;
490
526
  }
491
527
 
492
528
  /**