@north-light/crouter 0.3.204 → 0.3.206

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 (106) hide show
  1. package/dist/api/dto/broker.d.ts +2 -0
  2. package/dist/api/dto/messages.d.ts +22 -1
  3. package/dist/api/dto/nodes.d.ts +8 -5
  4. package/dist/api/index.d.ts +1 -0
  5. package/dist/api/index.js +1 -0
  6. package/dist/clients/attach/__tests__/context-message.test.js +54 -19
  7. package/dist/clients/attach/__tests__/page-block.test.d.ts +1 -0
  8. package/dist/clients/attach/__tests__/page-block.test.js +54 -0
  9. package/dist/clients/attach/render/chat-view.d.ts +3 -0
  10. package/dist/clients/attach/render/chat-view.js +56 -27
  11. package/dist/clients/attach/render/context-message.d.ts +6 -0
  12. package/dist/clients/attach/render/context-message.js +21 -3
  13. package/dist/clients/attach/render/group-activity.d.ts +5 -3
  14. package/dist/clients/attach/render/group-activity.js +10 -6
  15. package/dist/clients/attach/render/page-block.js +11 -11
  16. package/dist/clients/attach/viewer.js +717 -703
  17. package/dist/clients/conversation/projection.js +7 -37
  18. package/dist/commands/node/create.js +1 -1
  19. package/dist/commands/profile/project.js +1 -1
  20. package/dist/commands/profile/show.js +1 -1
  21. package/dist/commands/profile.js +1 -1
  22. package/dist/core/__tests__/canvas-inbox-watcher.test.js +90 -23
  23. package/dist/core/__tests__/context-intro.test.js +7 -8
  24. package/dist/core/__tests__/human-deliver.test.js +32 -4
  25. package/dist/core/__tests__/kickoff.test.js +6 -6
  26. package/dist/core/__tests__/serial/broker-snapshot-history.test.js +5 -2
  27. package/dist/core/__tests__/serial/deferred-no-wake.test.js +7 -4
  28. package/dist/core/__tests__/serial/flagship-lifecycle.test.js +2 -1
  29. package/dist/core/__tests__/serial/human-deliver-e2e.test.js +4 -1
  30. package/dist/core/__tests__/serial/revive.test.js +8 -3
  31. package/dist/core/__tests__/session-cycles.test.js +10 -6
  32. package/dist/core/canvas/render-source.js +3 -0
  33. package/dist/core/feed/feed.d.ts +7 -1
  34. package/dist/core/feed/feed.js +8 -7
  35. package/dist/core/feed/inbox.d.ts +16 -12
  36. package/dist/core/feed/inbox.js +56 -56
  37. package/dist/core/human/page-eval.d.ts +9 -4
  38. package/dist/core/human/page-eval.js +3 -1
  39. package/dist/core/human/page-markdown.d.ts +3 -0
  40. package/dist/core/human/page-markdown.js +295 -0
  41. package/dist/core/human/page.js +4 -0
  42. package/dist/core/runtime/bearings.js +5 -4
  43. package/dist/core/runtime/broker/client-registry.d.ts +1 -0
  44. package/dist/core/runtime/broker/client-registry.js +1 -0
  45. package/dist/core/runtime/broker/fault-retry.js +8 -3
  46. package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
  47. package/dist/core/runtime/broker/frame-dispatch.js +13 -2
  48. package/dist/core/runtime/broker/inbox.d.ts +20 -2
  49. package/dist/core/runtime/broker/inbox.js +68 -25
  50. package/dist/core/runtime/broker/passive.d.ts +1 -0
  51. package/dist/core/runtime/broker/tool-groups.js +3 -2
  52. package/dist/core/runtime/broker-extension-render.d.ts +3 -0
  53. package/dist/core/runtime/broker-extension-render.js +3 -0
  54. package/dist/core/runtime/broker-protocol.d.ts +14 -0
  55. package/dist/core/runtime/broker-protocol.js +11 -0
  56. package/dist/core/runtime/broker.d.ts +2 -2
  57. package/dist/core/runtime/broker.js +31 -6
  58. package/dist/core/runtime/deliver-live.js +2 -1
  59. package/dist/core/runtime/interactive-deliver.d.ts +3 -2
  60. package/dist/core/runtime/interactive-deliver.js +4 -3
  61. package/dist/core/runtime/kickoff.d.ts +3 -4
  62. package/dist/core/runtime/kickoff.js +27 -16
  63. package/dist/core/runtime/node-read.d.ts +2 -0
  64. package/dist/core/runtime/node-read.js +11 -3
  65. package/dist/core/runtime/session-cycles.d.ts +6 -1
  66. package/dist/core/runtime/session-cycles.js +17 -11
  67. package/dist/core/runtime/session-visibility.d.ts +7 -12
  68. package/dist/core/runtime/session-visibility.js +7 -13
  69. package/dist/core/runtime/situational-context.d.ts +14 -5
  70. package/dist/core/runtime/situational-context.js +39 -21
  71. package/dist/core/runtime/situational-live.d.ts +2 -2
  72. package/dist/core/runtime/situational-live.js +17 -16
  73. package/dist/core/runtime/spawn.js +4 -3
  74. package/dist/core/runtime/stop-guard.js +8 -4
  75. package/dist/core/runtime/warm-pool.d.ts +1 -1
  76. package/dist/core/runtime/warm-pool.js +6 -9
  77. package/dist/daemon/api/handlers/messages.js +101 -17
  78. package/dist/daemon/api/handlers/nodes.js +12 -8
  79. package/dist/daemon/human/finish.js +44 -4
  80. package/dist/daemon/messaging/node-message.d.ts +5 -0
  81. package/dist/daemon/messaging/node-message.js +6 -1
  82. package/dist/daemon/review/comment-notify.js +8 -0
  83. package/dist/daemon/review/deliver.js +2 -2
  84. package/dist/daemon/review/finish.js +1 -0
  85. package/dist/pi-extensions/__tests__/canvas-goal-capture-envelope.test.d.ts +1 -0
  86. package/dist/pi-extensions/__tests__/canvas-goal-capture-envelope.test.js +96 -0
  87. package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.js +1 -1
  88. package/dist/pi-extensions/__tests__/canvas-stophook-context-nudge.test.js +2 -2
  89. package/dist/pi-extensions/broker-local.d.ts +0 -2
  90. package/dist/pi-extensions/broker-local.js +0 -2
  91. package/dist/pi-extensions/canvas-context-intro.js +9 -8
  92. package/dist/pi-extensions/canvas-goal-capture.js +10 -6
  93. package/dist/pi-extensions/canvas-inbox-watcher.js +116 -69
  94. package/dist/pi-extensions/canvas-passive-context.d.ts +10 -0
  95. package/dist/pi-extensions/canvas-passive-context.js +23 -3
  96. package/dist/pi-extensions/canvas-review-boundary.d.ts +1 -1
  97. package/dist/pi-extensions/canvas-review-boundary.js +11 -3
  98. package/dist/pi-extensions/canvas-stophook.js +3 -3
  99. package/dist/shared/__tests__/generated-context-grammar.test.d.ts +1 -0
  100. package/dist/shared/__tests__/generated-context-grammar.test.js +85 -0
  101. package/dist/shared/generated-context.d.ts +68 -36
  102. package/dist/shared/generated-context.js +300 -174
  103. package/dist/shared/tool-groups.js +3 -2
  104. package/package.json +1 -1
  105. package/runtime.lock.json +2 -2
  106. package/scripts/postinstall.mjs +9 -0
@@ -1,62 +1,94 @@
1
- import { REVIEW_BOUNDARY_CUSTOM_TYPE } from '../core/runtime/session-visibility.js';
2
- export { REVIEW_BOUNDARY_CUSTOM_TYPE };
3
1
  /** Custom message carrying the node's session-start bearings. */
4
2
  export declare const CONTEXT_INTRO_CUSTOM_TYPE = "crtr-context";
5
3
  /** Custom message carrying an ambient situational-context update. */
6
4
  export declare const SITUATIONAL_CONTEXT_CUSTOM_TYPE = "crtr-situational-context";
7
5
  /** Custom message used when a context-size nudge waits for the next turn. */
8
6
  export declare const CONTEXT_NUDGE_CUSTOM_TYPE = "crtr-context-nudge";
9
- /** Opening text of a fresh-revive kickoff user message. */
7
+ /** Custom message that opens a review companion's visible transcript. */
8
+ export declare const REVIEW_BOUNDARY_CUSTOM_TYPE = "crtr-review-boundary";
9
+ /** Opening text of a pre-envelope fresh-revive kickoff user message. */
10
10
  export declare const REVIVE_KICKOFF_SENTINEL = "You have been revived fresh after a context refresh";
11
- /** Prefix shared by the producer and the compatibility classifier for context nudges. */
12
- export declare const CONTEXT_NUDGE_PREFIX = "[crtr] Context ~";
13
- /** Runtime-authored continuation after a cleanly aborted turn survives a restart. */
14
- export declare const RUNTIME_RESTART_CONTINUATION = "<runtime-restart-continuation>\ncontinue\n</runtime-restart-continuation>";
15
11
  /** Generic completion mandate issued by the terminal-node stop guard. */
16
12
  export declare const STALL_REPROMPT: string;
17
13
  /** Static recovery prompts shared by the broker producer and display classifier. */
18
14
  export declare const AUTH_FAULT_RECOVERY_BODY = "Provider credentials were just updated (a new login landed). Your previous turn stopped on a provider authentication failure. Continue from where you left off and retry the work that failed.";
19
15
  export declare const CONNECTION_FAULT_RECOVERY_BODY = "The network connection is back online. Your previous turn stopped on a connection error (the network was down). Continue from where you left off and retry the work that failed.";
20
16
  export declare const PROVIDER_FAULT_RECOVERY_BODY = "Your previous turn stopped on a provider fault. Continue from where you left off and retry the work that failed.";
21
- /** Mark an active persona transition without changing the guidance inside it. */
22
- export declare function formatPersonaTransition(guidance: string): string;
23
- /** Mark a daemon-delivered review approval for compact viewer presentation. */
24
- export declare function formatReviewApproval(body: string): string;
17
+ export type ModelFallbackRecoveryReason = 'credential' | 'not-found';
25
18
  /** Format the stop guard's dynamic structured-output mandate. */
26
19
  export declare function formatStructuredOutputReprompt(schema: string): string;
27
- export type ModelFallbackRecoveryReason = 'credential' | 'not-found';
28
- /** Mark a model-route fallback re-drive while retaining its full guidance. */
20
+ /** Keep model-fallback guidance editable without making it a reader contract. */
29
21
  export declare function formatModelFallbackRecovery(previousModel: string, nextModel: string, reason: ModelFallbackRecoveryReason): string;
30
22
  export interface GeneratedContextMessageLike {
31
23
  role?: string;
32
24
  customType?: string;
33
25
  content?: unknown;
34
26
  }
35
- export interface GeneratedContextPresentation {
36
- kind: 'bearings' | 'situational' | 'revive' | 'context-nudge' | 'inbox' | 'review-approval' | 'persona-transition' | 'stop-guard' | 'recovery';
27
+ export type CardEntryDisposition = 'report' | 'human-answer' | 'human-canceled';
28
+ export interface CardEntry {
29
+ disposition: CardEntryDisposition;
30
+ kind: string;
31
+ body: string;
32
+ ref?: string;
33
+ }
34
+ export interface CardSender {
35
+ id: string;
36
+ name?: string;
37
+ updates: number;
38
+ finished: boolean;
39
+ entries: CardEntry[];
40
+ }
41
+ /** An already-resolved inbox entry supplied to the pure digest formatter. */
42
+ export interface InboxCardEntry {
43
+ kind: string;
44
+ body: string;
45
+ ref?: string;
46
+ disposition?: CardEntryDisposition;
47
+ }
48
+ /** An already-resolved sender section supplied to the pure digest formatter. */
49
+ export interface InboxCardSection {
50
+ id: string;
51
+ name?: string;
52
+ entries: readonly InboxCardEntry[];
53
+ updates?: number;
54
+ finished?: boolean;
55
+ }
56
+ export interface GeneratedCard {
57
+ kind: string;
58
+ facts: Readonly<Record<string, string>>;
59
+ body: string;
60
+ senders: CardSender[];
37
61
  label: string;
38
62
  summary: string;
39
- /** The unmodified, model-visible message content. */
40
- body: string;
63
+ expandable: boolean;
64
+ }
65
+ type CardSummary = (facts: Readonly<Record<string, string>>) => string;
66
+ export interface CardKindDefinition {
67
+ label: string;
68
+ summary: CardSummary;
69
+ expandable: boolean;
70
+ customTypes?: Readonly<Record<string, Partial<Pick<CardKindDefinition, 'label' | 'summary' | 'expandable'>>>>;
41
71
  }
42
- export declare function generatedContextExpandedBody(presentation: GeneratedContextPresentation): string;
72
+ /** The closed crouter vocabulary, plus custom-role aliases for the same cards. */
73
+ export declare const KIND_TABLE: Readonly<Record<string, CardKindDefinition>>;
74
+ /** Contribute presentation for namespaced kinds this process will render.
75
+ * Idempotent and last-write-wins, so a re-imported module cannot fail a boot.
76
+ * A process that never registers is not degraded: an unregistered kind still
77
+ * parses and only falls back to the generic label and summary. */
78
+ export declare function registerCardKinds(kinds: Readonly<Record<string, CardKindDefinition>>): void;
43
79
  /** Plain text from a generated message's string or text-block content. */
44
80
  export declare function generatedContextText(message: GeneratedContextMessageLike): string;
45
- /** Format the runtime's visible context-size guidance. */
46
- export declare function formatContextNudge(note: string): string;
47
- export declare function isInboxDigest(text: string): boolean;
48
- export declare function extractInboxSender(text: string): string | null;
49
- /** Node ids whose section of this digest reports a finished node. Sections are
50
- * delimited by their `From <sender>` headers, so a final never attaches to the
51
- * neighbouring sender. */
52
- export declare function inboxFinishedSenders(text: string): string[];
53
- /** Exact producer-owned marker for the continuation a successor broker inserts
54
- * after a runtime restart. Other recovery bodies intentionally do not match. */
55
- export declare function isRuntimeRestartContinuation(message: GeneratedContextMessageLike): boolean;
56
- /**
57
- * Classify a crouter-generated context message for display. The checks are
58
- * exact producer-owned contracts: custom messages use their customType, and
59
- * user messages use stable sentinels or the same exact formatter/constants as
60
- * their producers. Ordinary user prompts remain ordinary user prompts.
61
- */
62
- export declare function generatedContextPresentation(message: GeneratedContextMessageLike): GeneratedContextPresentation | null;
81
+ /** Wrap a user-role runtime message in its whole-message card envelope. */
82
+ export declare function formatCard(kind: string, facts: Record<string, string | number | boolean | undefined>, body: string): string;
83
+ /** Wrap a card whose body is DATA, not markup — the only escape on the API
84
+ * path, so a caller can neither emit a malformed card nor smuggle markup into
85
+ * one. `formatCard` keeps its raw body for the trusted crouter producers that
86
+ * deliberately nest markup (bearings blocks, the inbox `<from>`/`<entry>`
87
+ * grammar `parseInboxBody` depends on). */
88
+ export declare function formatDataCard(kind: string, facts: Record<string, string | number | boolean | undefined>, body: string): string;
89
+ /** Parse a runtime envelope, with pre-envelope customType compatibility. */
90
+ export declare function parseCard(message: GeneratedContextMessageLike): GeneratedCard | null;
91
+ /** Format a complete inbox card from report bodies resolved by the caller. */
92
+ export declare function formatInboxCard(sections: readonly InboxCardSection[]): string;
93
+ export declare function isLegacyRuntimeText(text: string): boolean;
94
+ export {};