@noodleseed/one 0.133.0 → 0.135.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 (88) hide show
  1. package/dist/commands/author-loop.d.ts.map +1 -1
  2. package/dist/commands/author-loop.js +3 -3
  3. package/dist/commands/author-loop.js.map +1 -1
  4. package/dist/commands/devtools.js +1 -1
  5. package/dist/commands/devtools.js.map +1 -1
  6. package/dist/commands/local-readiness.d.ts +2 -2
  7. package/dist/commands/local-readiness.d.ts.map +1 -1
  8. package/dist/commands/local-readiness.js +15 -7
  9. package/dist/commands/local-readiness.js.map +1 -1
  10. package/dist/dev-local-runtime.d.ts +33 -0
  11. package/dist/dev-local-runtime.d.ts.map +1 -0
  12. package/dist/dev-local-runtime.js +53 -0
  13. package/dist/dev-local-runtime.js.map +1 -0
  14. package/dist/dev.d.ts +4 -0
  15. package/dist/dev.d.ts.map +1 -1
  16. package/dist/dev.js +109 -31
  17. package/dist/dev.js.map +1 -1
  18. package/dist/devtools-harness.js +5 -3
  19. package/dist/devtools-harness.js.map +1 -1
  20. package/dist/devtools-preview.d.ts +2 -0
  21. package/dist/devtools-preview.d.ts.map +1 -1
  22. package/dist/devtools-preview.js +15 -3
  23. package/dist/devtools-preview.js.map +1 -1
  24. package/dist/devtools-rpc-forwarder.js +1 -1
  25. package/dist/devtools-rpc-forwarder.js.map +1 -1
  26. package/dist/preview-session.d.ts.map +1 -1
  27. package/dist/preview-session.js +1 -0
  28. package/dist/preview-session.js.map +1 -1
  29. package/dist/react-widget-build.d.ts +4 -0
  30. package/dist/react-widget-build.d.ts.map +1 -1
  31. package/dist/react-widget-build.js +9 -0
  32. package/dist/react-widget-build.js.map +1 -1
  33. package/node_modules/@noodle-borg/admission-limits/dist/client-address.d.ts +7 -0
  34. package/node_modules/@noodle-borg/admission-limits/dist/counter-store.d.ts +71 -0
  35. package/node_modules/@noodle-borg/admission-limits/dist/envelope.d.ts +67 -0
  36. package/node_modules/@noodle-borg/admission-limits/dist/in-memory-counter-store.d.ts +15 -0
  37. package/node_modules/@noodle-borg/admission-limits/dist/portable.d.ts +6 -0
  38. package/node_modules/@noodle-borg/admission-limits/dist/portable.js +6 -0
  39. package/node_modules/@noodle-borg/admission-limits/package.json +8 -0
  40. package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js +3 -3
  41. package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js +4 -1
  42. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  43. package/node_modules/@noodle-borg/assistant-gateway/dist/artifact-projection.d.ts +21 -0
  44. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-context.d.ts +25 -0
  45. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-customer-issuer.d.ts +3 -0
  46. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-customer-routing.d.ts +19 -0
  47. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-guide.d.ts +39 -0
  48. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-interaction-state.d.ts +181 -0
  49. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-interactive.d.ts +99 -0
  50. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-interactive.js +1 -1
  51. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-presentation.d.ts +35 -0
  52. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-sensitive-values.d.ts +3 -0
  53. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-store.d.ts +226 -0
  54. package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-store.js +1 -1
  55. package/node_modules/@noodle-borg/assistant-gateway/dist/elevation-store.d.ts +70 -0
  56. package/node_modules/@noodle-borg/assistant-gateway/dist/elevation.d.ts +68 -0
  57. package/node_modules/@noodle-borg/assistant-gateway/dist/embed-script.d.ts +24 -0
  58. package/node_modules/@noodle-borg/assistant-gateway/dist/embed-store.d.ts +73 -0
  59. package/node_modules/@noodle-borg/assistant-gateway/dist/in-memory-elevation-store.d.ts +21 -0
  60. package/node_modules/@noodle-borg/assistant-gateway/dist/in-memory-embed-store.d.ts +28 -0
  61. package/node_modules/@noodle-borg/assistant-gateway/dist/portable.d.ts +24 -0
  62. package/node_modules/@noodle-borg/assistant-gateway/dist/public-session.d.ts +56 -0
  63. package/node_modules/@noodle-borg/assistant-gateway/dist/public-surface.d.ts +21 -0
  64. package/node_modules/@noodle-borg/assistant-gateway/dist/public-surface.js +2 -1
  65. package/node_modules/@noodle-borg/assistant-gateway/dist/public-turn.d.ts +44 -0
  66. package/node_modules/@noodle-borg/assistant-gateway/dist/session-resume.d.ts +22 -0
  67. package/node_modules/@noodle-borg/assistant-gateway/dist/surface-budget.d.ts +16 -0
  68. package/node_modules/@noodle-borg/assistant-gateway/dist/surface-budget.js +1 -1
  69. package/node_modules/@noodle-borg/assistant-gateway/dist/tenant-ref.d.ts +13 -0
  70. package/node_modules/@noodle-borg/assistant-gateway/package.json +1 -1
  71. package/node_modules/@noodle-borg/authoring/dist/assistant.d.ts +7 -0
  72. package/node_modules/@noodle-borg/authoring/dist/assistant.js +3 -0
  73. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +4 -0
  74. package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -5
  75. package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
  76. package/node_modules/@noodle-borg/service/dist/local-options.d.ts +9 -0
  77. package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.js +14 -3
  78. package/node_modules/@noodle-borg/service/dist/routes/assistant-embeds.js +1 -1
  79. package/node_modules/@noodle-borg/service/dist/routes/assistant-public-session.js +1 -1
  80. package/node_modules/@noodle-borg/service/dist/routes/assistant-public-turn.js +1 -1
  81. package/node_modules/@noodle-borg/service/dist/routes/assistant.js +1 -1
  82. package/node_modules/@noodle-borg/service/dist/serve-local.js +2 -3
  83. package/node_modules/@noodle-borg/service/package.json +1 -1
  84. package/node_modules/@noodleseed/assistant/README.md +4 -1
  85. package/node_modules/@noodleseed/assistant/package.json +1 -1
  86. package/package.json +5 -3
  87. package/node_modules/@noodle-borg/admission-limits/dist/index.js +0 -15
  88. package/node_modules/@noodle-borg/admission-limits/dist/postgres-counter-store.js +0 -68
@@ -0,0 +1,39 @@
1
+ import type { ArtifactTool, RuntimeArtifact } from '@noodle-borg/compiler';
2
+ import { type ToolAuthorizationCaller } from '@noodle-borg/protocol';
3
+ import { type SurfaceCapabilityRef } from './artifact-projection.js';
4
+ /** Model-context budget for the embedded assistant's compact product workflow projection. */
5
+ export declare const ASSISTANT_GUIDE_MAX_BYTES: number;
6
+ export type AssistantGuideUnavailableReason = 'package_unavailable' | 'no_complete_workflow' | 'context_too_large';
7
+ export type AssistantGuideProjection = {
8
+ readonly status: 'ready';
9
+ readonly guide: {
10
+ readonly content: string;
11
+ readonly workflowIds: readonly string[];
12
+ readonly byteLength: number;
13
+ };
14
+ } | {
15
+ readonly status: 'unavailable';
16
+ readonly reason: AssistantGuideUnavailableReason;
17
+ };
18
+ /**
19
+ * Select the exact deployment tools an embedded model may see for this turn.
20
+ *
21
+ * A mixed anonymous surface deliberately advertises only its declared tools so the existing elevation
22
+ * interceptor can turn an attempted gated call into a sign-in offer. The selector performs that projection
23
+ * itself: callers cannot opt into sign-in offers without supplying the surface capability boundary. Every
24
+ * other caller gets the normal authorization filter. App-only tools never enter model tools or guidance.
25
+ */
26
+ export declare function selectAssistantModelTools(artifact: RuntimeArtifact, caller: (ToolAuthorizationCaller & {
27
+ readonly identityKind?: string;
28
+ }) | undefined, options?: {
29
+ readonly anonymousSignInOfferSurface?: readonly SurfaceCapabilityRef[];
30
+ }): readonly ArtifactTool[];
31
+ /**
32
+ * Build bounded product guidance from structured App Package data, never from rendered host files.
33
+ * Workflows are atomic: if one step is unavailable to this model, the entire workflow is omitted.
34
+ */
35
+ export declare function projectAssistantGuide(input: {
36
+ readonly appPackage: unknown;
37
+ readonly modelTools: readonly ArtifactTool[];
38
+ }): AssistantGuideProjection;
39
+ //# sourceMappingURL=assistant-guide.d.ts.map
@@ -0,0 +1,181 @@
1
+ import type { InvocationContext } from '@noodle-borg/runtime';
2
+ export declare const DEFAULT_MAX_PENDING_INTERACTIONS_PER_SESSION = 8;
3
+ export declare const ASSISTANT_INTERACTION_OUTCOME_RETENTION_MS: number;
4
+ /** Recovery grace for an in-flight action before its outcome becomes unknowable and payload is scrubbed. */
5
+ export declare const ASSISTANT_INTERACTION_EXECUTING_GRACE_MS: number;
6
+ export type AssistantInteractionKind = 'confirmation' | 'input';
7
+ export type AssistantInteractionStatus = 'pending' | 'executing' | 'succeeded' | 'failed' | 'declined' | 'cancelled';
8
+ export type AssistantInteractionPublicScalar = string | number | boolean | null;
9
+ export interface AssistantInteractionPublicArray extends ReadonlyArray<AssistantInteractionPublicValue> {
10
+ readonly [index: number]: AssistantInteractionPublicValue;
11
+ }
12
+ export interface AssistantInteractionPublicObject {
13
+ readonly [key: string]: AssistantInteractionPublicValue;
14
+ }
15
+ export type AssistantInteractionPublicValue = AssistantInteractionPublicScalar | AssistantInteractionPublicArray | AssistantInteractionPublicObject;
16
+ /** Compact replay-safe data only. Exact connector output and errors must never enter this shape. */
17
+ export interface AssistantInteractionPublicOutcome {
18
+ readonly code: string;
19
+ readonly summary: string;
20
+ readonly details?: Readonly<Record<string, AssistantInteractionPublicScalar>>;
21
+ readonly result?: AssistantInteractionPublicValue;
22
+ }
23
+ export declare const ASSISTANT_INTERACTION_UNKNOWN_OUTCOME: AssistantInteractionPublicOutcome;
24
+ interface AssistantInteractionCommon {
25
+ readonly id: string;
26
+ readonly sessionId: string;
27
+ readonly deploymentId: string;
28
+ /** Immutable proposal-time snapshot reused when the interaction resumes. */
29
+ readonly context?: InvocationContext;
30
+ /** Set when a terminal interaction's exact private payload has been removed. */
31
+ readonly payloadScrubbedAt?: string;
32
+ readonly createdAt: string;
33
+ readonly expiresAt: string;
34
+ }
35
+ interface AssistantConfirmationInteractionPayload {
36
+ readonly kind: 'confirmation';
37
+ readonly tool: string;
38
+ /** Exact validated arguments. Store-internal; renderers receive a separate review projection. */
39
+ readonly arguments: unknown;
40
+ /** Prepared post-elicitation execution state. Server-internal and absent on legacy proposals. */
41
+ readonly continuation?: unknown;
42
+ /** Complete, already-redacted review projection retained so a lost response can be replayed. */
43
+ readonly review?: unknown;
44
+ }
45
+ interface AssistantInputInteractionPayload {
46
+ readonly kind: 'input';
47
+ readonly tool: string;
48
+ readonly message: string;
49
+ readonly requestedSchema: Readonly<Record<string, unknown>>;
50
+ /** Exact runtime continuation. Store-internal and never part of the public interaction event. */
51
+ readonly continuation: unknown;
52
+ }
53
+ export interface AssistantPendingInteractionState {
54
+ readonly status: 'pending';
55
+ }
56
+ export interface AssistantExecutingInteractionState {
57
+ readonly status: 'executing';
58
+ readonly claimedAt: string;
59
+ }
60
+ export interface AssistantSucceededInteractionState {
61
+ readonly status: 'succeeded';
62
+ readonly claimedAt: string;
63
+ readonly completedAt: string;
64
+ readonly publicOutcome: AssistantInteractionPublicOutcome;
65
+ }
66
+ export interface AssistantFailedInteractionState {
67
+ readonly status: 'failed';
68
+ readonly claimedAt: string;
69
+ readonly completedAt: string;
70
+ readonly publicOutcome: AssistantInteractionPublicOutcome;
71
+ }
72
+ export interface AssistantDeclinedInteractionState {
73
+ readonly status: 'declined';
74
+ readonly completedAt: string;
75
+ readonly publicOutcome: AssistantInteractionPublicOutcome;
76
+ }
77
+ export interface AssistantCancelledInteractionState {
78
+ readonly status: 'cancelled';
79
+ readonly completedAt: string;
80
+ readonly publicOutcome: AssistantInteractionPublicOutcome;
81
+ }
82
+ export type AssistantInteractionState = AssistantPendingInteractionState | AssistantExecutingInteractionState | AssistantSucceededInteractionState | AssistantFailedInteractionState | AssistantDeclinedInteractionState | AssistantCancelledInteractionState;
83
+ export type AssistantTerminalInteractionState = AssistantSucceededInteractionState | AssistantFailedInteractionState | AssistantDeclinedInteractionState | AssistantCancelledInteractionState;
84
+ export type AssistantConfirmationInteractionRecord = AssistantInteractionCommon & AssistantConfirmationInteractionPayload & AssistantInteractionState;
85
+ export type AssistantInputInteractionRecord = AssistantInteractionCommon & AssistantInputInteractionPayload & AssistantInteractionState;
86
+ export type AssistantInteractionRecord = AssistantConfirmationInteractionRecord | AssistantInputInteractionRecord;
87
+ export type AssistantPendingConfirmationInteractionRecord = AssistantInteractionCommon & AssistantConfirmationInteractionPayload & AssistantPendingInteractionState;
88
+ export type AssistantPendingInputInteractionRecord = AssistantInteractionCommon & AssistantInputInteractionPayload & AssistantPendingInteractionState;
89
+ export type AssistantPendingInteractionRecord = AssistantPendingConfirmationInteractionRecord | AssistantPendingInputInteractionRecord;
90
+ interface AssistantInteractionCreateCommon {
91
+ readonly sessionId: string;
92
+ readonly deploymentId: string;
93
+ readonly context?: InvocationContext;
94
+ /** Omit only when the persistence adapter should stamp its own proposal time. */
95
+ readonly createdAt?: string;
96
+ readonly expiresAt: string;
97
+ }
98
+ export type AssistantConfirmationInteractionCreateInput = AssistantInteractionCreateCommon & Omit<AssistantConfirmationInteractionPayload, never>;
99
+ export type AssistantInputInteractionCreateInput = AssistantInteractionCreateCommon & Omit<AssistantInputInteractionPayload, never>;
100
+ export type AssistantInteractionCreateInput = AssistantConfirmationInteractionCreateInput | AssistantInputInteractionCreateInput;
101
+ export interface AssistantInteractionScope {
102
+ readonly id: string;
103
+ readonly sessionId: string;
104
+ readonly deploymentId: string;
105
+ readonly now: Date;
106
+ }
107
+ export type AssistantInteractionClaimResult = {
108
+ readonly disposition: 'claimed';
109
+ readonly interaction: AssistantInteractionRecord & AssistantExecutingInteractionState;
110
+ } | {
111
+ readonly disposition: 'replay';
112
+ readonly interaction: AssistantInteractionRecord;
113
+ } | {
114
+ readonly disposition: 'unavailable';
115
+ };
116
+ export type AssistantInteractionCompletion = {
117
+ readonly status: 'succeeded' | 'failed';
118
+ readonly publicOutcome: AssistantInteractionPublicOutcome;
119
+ } | {
120
+ readonly status: 'declined' | 'cancelled';
121
+ readonly publicOutcome?: AssistantInteractionPublicOutcome;
122
+ };
123
+ export type AssistantInteractionCompletionResult = {
124
+ readonly disposition: 'completed';
125
+ readonly interaction: AssistantInteractionRecord;
126
+ } | {
127
+ readonly disposition: 'replay';
128
+ readonly interaction: AssistantInteractionRecord;
129
+ } | {
130
+ readonly disposition: 'conflict';
131
+ readonly interaction: AssistantInteractionRecord;
132
+ } | {
133
+ readonly disposition: 'unavailable';
134
+ };
135
+ export type AssistantInteractionTransitionNext = Omit<AssistantConfirmationInteractionCreateInput, 'sessionId' | 'deploymentId' | 'createdAt'> | Omit<AssistantInputInteractionCreateInput, 'sessionId' | 'deploymentId' | 'createdAt'>;
136
+ /**
137
+ * Atomically records that an executing interaction handed control to one new pending interaction.
138
+ * The store owns the child identity and persists it in the parent's replay-safe public outcome.
139
+ */
140
+ export interface AssistantInteractionTransitionInput extends AssistantInteractionScope {
141
+ readonly publicOutcome: AssistantInteractionPublicOutcome;
142
+ readonly next: AssistantInteractionTransitionNext;
143
+ }
144
+ export type AssistantInteractionTransitionResult = {
145
+ readonly disposition: 'transitioned';
146
+ readonly interaction: AssistantInteractionRecord & AssistantSucceededInteractionState;
147
+ readonly next: AssistantPendingInteractionRecord;
148
+ } | {
149
+ readonly disposition: 'replay';
150
+ readonly interaction: AssistantInteractionRecord;
151
+ } | {
152
+ readonly disposition: 'conflict';
153
+ readonly interaction: AssistantInteractionRecord;
154
+ } | {
155
+ readonly disposition: 'unavailable';
156
+ };
157
+ export declare class AssistantInteractionCapacityError extends Error {
158
+ readonly code: "pending_interaction_limit";
159
+ constructor();
160
+ }
161
+ export declare function createPendingInteraction(id: string, input: AssistantConfirmationInteractionCreateInput): AssistantPendingConfirmationInteractionRecord;
162
+ export declare function createPendingInteraction(id: string, input: AssistantInputInteractionCreateInput): AssistantPendingInputInteractionRecord;
163
+ export declare function executingInteraction(interaction: AssistantInteractionRecord, claimedAt: Date): AssistantInteractionRecord & AssistantExecutingInteractionState;
164
+ export declare function completedInteraction(interaction: AssistantInteractionRecord, completion: AssistantInteractionCompletion, completedAt: Date): AssistantInteractionRecord & AssistantTerminalInteractionState;
165
+ export declare function transitionedInteractions(interaction: AssistantInteractionRecord, input: AssistantInteractionTransitionInput, nextId: string): {
166
+ readonly interaction: AssistantInteractionRecord & AssistantSucceededInteractionState;
167
+ readonly next: AssistantPendingInteractionRecord;
168
+ };
169
+ export declare function isTerminalInteraction(interaction: AssistantInteractionRecord): interaction is AssistantInteractionRecord & AssistantTerminalInteractionState;
170
+ /**
171
+ * Pending proposals expire at their decision deadline. Executing/unknown work keeps a tombstone, and a
172
+ * terminal public outcome remains replayable for a bounded reconciliation window after completion.
173
+ */
174
+ export declare function isPrunableInteraction(interaction: AssistantInteractionRecord, now: Date): boolean;
175
+ export declare function shouldExpireStrandedExecutingInteraction(interaction: AssistantInteractionRecord, now: Date): interaction is AssistantInteractionRecord & AssistantExecutingInteractionState;
176
+ /** Preserve a non-retryable unknown outcome without retaining its exact private payload. */
177
+ export declare function expireStrandedExecutingInteraction(interaction: AssistantInteractionRecord & AssistantExecutingInteractionState, scrubbedAt: Date): AssistantInteractionRecord & AssistantFailedInteractionState;
178
+ export declare function cloneInteraction<T extends AssistantInteractionRecord>(interaction: T): T;
179
+ export declare function normalizePublicOutcome(input: AssistantInteractionPublicOutcome): AssistantInteractionPublicOutcome;
180
+ export {};
181
+ //# sourceMappingURL=assistant-interaction-state.d.ts.map
@@ -0,0 +1,99 @@
1
+ import { type RuntimeArtifact } from '@noodle-borg/compiler';
2
+ import type { AuditSink } from '@noodle-borg/module';
3
+ import type { CallerIdentity, ConfirmationPreparationResult, ExecuteDeps, InteractiveExecutionResult, InvocationContext, PreparedToolContinuation, ToolContinuation, ToolPreparationContinuation } from '@noodle-borg/runtime';
4
+ import { type AssistantInteractionRecord, type AssistantInteractionTransitionNext, type AssistantPendingConfirmationInteractionRecord, type AssistantPendingInputInteractionRecord } from './assistant-interaction-state.js';
5
+ import type { AssistantSessionRecord, AssistantStore } from './assistant-store.js';
6
+ /**
7
+ * Single-use confirmation lifetime, owned by the admission envelope rather than restated here. The
8
+ * value is unchanged; what changes is that lowering `confirmationTtlMs` now does something, where
9
+ * before the envelope documented a bound this constant silently outranked.
10
+ */
11
+ export declare const ASSISTANT_INTERACTION_TTL_MS: number;
12
+ type InputRequired = Extract<InteractiveExecutionResult, {
13
+ readonly status: 'input_required';
14
+ }> | Extract<ConfirmationPreparationResult, {
15
+ readonly status: 'input_required';
16
+ }>;
17
+ export type AssistantToolDispatch = {
18
+ readonly kind: 'event';
19
+ readonly event: 'tool_proposed' | 'input_requested' | 'error';
20
+ readonly data: Readonly<Record<string, unknown>>;
21
+ } | {
22
+ readonly kind: 'tool_result';
23
+ readonly output: unknown;
24
+ };
25
+ /** Apply the same confirmation and suspend/resume policy to one model-proposed tool call. */
26
+ export declare function dispatchAssistantTool(input: {
27
+ readonly artifact: RuntimeArtifact;
28
+ readonly tool: RuntimeArtifact['tools'][number];
29
+ readonly arguments: unknown;
30
+ readonly executeDeps: ExecuteDeps;
31
+ readonly caller: CallerIdentity;
32
+ readonly context: InvocationContext;
33
+ readonly session: AssistantSessionRecord;
34
+ readonly store: AssistantStore;
35
+ readonly audit: AuditSink;
36
+ readonly now: () => Date;
37
+ readonly onToolStarted?: () => void;
38
+ }): Promise<AssistantToolDispatch>;
39
+ /** Persist a complete, reviewable proposal and its server-only prepared execution state. */
40
+ export declare function createAssistantConfirmationInteraction(input: {
41
+ readonly store: AssistantStore;
42
+ readonly audit: AuditSink;
43
+ readonly session: AssistantSessionRecord;
44
+ readonly context: InvocationContext;
45
+ readonly tool: string;
46
+ readonly arguments: unknown;
47
+ readonly review: unknown;
48
+ readonly continuation: PreparedToolContinuation;
49
+ readonly now: Date;
50
+ }): Promise<AssistantPendingConfirmationInteractionRecord>;
51
+ export declare function assistantConfirmationTransition(input: {
52
+ readonly context: InvocationContext;
53
+ readonly tool: string;
54
+ readonly arguments: unknown;
55
+ readonly review: unknown;
56
+ readonly continuation: PreparedToolContinuation;
57
+ readonly now: Date;
58
+ }): Extract<AssistantInteractionTransitionNext, {
59
+ readonly kind: 'confirmation';
60
+ }>;
61
+ export declare function assistantConfirmationProposalData(interaction: AssistantPendingConfirmationInteractionRecord): Readonly<Record<string, unknown>>;
62
+ /** Persist an opaque input interaction and audit only scalar metadata about the suspension. */
63
+ export declare function createAssistantInputInteraction(input: {
64
+ readonly store: AssistantStore;
65
+ readonly audit: AuditSink;
66
+ readonly session: AssistantSessionRecord;
67
+ readonly context: InvocationContext;
68
+ readonly required: InputRequired;
69
+ readonly now: Date;
70
+ }): Promise<AssistantPendingInputInteractionRecord>;
71
+ export declare function assistantInputTransition(input: {
72
+ readonly context: InvocationContext;
73
+ readonly required: InputRequired;
74
+ readonly now: Date;
75
+ }): Extract<AssistantInteractionTransitionNext, {
76
+ readonly kind: 'input';
77
+ }>;
78
+ /** Emit one tenant-scoped, scalar-only interaction audit record. */
79
+ export declare function auditAssistantInteraction(input: {
80
+ readonly audit: AuditSink;
81
+ readonly session: AssistantSessionRecord;
82
+ readonly interaction: AssistantInteractionRecord;
83
+ readonly eventType: 'assistant.interaction.proposed' | 'assistant.interaction.resolved' | 'assistant.interaction.execution';
84
+ readonly decision: 'allow' | 'deny';
85
+ readonly httpStatus: number;
86
+ readonly status: string;
87
+ readonly action?: 'accept' | 'decline' | 'cancel';
88
+ readonly reasonCode?: string;
89
+ }): Promise<void>;
90
+ export declare function assistantInteractionTool(interaction: AssistantInteractionRecord): string | undefined;
91
+ /** The store is the only trust boundary allowed to deserialize this runtime continuation. */
92
+ export declare function assistantToolContinuation(interaction: Extract<AssistantInteractionRecord, {
93
+ readonly kind: 'input';
94
+ }>): ToolContinuation | ToolPreparationContinuation;
95
+ export declare function assistantPreparedToolContinuation(interaction: Extract<AssistantInteractionRecord, {
96
+ readonly kind: 'confirmation';
97
+ }>): PreparedToolContinuation | undefined;
98
+ export {};
99
+ //# sourceMappingURL=assistant-interactive.d.ts.map
@@ -1,4 +1,4 @@
1
- import { ADMISSION_DEFAULTS } from '@noodle-borg/admission-limits';
1
+ import { ADMISSION_DEFAULTS } from '@noodle-borg/admission-limits/portable';
2
2
  import { requiresToolConfirmation } from '@noodle-borg/compiler';
3
3
  import { evaluateToolAuthorization } from '@noodle-borg/protocol';
4
4
  import { executeToolInteractive, prepareToolForConfirmation } from '@noodle-borg/runtime';
@@ -0,0 +1,35 @@
1
+ import { type ConfirmationReview } from '@noodle-borg/runtime';
2
+ type JsonSchema = Readonly<Record<string, unknown>>;
3
+ type AssistantPresentationScalar = string | number | boolean | null;
4
+ interface AssistantPresentationArray extends ReadonlyArray<AssistantPresentationValue> {
5
+ }
6
+ interface AssistantPresentationObject {
7
+ readonly [key: string]: AssistantPresentationValue;
8
+ }
9
+ export type AssistantPresentationValue = AssistantPresentationScalar | AssistantPresentationArray | AssistantPresentationObject;
10
+ type ArgumentReview = {
11
+ readonly ok: true;
12
+ readonly value: unknown;
13
+ readonly reviewSchema: JsonSchema;
14
+ } | {
15
+ readonly ok: false;
16
+ readonly code: 'arguments_not_presentable';
17
+ };
18
+ /** Derive a client-visible review while retaining the exact validated arguments only in the store. */
19
+ export declare function assistantArgumentReview(schema: JsonSchema, value: unknown): ArgumentReview;
20
+ /** Present the original tool input plus every elicited value that will affect prepared execution. */
21
+ export declare function assistantPreparedArgumentReview(schema: JsonSchema, review: ConfirmationReview): ArgumentReview;
22
+ /** Attach portable display metadata to the already-persisted review JSON without changing execution input. */
23
+ export declare function assistantConfirmationReview(input: {
24
+ readonly title?: string;
25
+ readonly description: string;
26
+ readonly review: Extract<ArgumentReview, {
27
+ readonly ok: true;
28
+ }>;
29
+ }): Readonly<Record<string, unknown>>;
30
+ /** Decode enriched and legacy persisted reviews into the additive public proposal shape. */
31
+ export declare function assistantConfirmationProposal(review: unknown): Readonly<Record<string, unknown>>;
32
+ /** Redact and bound execution output before SSE, history, audit, or model narration. */
33
+ export declare function assistantSafeOutput(schema: JsonSchema | undefined, value: unknown): AssistantPresentationValue;
34
+ export {};
35
+ //# sourceMappingURL=assistant-presentation.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** Catch common credential shapes even when a connector returns them under an innocuous key. */
2
+ export declare function isCredentialShapedAssistantText(value: string): boolean;
3
+ //# sourceMappingURL=assistant-sensitive-values.d.ts.map
@@ -0,0 +1,226 @@
1
+ import type { ArtifactServer } from '@noodle-borg/compiler';
2
+ import type { CallerIdentity } from '@noodle-borg/runtime';
3
+ import type { AssistantContextPreferences } from './assistant-context.js';
4
+ import type { AssistantCustomerRouting } from './assistant-customer-routing.js';
5
+ import { type AssistantInteractionClaimResult, type AssistantInteractionCompletionResult, type AssistantInteractionCreateInput, type AssistantInteractionRecord, type AssistantInteractionScope, type AssistantInteractionTransitionInput, type AssistantInteractionTransitionResult, type AssistantPendingConfirmationInteractionRecord, type AssistantPendingInputInteractionRecord } from './assistant-interaction-state.js';
6
+ import type { TenantRef } from './tenant-ref.js';
7
+ export { ASSISTANT_INTERACTION_EXECUTING_GRACE_MS, ASSISTANT_INTERACTION_OUTCOME_RETENTION_MS, type AssistantConfirmationInteractionRecord, AssistantInteractionCapacityError, type AssistantInteractionClaimResult, type AssistantInteractionCompletion, type AssistantInteractionCompletionResult, type AssistantInteractionCreateInput, type AssistantInteractionKind, type AssistantInteractionPublicArray, type AssistantInteractionPublicObject, type AssistantInteractionPublicOutcome, type AssistantInteractionPublicValue, type AssistantInteractionRecord, type AssistantInteractionScope, type AssistantInteractionStatus, type AssistantInteractionTransitionInput, type AssistantInteractionTransitionNext, type AssistantInteractionTransitionResult, type AssistantPendingConfirmationInteractionRecord, type AssistantPendingInputInteractionRecord, DEFAULT_MAX_PENDING_INTERACTIONS_PER_SESSION, } from './assistant-interaction-state.js';
8
+ export declare const ASSISTANT_SESSION_IDLE_MS: number;
9
+ /**
10
+ * The only `server.assistant` fields that may reach a browser.
11
+ *
12
+ * It lives here, beside the record it types, so the allowlist and the shape it produces cannot drift
13
+ * apart: the projection in `packages/service` iterates this same list. A denylist here would be a type
14
+ * that lies — it once admitted `sessionClaims` key names, and would now admit the public surface's
15
+ * capability allowlist — so growth in the manifest must not be able to grow the browser payload.
16
+ */
17
+ export declare const ASSISTANT_BROWSER_UI_FIELDS: readonly ["layout", "behavior", "labels", "presentation", "suggestedPrompts", "privacyUrl", "termsUrl", "locale", "direction"];
18
+ export interface AssistantClientRecord {
19
+ readonly id: string;
20
+ readonly name: string;
21
+ readonly tenant: TenantRef;
22
+ readonly deploymentId: string;
23
+ readonly allowedOrigins: readonly string[];
24
+ readonly secretHash: string;
25
+ readonly createdAt: string;
26
+ readonly revokedAt?: string;
27
+ }
28
+ export interface AssistantSessionRecord {
29
+ readonly id: string;
30
+ readonly tokenHash: string;
31
+ readonly clientId: string;
32
+ readonly tenant: TenantRef;
33
+ readonly deploymentId: string;
34
+ readonly origin: string;
35
+ readonly caller: CallerIdentity;
36
+ /** Canonical customer endpoint routes; private session authority, never caller or response data. */
37
+ readonly customerRouting?: AssistantCustomerRouting;
38
+ readonly context?: Readonly<Record<string, string | number | boolean | null>>;
39
+ readonly preferences?: AssistantContextPreferences;
40
+ readonly configuration?: {
41
+ readonly branding?: ArtifactServer['branding'];
42
+ readonly assistant?: Pick<NonNullable<ArtifactServer['assistant']>, (typeof ASSISTANT_BROWSER_UI_FIELDS)[number]>;
43
+ };
44
+ /**
45
+ * The public surface this session was minted from, when it was minted anonymously from a page rather
46
+ * than exchanged through a customer backend. It is the key admission spends against, so it stays on
47
+ * the record for the session's whole life — including after a mixed surface elevates the caller, whose
48
+ * turns still belong to the surface that admitted them.
49
+ */
50
+ readonly publicEmbedId?: string;
51
+ /**
52
+ * The intercepted tool a successful elevation may re-attempt as the session's first elevated
53
+ * turn. Armed only in the same statement that elevates; consumed (or mooted by the visitor's
54
+ * first typed turn) exactly once via {@link AssistantStore.consumePendingResume}.
55
+ */
56
+ readonly pendingResume?: AssistantPendingResume;
57
+ readonly createdAt: string;
58
+ readonly expiresAt: string;
59
+ readonly absoluteExpiresAt: string;
60
+ readonly history: AssistantHistoryMessage[];
61
+ /**
62
+ * Model turns already spent. Durable and separate from `history`, which truncates to the last twelve
63
+ * messages: history is a prompt-window trim, never a bound.
64
+ */
65
+ readonly turnCount: number;
66
+ }
67
+ /** The intercepted call a spent sign-in ticket left pending, resumable at most once. */
68
+ export interface AssistantPendingResume {
69
+ readonly tool: string;
70
+ readonly requestedAt: string;
71
+ }
72
+ /** One consumed turn slot, or the refusal that the session has spent its allowance. */
73
+ export interface AssistantTurnConsumption {
74
+ readonly allowed: boolean;
75
+ readonly turnCount: number;
76
+ }
77
+ export interface AssistantHistoryMessage {
78
+ readonly role: 'user' | 'assistant';
79
+ readonly content: string;
80
+ }
81
+ export type AssistantSessionElevation = {
82
+ readonly ok: true;
83
+ readonly session: AssistantSessionRecord;
84
+ /** The replacement token. The value it replaces is dead the moment this returns. */
85
+ readonly token: string;
86
+ } | {
87
+ readonly ok: false;
88
+ readonly reason: 'unknown_session' | 'already_elevated';
89
+ };
90
+ export interface AssistantStore {
91
+ createClient(input: {
92
+ readonly name: string;
93
+ readonly tenant: TenantRef;
94
+ readonly deploymentId: string;
95
+ readonly allowedOrigins: readonly string[];
96
+ readonly now: Date;
97
+ }): Promise<{
98
+ readonly client: AssistantClientRecord;
99
+ readonly secret: string;
100
+ }>;
101
+ listClients(tenant: TenantRef): Promise<readonly AssistantClientRecord[]>;
102
+ rotateClient(id: string, now: Date): Promise<{
103
+ readonly client: AssistantClientRecord;
104
+ readonly secret: string;
105
+ } | undefined>;
106
+ revokeClient(id: string, now: Date): Promise<boolean>;
107
+ authenticateClient(id: string, secret: string): Promise<AssistantClientRecord | undefined>;
108
+ createSession(input: Omit<AssistantSessionRecord, 'id' | 'tokenHash' | 'history' | 'turnCount'>): Promise<{
109
+ readonly session: AssistantSessionRecord;
110
+ readonly token: string;
111
+ }>;
112
+ /**
113
+ * Spend one turn if the session has one left, atomically. This is one seam rather than a
114
+ * read-then-write in the route because two turns arriving together at the last slot is precisely the
115
+ * race a read-then-write loses. A refused turn does not advance the count.
116
+ */
117
+ consumeTurn(id: string, limit: number): Promise<AssistantTurnConsumption>;
118
+ /**
119
+ * Bind an already-open conversation to a signed-in caller (ADR 0201, 5.6b).
120
+ *
121
+ * One seam, and one row: the session is **mutated in place** rather than replaced, so the visitor
122
+ * keeps the conversation they were having. The old token dies with the same statement that installs
123
+ * the new one, which is why this is not a read-then-write — an elevation that left the anonymous
124
+ * token briefly alive would be a window in which both identities could act.
125
+ *
126
+ * `publicEmbedId` is deliberately retained: admission keeps charging the surface that admitted the
127
+ * visitor, exactly as 5.4 designed when it chose to key sessions on the embed rather than on being
128
+ * anonymous. Refuses when the session is already non-anonymous, which is what makes a second
129
+ * elevation impossible without a separate check to forget.
130
+ */
131
+ elevateSession(input: {
132
+ readonly sessionId: string;
133
+ readonly caller: AssistantSessionRecord['caller'];
134
+ /** The elevating client: becomes the session's delegated-credential issuer basis (ADR 0152). */
135
+ readonly clientId: string;
136
+ /** Allowlist-validated by the route: becomes the session's CORS pin, where the conversation continues. */
137
+ readonly origin: string;
138
+ /** Backend-verified customer routes; absent means unchanged, never cleared. */
139
+ readonly customerRouting?: AssistantSessionRecord['customerRouting'];
140
+ /** Arms the one-shot resume of the intercepted tool, in the same statement that elevates. */
141
+ readonly pendingResume?: AssistantPendingResume;
142
+ readonly now: Date;
143
+ }): Promise<AssistantSessionElevation>;
144
+ /**
145
+ * Clear and return the pending resume exactly once, atomically — the turn route calls this both
146
+ * to run the resume and to moot it when the visitor types first, and two requests racing the
147
+ * same arm must not both see it.
148
+ */
149
+ consumePendingResume(sessionId: string): Promise<AssistantPendingResume | undefined>;
150
+ getSession(token: string, now: Date): Promise<AssistantSessionRecord | undefined>;
151
+ appendHistory(id: string, messages: readonly AssistantHistoryMessage[]): Promise<void>;
152
+ createInteraction(input: Extract<AssistantInteractionCreateInput, {
153
+ readonly kind: 'confirmation';
154
+ }>): Promise<AssistantPendingConfirmationInteractionRecord>;
155
+ createInteraction(input: Extract<AssistantInteractionCreateInput, {
156
+ readonly kind: 'input';
157
+ }>): Promise<AssistantPendingInputInteractionRecord>;
158
+ claimInteraction(input: AssistantInteractionScope): Promise<AssistantInteractionClaimResult>;
159
+ completeInteraction(input: AssistantInteractionScope & {
160
+ readonly completion: import('./assistant-interaction-state.js').AssistantInteractionCompletion;
161
+ }): Promise<AssistantInteractionCompletionResult>;
162
+ transitionInteraction(input: AssistantInteractionTransitionInput): Promise<AssistantInteractionTransitionResult>;
163
+ getInteraction(input: AssistantInteractionScope): Promise<AssistantInteractionRecord | undefined>;
164
+ /** @deprecated Temporary compatibility for the accept-only route while it moves to claim/complete. */
165
+ consumeInteraction(id: string, sessionId: string, deploymentId: string, now: Date): Promise<(import('./assistant-interaction-state.js').AssistantConfirmationInteractionRecord & {
166
+ readonly status: 'executing';
167
+ }) | undefined>;
168
+ consumeConsoleApprovalNonce(nonce: string, subject: string, expiresAt: Date, now: Date): Promise<boolean>;
169
+ }
170
+ export declare class InMemoryAssistantStore implements AssistantStore {
171
+ #private;
172
+ constructor(options?: {
173
+ readonly maxPendingInteractionsPerSession?: number;
174
+ });
175
+ createClient(input: {
176
+ readonly name: string;
177
+ readonly tenant: TenantRef;
178
+ readonly deploymentId: string;
179
+ readonly allowedOrigins: readonly string[];
180
+ readonly now: Date;
181
+ }): Promise<{
182
+ readonly client: AssistantClientRecord;
183
+ readonly secret: string;
184
+ }>;
185
+ listClients(tenant: TenantRef): Promise<readonly AssistantClientRecord[]>;
186
+ rotateClient(id: string, now: Date): Promise<{
187
+ readonly client: AssistantClientRecord;
188
+ readonly secret: string;
189
+ } | undefined>;
190
+ revokeClient(id: string, now: Date): Promise<boolean>;
191
+ authenticateClient(id: string, secret: string): Promise<AssistantClientRecord | undefined>;
192
+ createSession(input: Omit<AssistantSessionRecord, 'id' | 'tokenHash' | 'history' | 'turnCount'>): Promise<{
193
+ readonly session: AssistantSessionRecord;
194
+ readonly token: string;
195
+ }>;
196
+ elevateSession(input: {
197
+ readonly sessionId: string;
198
+ readonly caller: AssistantSessionRecord['caller'];
199
+ readonly clientId: string;
200
+ readonly origin: string;
201
+ readonly customerRouting?: AssistantSessionRecord['customerRouting'];
202
+ readonly pendingResume?: AssistantPendingResume;
203
+ readonly now: Date;
204
+ }): Promise<AssistantSessionElevation>;
205
+ consumePendingResume(sessionId: string): Promise<AssistantPendingResume | undefined>;
206
+ consumeTurn(id: string, limit: number): Promise<AssistantTurnConsumption>;
207
+ getSession(token: string, now: Date): Promise<AssistantSessionRecord | undefined>;
208
+ appendHistory(id: string, messages: readonly AssistantHistoryMessage[]): Promise<void>;
209
+ createInteraction(input: Extract<AssistantInteractionCreateInput, {
210
+ readonly kind: 'confirmation';
211
+ }>): Promise<AssistantPendingConfirmationInteractionRecord>;
212
+ createInteraction(input: Extract<AssistantInteractionCreateInput, {
213
+ readonly kind: 'input';
214
+ }>): Promise<AssistantPendingInputInteractionRecord>;
215
+ claimInteraction(input: AssistantInteractionScope): Promise<AssistantInteractionClaimResult>;
216
+ completeInteraction(input: AssistantInteractionScope & {
217
+ readonly completion: import('./assistant-interaction-state.js').AssistantInteractionCompletion;
218
+ }): Promise<AssistantInteractionCompletionResult>;
219
+ transitionInteraction(input: AssistantInteractionTransitionInput): Promise<AssistantInteractionTransitionResult>;
220
+ getInteraction(input: AssistantInteractionScope): Promise<AssistantInteractionRecord | undefined>;
221
+ consumeInteraction(id: string, sessionId: string, deploymentId: string, now: Date): Promise<(import('./assistant-interaction-state.js').AssistantConfirmationInteractionRecord & {
222
+ readonly status: 'executing';
223
+ }) | undefined>;
224
+ consumeConsoleApprovalNonce(nonce: string, subject: string, expiresAt: Date, now: Date): Promise<boolean>;
225
+ }
226
+ //# sourceMappingURL=assistant-store.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { createHash, randomBytes, randomUUID, timingSafeEqual } from 'node:crypto';
2
- import { ADMISSION_DEFAULTS } from '@noodle-borg/admission-limits';
2
+ import { ADMISSION_DEFAULTS } from '@noodle-borg/admission-limits/portable';
3
3
  import { AssistantInteractionCapacityError, cloneInteraction, completedInteraction, createPendingInteraction, DEFAULT_MAX_PENDING_INTERACTIONS_PER_SESSION, executingInteraction, expireStrandedExecutingInteraction, isPrunableInteraction, isTerminalInteraction, shouldExpireStrandedExecutingInteraction, transitionedInteractions, } from './assistant-interaction-state.js';
4
4
  export { ASSISTANT_INTERACTION_EXECUTING_GRACE_MS, ASSISTANT_INTERACTION_OUTCOME_RETENTION_MS, AssistantInteractionCapacityError, DEFAULT_MAX_PENDING_INTERACTIONS_PER_SESSION, } from './assistant-interaction-state.js';
5
5
  export const ASSISTANT_SESSION_IDLE_MS = 30 * 60 * 1000;