@peer-agent/protocol 0.1.0-rc.4 → 0.1.0-rc.41

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 (86) hide show
  1. package/dist/acceptance-close-gate.d.ts +10 -1
  2. package/dist/acceptance-close-gate.js +12 -0
  3. package/dist/agent-supervision.d.ts +81 -0
  4. package/dist/agent-supervision.js +1 -0
  5. package/dist/attention.d.ts +44 -0
  6. package/dist/attention.js +1 -0
  7. package/dist/bot-access-policy.d.ts +29 -0
  8. package/dist/bot-access-policy.js +1 -0
  9. package/dist/bot-conversation-read.d.ts +25 -0
  10. package/dist/bot-conversation-read.js +9 -0
  11. package/dist/bot-model-selection.d.ts +13 -0
  12. package/dist/bot-model-selection.js +1 -0
  13. package/dist/browser-window.d.ts +48 -0
  14. package/dist/browser-window.js +23 -0
  15. package/dist/capability-admission.d.ts +20 -0
  16. package/dist/capability-admission.js +1 -0
  17. package/dist/delegation-coordination.d.ts +81 -0
  18. package/dist/delegation-coordination.js +1 -0
  19. package/dist/delegation.d.ts +216 -7
  20. package/dist/delegation.js +43 -39
  21. package/dist/document-reference.d.ts +83 -0
  22. package/dist/document-reference.js +1 -0
  23. package/dist/evidence-inspection.d.ts +64 -0
  24. package/dist/evidence-inspection.js +1 -0
  25. package/dist/goal.d.ts +50 -2
  26. package/dist/index.d.ts +56 -5
  27. package/dist/index.js +25 -0
  28. package/dist/input-prediction.d.ts +86 -0
  29. package/dist/input-prediction.js +48 -0
  30. package/dist/intent-coordination.d.ts +201 -0
  31. package/dist/intent-coordination.js +1 -0
  32. package/dist/interactive-result.d.ts +363 -0
  33. package/dist/interactive-result.js +215 -0
  34. package/dist/interactive-verification.d.ts +41 -0
  35. package/dist/interactive-verification.js +65 -0
  36. package/dist/local-git.d.ts +44 -0
  37. package/dist/local-git.js +3 -0
  38. package/dist/local-image.d.ts +53 -0
  39. package/dist/local-image.js +5 -0
  40. package/dist/model-reasoning.d.ts +13 -0
  41. package/dist/model-reasoning.js +18 -0
  42. package/dist/model-routing.d.ts +37 -3
  43. package/dist/model-routing.js +31 -5
  44. package/dist/project-agent-failure.d.ts +30 -0
  45. package/dist/project-agent-failure.js +44 -0
  46. package/dist/project-input-recovery.d.ts +65 -0
  47. package/dist/project-input-recovery.js +5 -0
  48. package/dist/project-recovery.d.ts +43 -0
  49. package/dist/project-recovery.js +1 -0
  50. package/dist/project.d.ts +81 -0
  51. package/dist/project.js +8 -5
  52. package/dist/remote-access.d.ts +15 -0
  53. package/dist/remote-access.js +1 -1
  54. package/dist/reply-delivery.d.ts +28 -0
  55. package/dist/reply-delivery.js +1 -0
  56. package/dist/resource-edit-execution.d.ts +68 -0
  57. package/dist/resource-edit-execution.js +96 -0
  58. package/dist/resource-edit.d.ts +237 -0
  59. package/dist/resource-edit.js +134 -0
  60. package/dist/resource-feedback-transport.d.ts +25 -0
  61. package/dist/resource-feedback-transport.js +93 -0
  62. package/dist/resource-feedback.d.ts +98 -0
  63. package/dist/resource-feedback.js +151 -0
  64. package/dist/resource-file-replace.d.ts +36 -0
  65. package/dist/resource-file-replace.js +40 -0
  66. package/dist/resource-reference-hints.d.ts +3 -0
  67. package/dist/resource-reference-hints.js +58 -0
  68. package/dist/resource-window.d.ts +222 -0
  69. package/dist/resource-window.js +252 -0
  70. package/dist/runtime-session-facts.d.ts +58 -0
  71. package/dist/runtime-session-facts.js +55 -0
  72. package/dist/session-control.d.ts +196 -0
  73. package/dist/session-control.js +48 -0
  74. package/dist/session-facts.d.ts +29 -0
  75. package/dist/session-facts.js +35 -0
  76. package/dist/system-context.d.ts +6 -0
  77. package/dist/task-overview.d.ts +90 -0
  78. package/dist/task-overview.js +322 -17
  79. package/dist/tool-activity-preview.d.ts +4 -0
  80. package/dist/tool-activity-preview.js +72 -0
  81. package/dist/usage-accounting.d.ts +1 -1
  82. package/dist/user-anchor.d.ts +17 -0
  83. package/dist/user-anchor.js +1 -0
  84. package/dist/work-coordination.d.ts +165 -0
  85. package/dist/work-coordination.js +1 -0
  86. package/package.json +1 -1
package/dist/goal.d.ts CHANGED
@@ -163,10 +163,11 @@ export interface EvidenceIndexRecord {
163
163
  readonly capabilityId?: string;
164
164
  readonly toolName?: string;
165
165
  readonly createdAt: string;
166
+ readonly interactiveInspection?: import('./interactive-verification.ts').InteractiveInspectionReceipt;
166
167
  readonly artifactRefs?: readonly string[];
167
168
  /** Redacted, bounded execution-time snapshot of a successful local Tool Result. */
168
169
  readonly bodyPreview?: {
169
- readonly kind: 'file' | 'command';
170
+ readonly kind: 'file' | 'command' | 'observation';
170
171
  readonly text: string;
171
172
  readonly truncated: boolean;
172
173
  };
@@ -444,14 +445,30 @@ export interface GoalRunTrace {
444
445
  readonly lastCheckpointNodeId?: string;
445
446
  readonly events: readonly GoalRunEvent[];
446
447
  }
447
- export type GoalSuccessCriterionKind = 'command' | 'test' | 'file-contains' | 'file-exists' | 'manual';
448
+ export type GoalSuccessCriterionKind = 'command' | 'test' | 'file-contains' | 'file-exists' | 'model_review' | 'manual';
448
449
  export interface GoalSuccessCriterion {
450
+ readonly requiredCapabilities?: readonly string[];
449
451
  readonly id: string;
450
452
  readonly kind: GoalSuccessCriterionKind;
451
453
  readonly description: string;
452
454
  readonly command?: string;
453
455
  readonly path?: string;
454
456
  readonly expect?: string;
457
+ readonly authority?: {
458
+ readonly source: 'model' | 'user' | 'project_policy' | 'legacy_unknown';
459
+ readonly sourceRef?: string;
460
+ readonly version: number;
461
+ readonly verifier: 'mechanical' | 'host_model' | 'human';
462
+ readonly rationale: string;
463
+ };
464
+ }
465
+ export interface GoalModelReview {
466
+ readonly criterionId: string;
467
+ readonly sourceRevision: string;
468
+ readonly verifierRunId: string;
469
+ readonly passed: boolean;
470
+ readonly evidenceRefs: readonly string[];
471
+ readonly checkedAt: string;
455
472
  }
456
473
  export interface GoalCriterionResult {
457
474
  readonly criterionId: string;
@@ -567,6 +584,33 @@ export interface GoalExecutionCheckpoint {
567
584
  }
568
585
  /** GoalPlan 内嵌的轻量 runner 状态;不代表工具执行事实,任务完成仍必须由 Evidence 回写。 */
569
586
  export interface GoalRunnerState {
587
+ /** Host-owned readonly review continuity. Native messages stay in registered checkpoint storage. */
588
+ readonly verificationContinuation?: {
589
+ readonly schemaVersion: 1;
590
+ readonly policyVersion?: 2;
591
+ readonly planId: string;
592
+ readonly continuationId: string;
593
+ readonly sourceRevision: string;
594
+ readonly modelKey: string;
595
+ readonly workId?: string;
596
+ readonly phase: 'ready' | 'requesting' | 'tools' | 'completed';
597
+ /** Current slice deadline; legacy review-wide deadlines are renewed only on safe admission. */
598
+ readonly deadlineAt: string;
599
+ readonly modelRequests: number;
600
+ readonly toolCalls: number;
601
+ readonly formatAttempt: number;
602
+ readonly previousText?: string;
603
+ readonly checkpointRef?: string;
604
+ readonly evidenceRefs: readonly string[];
605
+ readonly fingerprint?: string;
606
+ readonly repeats?: number;
607
+ readonly progressFacts?: readonly string[];
608
+ readonly startedAt?: string;
609
+ readonly lastProgressAt?: string;
610
+ readonly observationCount?: number;
611
+ readonly observationFacts?: readonly string[];
612
+ readonly formatRequests?: number;
613
+ };
570
614
  readonly enabled: boolean;
571
615
  readonly status: GoalRunnerStatus;
572
616
  readonly intent?: GoalRunnerIntent;
@@ -616,6 +660,7 @@ export interface GoalRunnerState {
616
660
  * 中断在计划状态重派生时被误判为完成。
617
661
  */
618
662
  readonly interruption?: {
663
+ readonly origin?: import('./agent-supervision.ts').InterruptionOrigin;
619
664
  readonly source: string;
620
665
  readonly reason: string;
621
666
  readonly interruptedAt: string;
@@ -678,6 +723,9 @@ export interface GoalPlan {
678
723
  readonly successCriteria: readonly GoalSuccessCriterion[];
679
724
  readonly criterionResults: readonly GoalCriterionResult[];
680
725
  readonly manualConfirmations?: readonly GoalManualConfirmation[];
726
+ readonly modelReviews?: readonly GoalModelReview[];
727
+ /** Host-derived current revision for checking semantic review freshness. */
728
+ readonly modelReviewSourceRevision?: string;
681
729
  readonly boundaries: GoalBoundaries;
682
730
  readonly exceptionPolicies: ExceptionPolicy[];
683
731
  /** 顶层汇总(来源于子任务) */
package/dist/index.d.ts CHANGED
@@ -1,14 +1,25 @@
1
- export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead } from './selection-reference.ts';
1
+ export type { AttentionCard, BotDecisionSnapshot, BotAttentionItem, BotAttentionRequest, BotAttentionResult } from './attention.ts';
2
+ export type { ProjectWorkBudgetLimits, ProjectWorkBudgetBoundary, ProjectReplyRecoveryAction, ProjectWorkReceipt, ProjectWorkRecovery, ProjectWorkState, ProjectTurnEnd, ProjectReplyFailureStatus, ProjectAgentSilentWait, } from './work-coordination.ts';
3
+ export type { CoordinationAction, CoordinationLifecycle, CoordinationMandate, CoordinationDecision, TaskTransitionPhase, TaskTransition, CoordinationExecutionBinding, CoordinationSessionFacts, } from './delegation-coordination.ts';
4
+ export { deriveSessionFacts, type SessionFactSnapshot } from './session-facts.ts';
5
+ export { runtimeSessionFacts, runtimeSessionOwnership, hasPendingRuntimeSessions } from './runtime-session-facts.ts';
6
+ export type { RuntimeHandling, RuntimeSessionFacts, RuntimeSessionOwnership, ResourceWaitScope, ResourceWaitReference, ResourceWaitFact, ResourceWaitInspection, ResourceWaitPort } from './runtime-session-facts.ts';
7
+ export { projectAgentFailureKind, classifyProjectAgentFailure, type ProjectRecoveryFailureKind, type ProviderRequestRecovery, type ProjectAgentTurnRecovery, type ReplyAnchorCandidate } from './project-agent-failure.ts';
8
+ export type { EvidenceSourceDescription, EvidenceDeliveryBinding, EvidenceDelivery, ProjectAgentEvidenceReadRequest, ProjectAgentEvidenceReadResult } from './evidence-inspection.ts';
9
+ export { toolActivityPreview, toolActivitySummary } from './tool-activity-preview.ts';
10
+ export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort, type ModelReasoningEffort } from './model-reasoning.ts';
11
+ export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead, } from './selection-reference.ts';
2
12
  export { buildModelMenuGroups, modelMenuChannelName, type ModelMenuRow } from './model-menu.ts';
3
13
  export { evaluateUiDelivery } from './ui-delivery-verification.ts';
4
14
  export { DESKTOP_PREVIEW_PROTOCOL, DESKTOP_PREVIEW_CAPABILITY, DESKTOP_PREVIEW_TOOL } from './desktop-preview.ts';
5
15
  export type { DesktopPreviewRequest, DesktopPreviewReply } from './desktop-preview.ts';
6
- export type { UiDeliveryIdentity, UiDeliveryRequirement, UiDeliveryObservation, UiDeliveryJudgment, UiDeliveryGap } from './ui-delivery-verification.ts';
16
+ export type { UiDeliveryIdentity, UiDeliveryRequirement, UiDeliveryObservation, UiDeliveryJudgment, UiDeliveryGap, } from './ui-delivery-verification.ts';
7
17
  export { REMOTE_PROTOCOL_VERSION, parseRemoteReadRequest, admitRemoteRead } from './remote-access.ts';
8
18
  export type { RemoteReadRequest, RemoteReadContext, RemoteReadRejection, RemoteReadAdmission } from './remote-access.ts';
9
19
  export { REMOTE_PROJECT_LIMITS, parseRemoteProjectRequest, admitRemoteProject, parseRemoteDelegationProjection } from './remote-access.ts';
10
- export type { RemoteProjectGrant, RemoteProjectRequest, RemoteProjectContext, RemoteProjectRejection, RemoteProjectAdmission, RemoteDelegationProjection } from './remote-access.ts';
20
+ export type { RemoteProjectGrant, RemoteProjectRequest, RemoteProjectInteractiveResult, RemoteProjectContext, RemoteProjectRejection, RemoteProjectAdmission, RemoteDelegationProjection, } from './remote-access.ts';
11
21
  export type LocalAccessLevel = 'ask_before_local' | 'session_local' | 'restricted_local' | 'full_local';
22
+ export type { BotAccessPolicy, BotAccessPolicyReadRequest, BotAccessPolicyUpdateRequest, BotAccessPolicyResult } from './bot-access-policy.ts';
12
23
  export type { ConversationLifetimeUsage, ProviderRequestUsage, RuntimeTurnUsage, UsageAmounts, UsageScope, } from './usage-accounting.ts';
13
24
  export type CapabilityRiskLevel = 'L0_inert' | 'L1_local_read' | 'L2_local_write' | 'L3_external_write' | 'L4_privileged' | 'L5_destructive';
14
25
  export type DataLevel = 'D0_public' | 'D1_internal' | 'D2_sensitive' | 'D3_private' | 'D4_regulated';
@@ -430,7 +441,7 @@ export interface LlmOAuthStatus {
430
441
  readonly accountId?: string;
431
442
  readonly expiresAt?: string;
432
443
  }
433
- export type { AccountUsageSource, AccountUsageScope, AccountUsageBalance, AccountUsageSpend, AccountUsageUnavailable, AccountUsageLocal } from './account-usage.js';
444
+ export type { AccountUsageSource, AccountUsageScope, AccountUsageBalance, AccountUsageSpend, AccountUsageUnavailable, AccountUsageLocal, } from './account-usage.js';
434
445
  /** 订阅额度窗口(session / weekly / model 等)。 */
435
446
  export interface LlmSubscriptionQuotaWindow {
436
447
  readonly id: string;
@@ -691,6 +702,7 @@ export interface RuntimeToolCall {
691
702
  readonly argumentsPreview?: unknown;
692
703
  readonly [key: string]: unknown;
693
704
  }
705
+ export type { UserAnchorResolution, UserAnchorCandidate, UserAnchorDiagnostic } from './user-anchor.ts';
694
706
  export interface RuntimeToolResult {
695
707
  readonly toolCallId?: string;
696
708
  readonly status?: string;
@@ -718,6 +730,18 @@ export interface ClientToolCall extends RuntimeToolCall {
718
730
  readonly dataLevel: DataLevel;
719
731
  readonly requestedAt: string;
720
732
  }
733
+ /** Host permission wait events. Requests are presentation, never permission truth. */
734
+ export interface ChatPermissionRequest {
735
+ readonly streamId: string;
736
+ readonly call: ClientToolCall;
737
+ readonly deadlineAt?: string;
738
+ }
739
+ export interface ChatPermissionSettled {
740
+ readonly streamId: string;
741
+ readonly toolCallIds: readonly string[];
742
+ readonly granted?: boolean;
743
+ readonly reason?: string;
744
+ }
721
745
  export interface ClientToolCallPollRequest {
722
746
  readonly sessionId: string;
723
747
  readonly projectionId?: string;
@@ -733,11 +757,13 @@ export interface ClientToolCallPollResult {
733
757
  }
734
758
  export type PermissionDuration = 'once' | 'task' | 'session' | 'scope' | 'persistent' | 'denied';
735
759
  export interface PermissionGrant {
760
+ /** Host-issued policy version; audit provenance, never a client authority token. */
761
+ readonly policyRevision?: string;
736
762
  readonly grantId: string;
737
763
  readonly toolCallId: string;
738
764
  readonly granted: boolean;
739
765
  readonly duration: PermissionDuration;
740
- readonly scope?: string;
766
+ readonly scope?: string | import('./local-image.ts').LocalImagePermissionScope;
741
767
  readonly decidedAt: string;
742
768
  }
743
769
  /** Application-owned shell process snapshot. Source conversation is provenance, not ownership. */
@@ -867,6 +893,31 @@ export * from './task-overview.ts';
867
893
  export * from './skill-marketplace.ts';
868
894
  export * from './delegation.ts';
869
895
  export * from './model-routing.ts';
896
+ export * from './document-reference.ts';
870
897
  export * from './project.ts';
871
898
  export * from './objectives.ts';
872
899
  export * from './remote-access-settings.ts';
900
+ export type { BotModelSelectionUpdateRequest, BotModelSelectionUpdateResult } from './bot-model-selection.ts';
901
+ export * from './local-image.ts';
902
+ export * from './bot-conversation-read.ts';
903
+ export * from './project-recovery.ts';
904
+ export * from './local-git.ts';
905
+ export * from './agent-supervision.ts';
906
+ export type { CapabilityBlocker, DelegationCapabilityAdmission } from './capability-admission.ts';
907
+ export * from './project-input-recovery.ts';
908
+ export { botResourceReferences } from './resource-reference-hints.ts';
909
+ export type { ResourceWindowCheckpointRequest, ResourceWindowCheckpointAck, ResourceWindowCloseBlocked, ResourceWindowReturnRequest, ResourceWindowReturnAck, ResourceWindowHistoryEntry, ResourceWindowHistoryResult, ResourceWindowReadRequest, ResourceWindowReadResult, ResourceWindowResource, ResourceWindowNavigation, ResourceWindowOpenRequest, ResourceWindowOwner, ResourceWindowIdentity, ResourceWindowContext, ResourceWindowStatus, ResourceWindowResult } from './resource-window.ts';
910
+ export { normalizeResourceWindowRequest, normalizeResourceWindowOwner, normalizeResourceWindowNavigation, resourceWindowWorkspaceId, resourceWindowTask, normalizeResourceLayout, normalizeResourceLayoutSnapshot, normalizeResourceInteractiveSession, normalizeResourceRecentReference, interactiveReferenceKey } from './resource-window.ts';
911
+ export type { ResourceLayoutSnapshot, ResourcePresentationApi, ResourceInteractiveTab, ResourceInteractiveSession, ResourceRecentReference } from './resource-window.ts';
912
+ export * from './browser-window.js';
913
+ export * from './resource-feedback.js';
914
+ export * from './resource-feedback-transport.js';
915
+ export * from './resource-edit.ts';
916
+ export * from './resource-file-replace.ts';
917
+ export * from './resource-edit-execution.ts';
918
+ export { decideFollowUp, type FollowUpOwner, type FollowUpReason, type FollowUpProjection } from './task-overview.ts';
919
+ export type { SessionExecutionIdentity, StopBarrierReceipt, SessionControlOperation, ExecutionResourceBlocker, ExecutionClaimClosure, ExecutionResourceClaim, ExecutionResourceScope, UnknownOutcomePolicy, UnknownOutcomePolicyTier, UnknownOutcomeResolution, UnknownOutcomeResolutionTier, ReconciliationEvidence, ReconciliationProbe, ReconciliationProbeKind, ReconciliationVerdict } from './session-control.ts';
920
+ export { controlPhasesForOrigin, normalizeSessionExecutionIdentity, normalizeExecutionResourceScope } from './session-control.ts';
921
+ export * from './input-prediction.ts';
922
+ export * from './interactive-result.ts';
923
+ export * from './interactive-verification.ts';
package/dist/index.js CHANGED
@@ -1,3 +1,8 @@
1
+ export { deriveSessionFacts } from "./session-facts.js";
2
+ export { runtimeSessionFacts, runtimeSessionOwnership, hasPendingRuntimeSessions } from "./runtime-session-facts.js";
3
+ export { projectAgentFailureKind, classifyProjectAgentFailure } from "./project-agent-failure.js";
4
+ export { toolActivityPreview, toolActivitySummary } from "./tool-activity-preview.js";
5
+ export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort } from "./model-reasoning.js";
1
6
  export { buildModelMenuGroups, modelMenuChannelName } from "./model-menu.js";
2
7
  export { evaluateUiDelivery } from "./ui-delivery-verification.js";
3
8
  export { DESKTOP_PREVIEW_PROTOCOL, DESKTOP_PREVIEW_CAPABILITY, DESKTOP_PREVIEW_TOOL } from "./desktop-preview.js";
@@ -34,6 +39,26 @@ export * from "./task-overview.js";
34
39
  export * from "./skill-marketplace.js";
35
40
  export * from "./delegation.js";
36
41
  export * from "./model-routing.js";
42
+ export * from "./document-reference.js";
37
43
  export * from "./project.js";
38
44
  export * from "./objectives.js";
39
45
  export * from "./remote-access-settings.js";
46
+ export * from "./local-image.js";
47
+ export * from "./bot-conversation-read.js";
48
+ export * from "./project-recovery.js";
49
+ export * from "./local-git.js";
50
+ export * from "./agent-supervision.js";
51
+ export * from "./project-input-recovery.js";
52
+ export { botResourceReferences } from "./resource-reference-hints.js";
53
+ export { normalizeResourceWindowRequest, normalizeResourceWindowOwner, normalizeResourceWindowNavigation, resourceWindowWorkspaceId, resourceWindowTask, normalizeResourceLayout, normalizeResourceLayoutSnapshot, normalizeResourceInteractiveSession, normalizeResourceRecentReference, interactiveReferenceKey } from "./resource-window.js";
54
+ export * from './browser-window.js';
55
+ export * from './resource-feedback.js';
56
+ export * from './resource-feedback-transport.js';
57
+ export * from "./resource-edit.js";
58
+ export * from "./resource-file-replace.js";
59
+ export * from "./resource-edit-execution.js";
60
+ export { decideFollowUp } from "./task-overview.js";
61
+ export { controlPhasesForOrigin, normalizeSessionExecutionIdentity, normalizeExecutionResourceScope } from "./session-control.js";
62
+ export * from "./input-prediction.js";
63
+ export * from "./interactive-result.js";
64
+ export * from "./interactive-verification.js";
@@ -0,0 +1,86 @@
1
+ /** Suggestions are ephemeral presentation data, never input receipts or grants. */
2
+ export type InputPredictionMode = 'next_turn' | 'continuation';
3
+ export type InputPredictionSurface = 'desktop_bot' | 'desktop_classic';
4
+ export interface InputPredictionSettings {
5
+ readonly schemaVersion: 1;
6
+ readonly enabled: boolean;
7
+ readonly continuationEnabled: boolean;
8
+ readonly disabledWorkspaceIds: readonly string[];
9
+ readonly dailyRequestLimit: number;
10
+ readonly dailyTokenLimit: number;
11
+ }
12
+ export declare const INPUT_PREDICTION_LIMITS: Readonly<{
13
+ inputTokens: 4096;
14
+ outputTokens: 128;
15
+ draftLength: 2048;
16
+ candidateLength: 240;
17
+ candidateGraphemes: 120;
18
+ timeoutMs: 2000;
19
+ validationMs: 150;
20
+ ttlMs: 60000;
21
+ requestIntervalMs: 3000;
22
+ requestsPerMinute: 12;
23
+ }>;
24
+ export declare function normalizeInputPredictionSettings(value: unknown): InputPredictionSettings;
25
+ export interface InputPredictionRequest {
26
+ readonly requestId: string;
27
+ readonly workspaceId: string;
28
+ readonly conversationId: string;
29
+ readonly composerInstanceId: string;
30
+ readonly surface: InputPredictionSurface;
31
+ readonly mode: InputPredictionMode;
32
+ readonly draftVersion: number;
33
+ readonly draftText: string;
34
+ readonly selectionStart: number;
35
+ readonly selectionEnd: number;
36
+ readonly quoteMessageId?: string;
37
+ }
38
+ export interface InputCandidate {
39
+ readonly candidateId: string;
40
+ readonly requestId: string;
41
+ readonly workspaceId: string;
42
+ readonly conversationId: string;
43
+ readonly composerInstanceId: string;
44
+ readonly mode: InputPredictionMode;
45
+ readonly insertionText: string;
46
+ readonly draftVersion: number;
47
+ /** Host context identity only. This conveys no permission. */
48
+ readonly contextToken: string;
49
+ readonly expiresAt: string;
50
+ }
51
+ export type InputPredictionResult = {
52
+ readonly kind: 'candidate';
53
+ readonly candidate: InputCandidate;
54
+ } | {
55
+ readonly kind: 'none';
56
+ readonly reason: string;
57
+ } | {
58
+ readonly kind: 'unavailable';
59
+ readonly reason: string;
60
+ } | {
61
+ readonly kind: 'cancelled';
62
+ } | {
63
+ readonly kind: 'error';
64
+ readonly code: string;
65
+ };
66
+ export interface InputPredictionReference {
67
+ readonly composerInstanceId: string;
68
+ readonly requestId: string;
69
+ readonly candidateId?: string;
70
+ }
71
+ export type InputPredictionValidation = {
72
+ readonly kind: 'valid' | 'stale' | 'expired' | 'unavailable';
73
+ };
74
+ export interface InputPredictionPort {
75
+ request(request: InputPredictionRequest): Promise<InputPredictionResult>;
76
+ cancel(reference: InputPredictionReference): Promise<unknown>;
77
+ validate(reference: InputPredictionReference): Promise<InputPredictionValidation>;
78
+ }
79
+ export interface InputPredictionStatus {
80
+ readonly reason: 'ready' | 'disabled' | 'model_unconfigured' | 'budget' | 'usage_unavailable' | 'provider_error';
81
+ readonly requests: number;
82
+ readonly tokens: number;
83
+ readonly estimated: boolean;
84
+ }
85
+ export declare function isInputPredictionRequest(value: unknown): value is InputPredictionRequest;
86
+ export declare function isInputPredictionReference(value: unknown): value is InputPredictionReference;
@@ -0,0 +1,48 @@
1
+ export const INPUT_PREDICTION_LIMITS = Object.freeze({
2
+ inputTokens: 4096, outputTokens: 128, draftLength: 2048,
3
+ candidateLength: 240, candidateGraphemes: 120,
4
+ timeoutMs: 2000, validationMs: 150, ttlMs: 60_000,
5
+ requestIntervalMs: 3000, requestsPerMinute: 12,
6
+ });
7
+ export function normalizeInputPredictionSettings(value) {
8
+ const raw = value && typeof value === 'object' && !Array.isArray(value) ? value : {};
9
+ const supported = (value == null || value === raw)
10
+ && (raw.schemaVersion === undefined || raw.schemaVersion === 1);
11
+ const input = supported ? raw : {};
12
+ const enabled = supported && (input.enabled === undefined || input.enabled === true);
13
+ const limit = (value, fallback) => typeof value === 'number'
14
+ && Number.isSafeInteger(value) && value >= 0 ? value : fallback;
15
+ return {
16
+ schemaVersion: 1,
17
+ enabled,
18
+ // Preserve an existing explicit refusal until the user enables or selects a model again.
19
+ continuationEnabled: enabled && (input.continuationEnabled === undefined || input.continuationEnabled === true),
20
+ disabledWorkspaceIds: Array.isArray(input.disabledWorkspaceIds)
21
+ ? [...new Set(input.disabledWorkspaceIds.filter((id) => typeof id === 'string' && id.length > 0 && id.length <= 200))] : [],
22
+ dailyRequestLimit: limit(input.dailyRequestLimit, 100),
23
+ dailyTokenLimit: limit(input.dailyTokenLimit, 100_000),
24
+ };
25
+ }
26
+ export function isInputPredictionRequest(value) {
27
+ if (!value || typeof value !== 'object')
28
+ return false;
29
+ const row = value;
30
+ const id = (key) => typeof row[key] === 'string' && row[key].length > 0 && row[key].length <= 200;
31
+ return ['requestId', 'workspaceId', 'conversationId', 'composerInstanceId'].every(id)
32
+ && ['desktop_bot', 'desktop_classic'].includes(String(row.surface))
33
+ && ['next_turn', 'continuation'].includes(String(row.mode))
34
+ && Number.isSafeInteger(row.draftVersion) && Number(row.draftVersion) >= 0
35
+ && typeof row.draftText === 'string' && row.draftText.length <= INPUT_PREDICTION_LIMITS.draftLength
36
+ && Number.isSafeInteger(row.selectionStart) && Number.isSafeInteger(row.selectionEnd)
37
+ && Number(row.selectionStart) >= 0 && Number(row.selectionStart) === Number(row.selectionEnd)
38
+ && Number(row.selectionEnd) === row.draftText.length
39
+ && (row.mode === 'next_turn' ? row.draftText === '' : row.draftText.length > 0)
40
+ && (row.quoteMessageId === undefined || id('quoteMessageId'));
41
+ }
42
+ export function isInputPredictionReference(value) {
43
+ if (!value || typeof value !== 'object')
44
+ return false;
45
+ const row = value;
46
+ return ['composerInstanceId', 'requestId'].every(key => typeof row[key] === 'string' && row[key].length > 0 && row[key].length <= 200)
47
+ && (row.candidateId === undefined || typeof row.candidateId === 'string' && row.candidateId.length > 0 && row.candidateId.length <= 200);
48
+ }
@@ -0,0 +1,201 @@
1
+ /** ADR 117: model interpretations are continuity facts, never permissions or task acceptance. */
2
+ export type InputDispositionKind = 'discuss' | 'answer' | 'delegate' | 'augment' | 'revise' | 'withdraw';
3
+ export interface InputDisposition {
4
+ readonly inputId: string;
5
+ readonly kind: InputDispositionKind;
6
+ readonly reason: string;
7
+ }
8
+ export interface IntentRequirement {
9
+ readonly requirementId: string;
10
+ readonly text: string;
11
+ readonly sourceInputIds: readonly string[];
12
+ }
13
+ export interface IntentInterpretation {
14
+ readonly outcome: string;
15
+ readonly constraints: readonly string[];
16
+ readonly nonGoals: readonly string[];
17
+ readonly openQuestions: readonly string[];
18
+ readonly requirements: readonly IntentRequirement[];
19
+ }
20
+ export interface GoalCoverageItem {
21
+ readonly requirementId: string;
22
+ readonly status: 'remaining' | 'covered' | 'uncertain';
23
+ readonly explanation: string;
24
+ readonly sources: readonly {
25
+ readonly sessionId: string;
26
+ readonly sourceRevision: string;
27
+ readonly evidenceRefs: readonly string[];
28
+ }[];
29
+ }
30
+ export type WorkDisposition = {
31
+ readonly kind: 'continue';
32
+ readonly operationRefs: readonly string[];
33
+ } | {
34
+ readonly kind: 'wait';
35
+ readonly waitFor: readonly {
36
+ readonly kind: 'session' | 'human_request' | 'resource' | 'recovery';
37
+ readonly id: string;
38
+ readonly revision: string;
39
+ }[];
40
+ }
41
+ /** Host-reserved reply reference; local bindings resolve the actual canonical message or digest. */
42
+ | {
43
+ readonly kind: 'return';
44
+ readonly replyRef: string;
45
+ } | {
46
+ readonly kind: 'blocked_system';
47
+ readonly code: string;
48
+ readonly recoveryRef: string;
49
+ } | {
50
+ readonly kind: 'withdraw';
51
+ readonly controlRef: string;
52
+ };
53
+ export interface IntentAssessment {
54
+ readonly operationId: string;
55
+ readonly workId: string;
56
+ /** Semantic coordination revision, independent of budget writes and journal sequence. */
57
+ readonly expectedWorkRevision: number;
58
+ readonly expectedGoalRevision: number;
59
+ readonly sourceInputIds: readonly string[];
60
+ readonly sourceEventIds: readonly string[];
61
+ readonly sourceDecisionRef?: string;
62
+ readonly inputs: readonly InputDisposition[];
63
+ readonly interpretation?: IntentInterpretation;
64
+ readonly coverage: readonly GoalCoverageItem[];
65
+ readonly disposition: WorkDisposition;
66
+ readonly reason: string;
67
+ }
68
+ export interface IntentCoordination {
69
+ readonly schemaVersion: 1;
70
+ readonly revision: number;
71
+ readonly goalRevision: number;
72
+ readonly interpretation: IntentInterpretation;
73
+ readonly inputs: Readonly<Record<string, InputDisposition>>;
74
+ readonly coverage: readonly GoalCoverageItem[];
75
+ readonly decision: IntentAssessment;
76
+ readonly decisionTurnId?: string;
77
+ readonly lifecycle: 'active' | 'fulfilled' | 'cancelled';
78
+ readonly updatedAt: string;
79
+ readonly review?: {
80
+ readonly reviewRef: string;
81
+ readonly passed: boolean;
82
+ readonly goalRevision: number;
83
+ readonly intentRevision: number;
84
+ readonly coverageDigest: string;
85
+ readonly sources: readonly {
86
+ readonly sessionId: string;
87
+ readonly sourceRevision: string;
88
+ readonly observationRevision: string;
89
+ }[];
90
+ readonly evidenceRefs: readonly string[];
91
+ readonly at: string;
92
+ };
93
+ readonly closure?: {
94
+ readonly operationId: string;
95
+ readonly replyRef?: string;
96
+ readonly replyRefs?: readonly string[];
97
+ readonly intentReplyRef?: string;
98
+ readonly reviewRef?: string;
99
+ readonly at: string;
100
+ };
101
+ }
102
+ export interface IntentClosureRequest {
103
+ readonly operationId: string;
104
+ readonly workId: string;
105
+ readonly expectedWorkRevision: number;
106
+ readonly expectedGoalRevision: number;
107
+ readonly lifecycle: 'fulfilled' | 'cancelled';
108
+ }
109
+ export interface IntentDecisionReceipt {
110
+ readonly operationId: string;
111
+ readonly workId: string;
112
+ readonly workRevision: number;
113
+ readonly goalRevision: number;
114
+ readonly at: string;
115
+ readonly turnId?: string;
116
+ readonly continuation?: boolean;
117
+ }
118
+ export type IntentCoordinationRequest = {
119
+ readonly action: 'query';
120
+ readonly workId: string;
121
+ readonly expectedRevision?: number;
122
+ readonly expectedWorkRevision?: number;
123
+ readonly afterSessionId?: string;
124
+ readonly afterInputId?: string;
125
+ readonly inputId?: string;
126
+ readonly eventId?: string;
127
+ readonly payloadOffset?: number;
128
+ } | {
129
+ readonly action: 'assess';
130
+ readonly assessment: Omit<IntentAssessment, 'operationId'>;
131
+ };
132
+ /** Bounded host projection. Available actions are a snapshot, not grants. */
133
+ export interface CoordinationDecisionFrame {
134
+ readonly resourceWaits?: readonly import('./runtime-session-facts.ts').ResourceWaitFact[];
135
+ readonly resourceWaitError?: string;
136
+ readonly workId: string;
137
+ readonly workRevision: number;
138
+ readonly goalRevision: number;
139
+ readonly sourceInputIds: readonly string[];
140
+ readonly sourceEventIds: readonly string[];
141
+ readonly sourceDecisionRef?: string;
142
+ readonly intent: {
143
+ readonly lifecycle: IntentCoordination['lifecycle'];
144
+ readonly outcome: string;
145
+ readonly constraints: readonly string[];
146
+ readonly nonGoals: readonly string[];
147
+ readonly openQuestions: readonly string[];
148
+ readonly openQuestionCount: number;
149
+ readonly remainingRequirementCount: number;
150
+ readonly inputDispositions: readonly InputDisposition[];
151
+ readonly requirements: readonly (IntentRequirement & {
152
+ readonly status: GoalCoverageItem['status'];
153
+ })[];
154
+ readonly disposition: WorkDisposition['kind'];
155
+ readonly review?: {
156
+ readonly reviewRef: string;
157
+ readonly passed: boolean;
158
+ readonly current: boolean;
159
+ readonly goalRevision: number;
160
+ } | null;
161
+ } | null;
162
+ readonly sessions: readonly {
163
+ readonly sessionId: string;
164
+ readonly title: string;
165
+ readonly status: string;
166
+ readonly sourceRevision?: string;
167
+ readonly observationRevision?: string;
168
+ readonly humanGate: boolean;
169
+ }[];
170
+ readonly events: readonly {
171
+ readonly eventId: string;
172
+ readonly kind: string;
173
+ readonly sessionId?: string;
174
+ readonly payload: Readonly<Record<string, unknown>>;
175
+ }[];
176
+ readonly questions: readonly Readonly<Record<string, unknown>>[];
177
+ readonly operations: readonly Readonly<Record<string, unknown>>[];
178
+ readonly unknownEffects: readonly Readonly<Record<string, unknown>>[];
179
+ readonly controls: Readonly<Record<string, unknown>>;
180
+ readonly omitted: Readonly<Record<string, number | boolean>>;
181
+ readonly retrieval: {
182
+ readonly tool: 'coordinate_work';
183
+ readonly action: 'query';
184
+ readonly workId: string;
185
+ readonly expectedRevision: number;
186
+ readonly afterSessionId?: string;
187
+ };
188
+ readonly availableActions: readonly {
189
+ readonly action: string;
190
+ readonly allowed: boolean;
191
+ readonly reason?: string;
192
+ }[];
193
+ readonly truncated: boolean;
194
+ }
195
+ export interface ProgressObservation {
196
+ readonly kind: 'observed' | 'admitted' | 'advanced';
197
+ readonly fingerprint: string;
198
+ readonly failure: boolean;
199
+ /** Host-normalized facts; this record is neither Evidence nor an execution/permission receipt. */
200
+ readonly fact: Readonly<Record<string, unknown>>;
201
+ }
@@ -0,0 +1 @@
1
+ export {};