@peer-agent/protocol 0.1.0-rc.5 → 0.1.0-rc.50

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 (120) 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 +67 -0
  10. package/dist/bot-conversation-read.js +9 -0
  11. package/dist/bot-direct-step.d.ts +11 -0
  12. package/dist/bot-direct-step.js +1 -0
  13. package/dist/bot-git.d.ts +55 -0
  14. package/dist/bot-git.js +1 -0
  15. package/dist/bot-model-selection.d.ts +13 -0
  16. package/dist/bot-model-selection.js +1 -0
  17. package/dist/browser-window.d.ts +48 -0
  18. package/dist/browser-window.js +23 -0
  19. package/dist/capability-admission.d.ts +20 -0
  20. package/dist/capability-admission.js +1 -0
  21. package/dist/compaction-history-selection.d.ts +15 -0
  22. package/dist/compaction-history-selection.js +30 -0
  23. package/dist/compaction.d.ts +5 -0
  24. package/dist/compaction.js +6 -0
  25. package/dist/context-accounting.d.ts +3 -0
  26. package/dist/conversation-execution.d.ts +68 -0
  27. package/dist/conversation-execution.js +222 -0
  28. package/dist/delegation-coordination.d.ts +81 -0
  29. package/dist/delegation-coordination.js +1 -0
  30. package/dist/delegation.d.ts +260 -7
  31. package/dist/delegation.js +97 -39
  32. package/dist/document-reference.d.ts +111 -0
  33. package/dist/document-reference.js +1 -0
  34. package/dist/evidence-inspection.d.ts +64 -0
  35. package/dist/evidence-inspection.js +1 -0
  36. package/dist/gemini-standard-pricing.json +105 -0
  37. package/dist/goal.d.ts +50 -2
  38. package/dist/hook-observation.d.ts +2 -0
  39. package/dist/hook-observation.js +19 -0
  40. package/dist/index.d.ts +109 -25
  41. package/dist/index.js +38 -0
  42. package/dist/input-prediction.d.ts +86 -0
  43. package/dist/input-prediction.js +48 -0
  44. package/dist/intent-coordination.d.ts +201 -0
  45. package/dist/intent-coordination.js +1 -0
  46. package/dist/interactive-result.d.ts +363 -0
  47. package/dist/interactive-result.js +215 -0
  48. package/dist/interactive-verification.d.ts +41 -0
  49. package/dist/interactive-verification.js +65 -0
  50. package/dist/local-git.d.ts +44 -0
  51. package/dist/local-git.js +3 -0
  52. package/dist/local-image.d.ts +53 -0
  53. package/dist/local-image.js +5 -0
  54. package/dist/local-read.d.ts +9 -0
  55. package/dist/local-read.js +1 -0
  56. package/dist/memory.d.ts +71 -11
  57. package/dist/memory.js +12 -0
  58. package/dist/model-reasoning.d.ts +16 -0
  59. package/dist/model-reasoning.js +25 -0
  60. package/dist/model-routing.d.ts +39 -3
  61. package/dist/model-routing.js +31 -5
  62. package/dist/native-process.d.ts +21 -0
  63. package/dist/native-process.js +51 -0
  64. package/dist/parent-coordination.d.ts +104 -0
  65. package/dist/parent-coordination.js +2 -0
  66. package/dist/project-agent-failure.d.ts +30 -0
  67. package/dist/project-agent-failure.js +44 -0
  68. package/dist/project-input-recovery.d.ts +83 -0
  69. package/dist/project-input-recovery.js +25 -0
  70. package/dist/project-matter.d.ts +225 -0
  71. package/dist/project-matter.js +1 -0
  72. package/dist/project-recovery.d.ts +43 -0
  73. package/dist/project-recovery.js +1 -0
  74. package/dist/project.d.ts +136 -0
  75. package/dist/project.js +130 -5
  76. package/dist/quiet-reply.d.ts +9 -0
  77. package/dist/quiet-reply.js +43 -0
  78. package/dist/remote-access.d.ts +15 -0
  79. package/dist/remote-access.js +1 -1
  80. package/dist/reply-delivery.d.ts +28 -0
  81. package/dist/reply-delivery.js +1 -0
  82. package/dist/resource-edit-execution.d.ts +68 -0
  83. package/dist/resource-edit-execution.js +96 -0
  84. package/dist/resource-edit.d.ts +237 -0
  85. package/dist/resource-edit.js +134 -0
  86. package/dist/resource-feedback-transport.d.ts +26 -0
  87. package/dist/resource-feedback-transport.js +94 -0
  88. package/dist/resource-feedback.d.ts +98 -0
  89. package/dist/resource-feedback.js +151 -0
  90. package/dist/resource-file-replace.d.ts +36 -0
  91. package/dist/resource-file-replace.js +40 -0
  92. package/dist/resource-reference-hints.d.ts +3 -0
  93. package/dist/resource-reference-hints.js +58 -0
  94. package/dist/resource-window.d.ts +222 -0
  95. package/dist/resource-window.js +252 -0
  96. package/dist/runtime-session-facts.d.ts +58 -0
  97. package/dist/runtime-session-facts.js +57 -0
  98. package/dist/session-control.d.ts +211 -0
  99. package/dist/session-control.js +48 -0
  100. package/dist/session-facts.d.ts +29 -0
  101. package/dist/session-facts.js +35 -0
  102. package/dist/skill-marketplace.d.ts +39 -4
  103. package/dist/spend-budget.d.ts +69 -0
  104. package/dist/spend-budget.js +1 -0
  105. package/dist/system-context.d.ts +7 -0
  106. package/dist/task-overview.d.ts +91 -0
  107. package/dist/task-overview.js +325 -17
  108. package/dist/tool-activity-preview.d.ts +4 -0
  109. package/dist/tool-activity-preview.js +72 -0
  110. package/dist/updater.d.ts +13 -3
  111. package/dist/usage-accounting.d.ts +42 -1
  112. package/dist/user-anchor.d.ts +17 -0
  113. package/dist/user-anchor.js +1 -0
  114. package/dist/work-coordination.d.ts +188 -0
  115. package/dist/work-coordination.js +1 -0
  116. package/dist/work-hook.d.ts +3 -0
  117. package/dist/work-hook.js +76 -0
  118. package/dist/working-plan.d.ts +18 -0
  119. package/dist/working-plan.js +1 -0
  120. package/package.json +1 -1
@@ -0,0 +1,104 @@
1
+ /** ADR 143 native Core RPC contract. Sequences are unsigned decimal strings. */
2
+ export declare const PARENT_COORDINATION_VERSION = 1;
3
+ export interface CoordinationOption {
4
+ id: string;
5
+ label: string;
6
+ summary: string;
7
+ recommended?: boolean;
8
+ }
9
+ export type CoordinationArtifactRef = {
10
+ kind: 'workspace_path';
11
+ path: string;
12
+ } | {
13
+ kind: 'evidence';
14
+ ref: string;
15
+ };
16
+ export type CoordinationExchangeKind = 'notice' | 'question' | 'parent_answer' | 'parent_steer' | 'parent_dispatch' | 'parent_acknowledged' | 'escalated' | 'user_decision' | 'delivery';
17
+ export interface CoordinationExchangeItem {
18
+ seq: string;
19
+ itemId: string;
20
+ kind: CoordinationExchangeKind;
21
+ actorRole: 'worker' | 'parent' | 'user' | 'host';
22
+ occurredAt: string;
23
+ sessionId: string;
24
+ followUpEpoch: number;
25
+ matterId?: string;
26
+ requestId?: string;
27
+ noticeId?: string;
28
+ relatedItemIds: string[];
29
+ summary: string;
30
+ detail?: string;
31
+ options?: CoordinationOption[];
32
+ artifactRefs?: CoordinationArtifactRef[];
33
+ disposition?: string;
34
+ erased?: boolean;
35
+ erasureGeneration?: string;
36
+ }
37
+ export type CoordinationLogQuery = {
38
+ workspaceId: string;
39
+ beforeCursor?: string;
40
+ limit?: number;
41
+ } & ({
42
+ sessionId: string;
43
+ followUpEpoch?: number;
44
+ matterId?: never;
45
+ } | {
46
+ matterId: string;
47
+ sessionId?: never;
48
+ followUpEpoch?: never;
49
+ });
50
+ export interface CoordinationLogPage {
51
+ items: CoordinationExchangeItem[];
52
+ nextCursor?: string;
53
+ highWatermark: string;
54
+ }
55
+ export type SubmitCoordinationDecision = {
56
+ workspaceId: string;
57
+ requestId: string;
58
+ expectedRevision: number;
59
+ actorRef: string;
60
+ inputId: string;
61
+ } & ({
62
+ actionKind: 'answer';
63
+ chosenOptionId: string;
64
+ freeText?: never;
65
+ } | {
66
+ actionKind: 'answer';
67
+ freeText: string;
68
+ chosenOptionId?: never;
69
+ } | {
70
+ actionKind: 'cancel';
71
+ chosenOptionId?: never;
72
+ freeText?: never;
73
+ });
74
+ export interface UserDecisionReceipt {
75
+ receiptId: string;
76
+ requestId: string;
77
+ actionKind: 'answer' | 'cancel';
78
+ chosenOption?: CoordinationOption;
79
+ freeText?: string;
80
+ answeredAt: string;
81
+ actorRef: string;
82
+ inputId: string;
83
+ requestRevision: number;
84
+ }
85
+ export type CoordinationDecisionCardOption = (CoordinationOption & {
86
+ actionKind: 'answer';
87
+ }) | {
88
+ actionKind: 'free_text' | 'cancel';
89
+ label: string;
90
+ };
91
+ export interface CoordinationDecisionCard {
92
+ kind: 'needs-you';
93
+ requestId: string;
94
+ revision: number;
95
+ question: string;
96
+ context?: string | null;
97
+ parentRationale: string;
98
+ options: CoordinationDecisionCardOption[];
99
+ freeText: true;
100
+ recentQuestions?: {
101
+ question: string;
102
+ answer: string;
103
+ }[] | null;
104
+ }
@@ -0,0 +1,2 @@
1
+ /** ADR 143 native Core RPC contract. Sequences are unsigned decimal strings. */
2
+ export const PARENT_COORDINATION_VERSION = 1;
@@ -0,0 +1,30 @@
1
+ import type { DelegationEvent } from './delegation.ts';
2
+ export type ProjectRecoveryFailureKind = 'response_headers_timeout' | 'network' | 'stream_interrupted' | 'provider_transient' | 'rate_limited' | 'authentication' | 'invalid_request' | 'configuration' | 'permission' | 'budget_exhausted' | 'execution_outcome_unknown' | 'cancelled' | 'fatal';
3
+ /** Produced by the host request boundary; never inferred from assistant prose. */
4
+ export interface ProviderRequestRecovery {
5
+ readonly kind: ProjectRecoveryFailureKind;
6
+ readonly phase?: 'response_headers' | 'stream' | 'request';
7
+ readonly requestId?: string;
8
+ readonly attempts?: number;
9
+ readonly maxAttempts?: number;
10
+ readonly exhausted?: boolean;
11
+ readonly replaySafe?: boolean;
12
+ readonly retryable: boolean;
13
+ }
14
+ /** Legacy diagnostics are admitted only at this seam; structured host failure takes precedence. */
15
+ export declare function classifyProjectAgentFailure(reason: unknown, detail?: unknown): {
16
+ kind: ProjectRecoveryFailureKind;
17
+ retryable: boolean;
18
+ };
19
+ /** Host failure classification, including the persisted diagnostic prefix used by older cards. */
20
+ export declare function projectAgentFailureKind(reason: unknown): 'budget_exhausted' | 'unavailable';
21
+ /** Durable host facts for an explicit retry; never a new user authorization. */
22
+ export interface ProjectAgentTurnRecovery {
23
+ readonly events: readonly DelegationEvent[];
24
+ readonly throughSeq: number;
25
+ }
26
+ /** Factual recovery data returned by post_reply after anchor validation fails. */
27
+ export interface ReplyAnchorCandidate {
28
+ readonly messageId: string;
29
+ readonly text: string;
30
+ }
@@ -0,0 +1,44 @@
1
+ const RECOVERABLE = new Set(['response_headers_timeout', 'network', 'stream_interrupted', 'provider_transient', 'rate_limited']);
2
+ const FAILURE_KINDS = new Set([...RECOVERABLE, 'authentication', 'invalid_request', 'configuration', 'permission', 'budget_exhausted', 'execution_outcome_unknown', 'cancelled', 'fatal']);
3
+ /** Legacy diagnostics are admitted only at this seam; structured host failure takes precedence. */
4
+ export function classifyProjectAgentFailure(reason, detail) {
5
+ if (detail && typeof detail === 'object' && 'kind' in detail && FAILURE_KINDS.has(detail.kind)) {
6
+ const kind = detail.kind;
7
+ return { kind, retryable: RECOVERABLE.has(kind) && !('retryable' in detail && detail.retryable === false) };
8
+ }
9
+ const code = typeof reason === 'string' ? reason.trim().replace(/^代理暂时不可用:\s*/, '') : '';
10
+ let kind = 'fatal';
11
+ if (/^(agent_tool_budget_exhausted|agent_loop_exhausted|work_budget_limited)(?:\s*:|$)/.test(code))
12
+ kind = 'budget_exhausted';
13
+ else if (/^(execution_outcome_unknown|checkpoint_persistence_failed)(?:\s*:|$)/.test(code))
14
+ kind = 'execution_outcome_unknown';
15
+ else if (/^(work_execution_stopped|aborted|AbortError|user_stopped)(?:\s*:|$)/i.test(code))
16
+ kind = 'cancelled';
17
+ else if (/^(permission_denied|permission_revoked|authorization_denied)(?:\s*:|$)/i.test(code))
18
+ kind = 'permission';
19
+ else if (/^(connect timeout after|response_headers_timeout)|ConnectTimeoutError/.test(code))
20
+ kind = 'response_headers_timeout';
21
+ else if (/^(provider_stream_idle_timeout|provider_stream_interrupted)(?:\s*:|$)/.test(code))
22
+ kind = 'stream_interrupted';
23
+ else if (/^(HTTP\s*)?(401|403)(?:\s|:|$)|^(authentication_error|invalid_api_key|credential_unavailable)(?:\s*:|$)/i.test(code))
24
+ kind = 'authentication';
25
+ else if (/^(HTTP\s*)?429(?:\s|:|$)/i.test(code))
26
+ kind = 'rate_limited';
27
+ else if (/^(HTTP\s*)?(500|502|503|504)(?:\s|:|$)|^(server_error|server_is_overloaded)(?:\s*:|$)/i.test(code))
28
+ kind = 'provider_transient';
29
+ else if (/^(HTTP\s*)?(400|404|422)(?:\s|:|$)|^(invalid_request|provider_checkpoint_mismatch)(?:\s*:|$)/i.test(code))
30
+ kind = 'invalid_request';
31
+ else if (/^(CERT_|ERR_CERT_|UNABLE_TO_VERIFY|SELF_SIGNED|DEPTH_ZERO_SELF_SIGNED_CERT|provider_not_configured|work_budget_host_unavailable)/i.test(code))
32
+ kind = 'configuration';
33
+ else if (/^(fetch failed|network|ECONNRESET|ECONNREFUSED|ENOTFOUND|ETIMEDOUT|EAI_AGAIN|UND_ERR_(SOCKET|CONNECT_TIMEOUT)|(?:net::)?ERR_(CONNECTION|NETWORK|TIMED_OUT|NAME_NOT_RESOLVED|PROXY_CONNECTION_FAILED|TUNNEL_CONNECTION_FAILED|SOCKS_CONNECTION_FAILED|INTERNET_DISCONNECTED))/i.test(code))
34
+ kind = 'network';
35
+ return { kind, retryable: RECOVERABLE.has(kind) };
36
+ }
37
+ /** Host failure classification, including the persisted diagnostic prefix used by older cards. */
38
+ export function projectAgentFailureKind(reason) {
39
+ if (typeof reason !== 'string')
40
+ return 'unavailable';
41
+ const code = reason.trim().replace(/^代理暂时不可用:\s*/, '');
42
+ return /^(agent_tool_budget_exhausted|agent_loop_exhausted|work_budget_limited)(?:\s*:|$)/.test(code)
43
+ ? 'budget_exhausted' : 'unavailable';
44
+ }
@@ -0,0 +1,83 @@
1
+ import type { ResourceFeedback } from './resource-feedback.ts';
2
+ import type { ProjectInputAttachment, ProjectAgentSubmitInputResult, WorkSessionStatus } from './delegation.ts';
3
+ export type LocalInputSurface = 'desktop' | 'quick_chat' | 'tui';
4
+ export interface InputDraftQuote {
5
+ readonly messageId: string;
6
+ readonly text: string;
7
+ }
8
+ export interface InputDraftTaskRef {
9
+ readonly sessionId: string;
10
+ readonly title: string;
11
+ readonly status: WorkSessionStatus | string;
12
+ readonly anchorMessageId?: string;
13
+ }
14
+ export interface InputDraftValue {
15
+ readonly text: string;
16
+ readonly quote: InputDraftQuote | null;
17
+ readonly attachments: readonly ProjectInputAttachment[];
18
+ readonly taskRefs?: readonly InputDraftTaskRef[];
19
+ readonly resourceFeedback?: readonly ResourceFeedback[];
20
+ }
21
+ /** User intent only. Presence here never means the input was received or executed. */
22
+ export interface UnconfirmedProjectInput {
23
+ readonly inputId: string;
24
+ readonly text: string;
25
+ readonly quoteRefs: readonly string[];
26
+ readonly taskRefs?: readonly InputDraftTaskRef[];
27
+ readonly answerTo?: string;
28
+ readonly attachments: readonly ProjectInputAttachment[];
29
+ readonly resourceFeedback?: readonly ResourceFeedback[];
30
+ readonly createdAt: string;
31
+ }
32
+ export interface ProjectInputDraftSnapshot {
33
+ readonly revision: number;
34
+ readonly draft: InputDraftValue;
35
+ readonly pending: readonly UnconfirmedProjectInput[];
36
+ }
37
+ export interface ProjectInputDraftReadRequest {
38
+ readonly workspaceId: string;
39
+ readonly surface: LocalInputSurface;
40
+ }
41
+ export type ProjectInputDraftReadResult = {
42
+ readonly ok: true;
43
+ readonly snapshot: ProjectInputDraftSnapshot;
44
+ } | {
45
+ readonly ok: false;
46
+ readonly code: string;
47
+ };
48
+ export interface ProjectInputDraftWriteRequest extends ProjectInputDraftReadRequest {
49
+ readonly revision: number;
50
+ readonly draft: Omit<InputDraftValue, 'attachments'> & {
51
+ readonly attachmentIds: readonly string[];
52
+ };
53
+ readonly pending: readonly (Omit<UnconfirmedProjectInput, 'attachments'> & {
54
+ readonly attachmentIds: readonly string[];
55
+ })[];
56
+ /** Already-stored attachments are referred to by ID; large bytes are sent only once. */
57
+ readonly uploads: readonly ProjectInputAttachment[];
58
+ }
59
+ export type ProjectInputDraftWriteResult = {
60
+ readonly ok: true;
61
+ readonly revision: number;
62
+ } | {
63
+ readonly ok: false;
64
+ readonly code: string;
65
+ };
66
+ export interface ProjectInputRecoveryPort {
67
+ read(request: ProjectInputDraftReadRequest): Promise<ProjectInputDraftReadResult>;
68
+ write(request: ProjectInputDraftWriteRequest): Promise<ProjectInputDraftWriteResult>;
69
+ submit(request: UnconfirmedProjectInput & ProjectInputDraftReadRequest): Promise<ProjectAgentSubmitInputResult>;
70
+ }
71
+ export type ProjectInputMutationResult = {
72
+ readonly ok: true;
73
+ } | {
74
+ readonly ok: false;
75
+ readonly code: string;
76
+ };
77
+ export declare const DEFINITE_PROJECT_INPUT_REJECTION_CODES: ReadonlySet<string>;
78
+ export declare function emptyInputDraft(): InputDraftValue;
79
+ /** A handoff failure may follow a durable receipt. Generic ok alone proves nothing. */
80
+ export declare function projectInputWasReceived(result: ProjectAgentSubmitInputResult | null | undefined, workspaceId: string, inputId: string): boolean;
81
+ export declare function isDefiniteProjectInputRejectionCode(code: string | null | undefined): boolean;
82
+ /** True only when the host rejected the input before enqueuing it (no durable receipt). */
83
+ export declare function isDefiniteProjectInputRejection(result: ProjectAgentSubmitInputResult | null | undefined, workspaceId: string, inputId: string): boolean;
@@ -0,0 +1,25 @@
1
+ export const DEFINITE_PROJECT_INPUT_REJECTION_CODES = new Set([
2
+ 'QUESTION_CLOSED',
3
+ 'INVALID_INPUT',
4
+ 'INVALID_INPUT_ID',
5
+ 'INVALID_RESOURCE_FEEDBACK',
6
+ 'RESOURCE_FEEDBACK_RECIPIENT_CHANGED',
7
+ 'RESOURCE_FEEDBACK_ATTACHMENT_LIMIT',
8
+ 'INTERACTIVE_FEEDBACK_UNAVAILABLE',
9
+ 'NOT_FOUND',
10
+ 'WORKSPACE_NOT_FOUND',
11
+ ]);
12
+ export function emptyInputDraft() { return { text: '', quote: null, attachments: [] }; }
13
+ /** A handoff failure may follow a durable receipt. Generic ok alone proves nothing. */
14
+ export function projectInputWasReceived(result, workspaceId, inputId) {
15
+ return result?.input?.workspaceId === workspaceId && result.input.inputId === inputId;
16
+ }
17
+ export function isDefiniteProjectInputRejectionCode(code) {
18
+ return typeof code === 'string' && DEFINITE_PROJECT_INPUT_REJECTION_CODES.has(code);
19
+ }
20
+ /** True only when the host rejected the input before enqueuing it (no durable receipt). */
21
+ export function isDefiniteProjectInputRejection(result, workspaceId, inputId) {
22
+ if (!result || result.ok || projectInputWasReceived(result, workspaceId, inputId))
23
+ return false;
24
+ return isDefiniteProjectInputRejectionCode(result.code);
25
+ }
@@ -0,0 +1,225 @@
1
+ /** Rust Core project.matter.* v1, used by the trusted Desktop bridge. */
2
+ export type MatterStatus = 'pending' | 'in_progress' | 'waiting' | 'delivered' | 'cancelled';
3
+ export type MatterGroup = 'needsYou' | 'active' | 'delivered' | 'cancelled';
4
+ export type MatterCriterion = {
5
+ id: string;
6
+ text: string;
7
+ status?: 'open' | 'met' | 'waived';
8
+ waiverReceiptRef?: string;
9
+ };
10
+ export type MatterBrief = {
11
+ title: string;
12
+ goal: string;
13
+ constraints?: readonly string[];
14
+ doneMeans: string | readonly MatterCriterion[];
15
+ };
16
+ export type MatterSource = {
17
+ kind: string;
18
+ ref?: string;
19
+ };
20
+ export type MatterSummary = {
21
+ matterId: string;
22
+ number: number;
23
+ title: string;
24
+ status: MatterStatus;
25
+ needsYou: boolean;
26
+ revision: number;
27
+ briefRevision: number;
28
+ waitReason: string | null;
29
+ cancelReason: string | null;
30
+ cancelSettling: boolean;
31
+ lastEffectiveChangeAt: string;
32
+ };
33
+ export type MatterDecisionDraft = {
34
+ context: string;
35
+ question: string;
36
+ options: readonly {
37
+ id: string;
38
+ label: string;
39
+ recommended?: boolean;
40
+ }[];
41
+ approveDoneMeans?: MatterBrief['doneMeans'];
42
+ };
43
+ export type MatterDecision = MatterDecisionDraft & {
44
+ requestId: string;
45
+ };
46
+ export type MatterGit = {
47
+ repo: string | null;
48
+ baseBranch: string | null;
49
+ baseSha: string | null;
50
+ taskBranch: string | null;
51
+ isolation: string | null;
52
+ };
53
+ export type MatterArtifact = {
54
+ kind?: string;
55
+ ref?: string;
56
+ path?: string;
57
+ title?: string;
58
+ label?: string;
59
+ };
60
+ export type MatterDelivery = {
61
+ summary: string;
62
+ deliveredAt: string;
63
+ git?: MatterGit | null;
64
+ evidenceRefs?: readonly string[];
65
+ artifacts?: readonly MatterArtifact[];
66
+ };
67
+ export type Matter = MatterBrief & Omit<MatterSummary, 'waitReason'> & {
68
+ origin: MatterSource;
69
+ waiting?: {
70
+ reason: string;
71
+ source: MatterSource;
72
+ } | null;
73
+ needsYouDecision?: MatterDecision | null;
74
+ delivery?: MatterDelivery | null;
75
+ deliveryHistory: readonly MatterDelivery[];
76
+ historyWithheld?: boolean;
77
+ };
78
+ export type MatterRun = {
79
+ sessionId: string;
80
+ followUpEpoch: number;
81
+ role: string;
82
+ state: string;
83
+ hostStatus?: string;
84
+ executionMode?: string;
85
+ git?: MatterGit | null;
86
+ deliveryBinding?: import('./delegation.ts').WorkSessionDeliveryBinding;
87
+ liveIsolationLost?: boolean;
88
+ briefRevision?: number | null;
89
+ };
90
+ export type MatterActivity = {
91
+ activityId: string;
92
+ seq: number;
93
+ kind: string;
94
+ actorKind: string;
95
+ body: string;
96
+ payload: Record<string, unknown>;
97
+ createdAt: string;
98
+ };
99
+ export type MatterChanged = {
100
+ workspaceId: string;
101
+ matterId: string;
102
+ revision: number;
103
+ };
104
+ export type MatterListPage = {
105
+ limit?: number;
106
+ deliveredLimit?: number;
107
+ } & Partial<Record<`${MatterGroup}Cursor`, string>>;
108
+ export type MatterDetailPage = {
109
+ afterSeq?: number;
110
+ activityLimit?: number;
111
+ runOffset?: number;
112
+ runLimit?: number;
113
+ };
114
+ type Scope = {
115
+ workspaceId: string;
116
+ version?: 1;
117
+ };
118
+ type Write = Scope & {
119
+ operationId: string;
120
+ };
121
+ type Target = {
122
+ matterId: string;
123
+ };
124
+ type CAS = {
125
+ revision: number;
126
+ briefRevision?: number;
127
+ };
128
+ type Answer = {
129
+ requestId: string;
130
+ } & ({
131
+ optionId: string;
132
+ text?: never;
133
+ } | {
134
+ text: string;
135
+ optionId?: never;
136
+ });
137
+ type Patch = {
138
+ brief?: MatterBrief;
139
+ status?: MatterStatus;
140
+ waiting?: {
141
+ reason: string;
142
+ source: MatterSource & {
143
+ ref: string;
144
+ };
145
+ };
146
+ decision?: MatterDecisionDraft;
147
+ userReceiptRef?: string;
148
+ delivery?: {
149
+ summary: string;
150
+ sessionId?: string;
151
+ followUpEpoch?: number;
152
+ };
153
+ };
154
+ export type MatterList = Record<MatterGroup, readonly MatterSummary[]> & Record<`${MatterGroup}Cursor`, string | null> & {
155
+ activeCount: number;
156
+ cancelledCount: number;
157
+ };
158
+ export type MatterDetail = {
159
+ matter: Matter;
160
+ activities: readonly MatterActivity[];
161
+ runs: readonly MatterRun[];
162
+ nextActivitySeq: number | null;
163
+ nextRunOffset: number | null;
164
+ };
165
+ type Receipt = Target & CAS & {
166
+ number: number;
167
+ status: MatterStatus;
168
+ seq?: number;
169
+ activityId?: string;
170
+ };
171
+ interface MatterRequests {
172
+ list: Scope & {
173
+ page?: MatterListPage;
174
+ };
175
+ get: Scope & Target & {
176
+ page?: MatterDetailPage;
177
+ };
178
+ create: Write & {
179
+ brief: MatterBrief;
180
+ };
181
+ update: Write & Target & CAS & {
182
+ patch: Patch;
183
+ };
184
+ comment: Write & Target & {
185
+ body: string;
186
+ };
187
+ answer_decision: Write & Target & CAS & {
188
+ answer: Answer;
189
+ };
190
+ reopen: Write & Target & CAS & {
191
+ reason: string;
192
+ };
193
+ cancel: Write & Target & CAS & {
194
+ reason: string;
195
+ };
196
+ claim_session: Write & {
197
+ claim: {
198
+ sessionId: string;
199
+ } & ({
200
+ brief: MatterBrief;
201
+ } | (Target & Pick<CAS, 'revision'>));
202
+ };
203
+ export_markdown: Scope & Target;
204
+ }
205
+ type ReadResults = {
206
+ list: MatterList;
207
+ get: MatterDetail;
208
+ export_markdown: Target & {
209
+ markdown: string;
210
+ };
211
+ };
212
+ type MatterFailure = {
213
+ ok: false;
214
+ code: string;
215
+ revision?: number;
216
+ briefRevision?: number;
217
+ };
218
+ export type MatterResult<K extends keyof MatterRequests> = MatterFailure | ({
219
+ ok: true;
220
+ version: 1;
221
+ } & (K extends keyof ReadResults ? ReadResults[K] : Receipt));
222
+ export type ProjectMatterRpc = <K extends keyof MatterRequests>(request: MatterRequests[K] & {
223
+ method: K;
224
+ }) => Promise<MatterResult<K>>;
225
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ /** Local maintenance controls. These commands never accept an execution verdict or a filesystem path. */
2
+ export interface ProjectRecoveryRequest {
3
+ readonly workspaceId: string;
4
+ /** `retain_all` ends every held work and child task in the plan bound by `planToken`; it never accepts ids. */
5
+ readonly action: 'inspect' | 'restore' | 'retain' | 'retain_all';
6
+ readonly planToken?: string;
7
+ readonly workId?: string;
8
+ readonly sessionId?: string;
9
+ }
10
+ export interface ProjectRecoveryWork {
11
+ readonly workId: string;
12
+ readonly title: string;
13
+ readonly disposition: 'held' | 'resume';
14
+ readonly reason: string;
15
+ }
16
+ export interface ProjectRecoveryView {
17
+ readonly phase: 'occupied' | 'inspection' | 'stopping' | 'backing_up' | 'restoring' | 'reconciling' | 'ready' | 'failed';
18
+ readonly planToken?: string;
19
+ readonly restored: boolean;
20
+ readonly canContinue: boolean;
21
+ readonly runtimeReady: boolean;
22
+ readonly completedCount: number;
23
+ readonly works: readonly ProjectRecoveryWork[];
24
+ readonly sessions: readonly {
25
+ readonly sessionId: string;
26
+ readonly title: string;
27
+ }[];
28
+ readonly holder?: {
29
+ readonly surface: 'desktop' | 'tui';
30
+ readonly version: string;
31
+ };
32
+ readonly backupAvailable: boolean;
33
+ readonly backupLocation?: string;
34
+ readonly code?: string;
35
+ }
36
+ export type ProjectRecoveryResult = {
37
+ readonly ok: true;
38
+ readonly view: ProjectRecoveryView;
39
+ } | {
40
+ readonly ok: false;
41
+ readonly code: string;
42
+ readonly view?: ProjectRecoveryView;
43
+ };
@@ -0,0 +1 @@
1
+ export {};