@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,96 @@
1
+ import { normalizeResourceEditOperation, resourceEditToken, resourceEditDigest } from "./resource-edit.js";
2
+ import { normalizeResourceFileReplacePreview, normalizeResourceFileReplaceInput, RESOURCE_FILE_REPLACE_CAPABILITY, RESOURCE_FILE_REPLACE_PROVIDER, RESOURCE_FILE_REPLACE_TOOL } from "./resource-file-replace.js";
3
+ export const RESOURCE_EDIT_EXECUTION_BYTES = 32768;
4
+ export const RESOURCE_EDIT_POSTLUDE_BYTES = 16384;
5
+ export const RESOURCE_EDIT_EXECUTION_TOTAL_BYTES = 8 * 1024 * 1024;
6
+ const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
7
+ const keys = (v, allowed) => Object.keys(v).every(key => allowed.includes(key));
8
+ const text = (v, max) => typeof v === 'string' && v.length > 0 && v.length <= max && !/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/.test(v);
9
+ const timestamp = (v) => typeof v === 'string' && v.length <= 40 && Number.isFinite(Date.parse(v));
10
+ function bounded(raw, max) { try {
11
+ return new TextEncoder().encode(JSON.stringify(raw)).byteLength <= max;
12
+ }
13
+ catch {
14
+ return false;
15
+ } }
16
+ const strings = (v, maxItems, maxChars) => Array.isArray(v) && v.length <= maxItems && v.every(item => text(item, maxChars));
17
+ export function resourceFileReplaceArgumentPayload(raw) {
18
+ const input = normalizeResourceFileReplaceInput(raw);
19
+ if (!input)
20
+ throw TypeError('INVALID_RESOURCE_EDIT_ARGUMENTS');
21
+ return JSON.stringify(input);
22
+ }
23
+ export function normalizeResourceEditExecutionRecord(raw) {
24
+ if (!object(raw) || !bounded(raw, RESOURCE_EDIT_EXECUTION_BYTES) || !keys(raw, ['schemaVersion', 'workspaceId', 'requestId', 'payloadHash', 'projectionId', 'sessionId', 'call', 'grant', 'result'])
25
+ || raw.schemaVersion !== 1 || !resourceEditToken(raw.workspaceId) || !resourceEditToken(raw.requestId) || !resourceEditDigest(raw.payloadHash)
26
+ || raw.projectionId !== `resource-edit:${raw.requestId}` || !text(raw.sessionId, 256) || !object(raw.call) || !object(raw.grant) || !object(raw.result))
27
+ return;
28
+ const call = raw.call, grant = raw.grant, result = raw.result;
29
+ if (!keys(call, ['toolCallId', 'capabilityId', 'toolName', 'argumentsDigest', 'occurredAt', 'permissionCallId']) || call.toolCallId !== `resource-edit:${raw.requestId}`
30
+ || call.permissionCallId !== undefined && ![call.toolCallId, `chat-permission:${call.toolCallId}`].includes(call.permissionCallId)
31
+ || call.capabilityId !== RESOURCE_FILE_REPLACE_CAPABILITY || call.toolName !== RESOURCE_FILE_REPLACE_TOOL || !resourceEditDigest(call.argumentsDigest) || !timestamp(call.occurredAt)
32
+ || !keys(grant, ['grantId', 'toolCallId', 'granted', 'duration', 'scope', 'decidedAt', 'policyRevision']) || !resourceEditToken(grant.grantId) || grant.toolCallId !== call.toolCallId
33
+ || typeof grant.granted !== 'boolean' || !['once', 'task', 'session', 'scope', 'persistent', 'denied'].includes(grant.duration)
34
+ || grant.granted && (grant.duration === 'denied' || grant.scope !== call.capabilityId)
35
+ || !grant.granted && grant.scope !== undefined && grant.scope !== null && grant.scope !== call.capabilityId || !timestamp(grant.decidedAt)
36
+ || grant.policyRevision !== undefined && !text(grant.policyRevision, 512)
37
+ || !keys(result, ['toolCallId', 'status', 'completedAt', 'observation', 'blockedReason', 'evidence']) || result.toolCallId !== call.toolCallId || !timestamp(result.completedAt)
38
+ || !['success', 'failed', 'denied', 'cancelled'].includes(result.status) || !object(result.evidence))
39
+ return;
40
+ const observation = result.observation === undefined ? undefined : normalizeResourceFileReplacePreview(result.observation);
41
+ if (result.observation !== undefined && !observation || observation && (observation.requestId !== raw.requestId || observation.status !== result.status
42
+ || observation.permissionCallId !== undefined && (![call.toolCallId, `chat-permission:${call.toolCallId}`].includes(observation.permissionCallId)
43
+ || call.permissionCallId !== undefined && observation.permissionCallId !== call.permissionCallId)
44
+ || observation.outcome === 'applied' && !grant.granted)
45
+ || !observation && (!['denied', 'cancelled'].includes(result.status) || grant.granted || !text(result.blockedReason, 2048))
46
+ || observation && result.blockedReason !== undefined)
47
+ return;
48
+ const evidence = result.evidence;
49
+ if (!keys(evidence, ['evidenceId', 'toolCallId', 'summary', 'locale', 'returnedToCloud', 'dataLevel', 'redactions', 'artifactRefs']) || !resourceEditToken(evidence.evidenceId)
50
+ || evidence.toolCallId !== call.toolCallId || !text(evidence.summary, 4096) || !text(evidence.locale, 32) || evidence.returnedToCloud !== false || evidence.dataLevel !== 'D2_sensitive'
51
+ || !strings(evidence.redactions, 32, 256) || !strings(evidence.artifactRefs, 32, 2048))
52
+ return;
53
+ return { schemaVersion: 1, workspaceId: raw.workspaceId, requestId: raw.requestId, payloadHash: raw.payloadHash, projectionId: raw.projectionId, sessionId: raw.sessionId,
54
+ call: { toolCallId: call.toolCallId, capabilityId: RESOURCE_FILE_REPLACE_CAPABILITY, toolName: RESOURCE_FILE_REPLACE_TOOL, argumentsDigest: call.argumentsDigest, occurredAt: call.occurredAt,
55
+ ...(call.permissionCallId !== undefined || observation?.permissionCallId !== undefined ? { permissionCallId: (call.permissionCallId ?? observation?.permissionCallId) } : {}) },
56
+ grant: { grantId: grant.grantId, toolCallId: grant.toolCallId, granted: grant.granted, duration: grant.duration,
57
+ ...(grant.scope !== undefined ? { scope: grant.scope } : {}),
58
+ decidedAt: grant.decidedAt, ...(grant.policyRevision !== undefined ? { policyRevision: grant.policyRevision } : {}) },
59
+ result: { toolCallId: result.toolCallId, status: result.status, completedAt: result.completedAt,
60
+ ...(observation ? { observation } : { blockedReason: result.blockedReason }), evidence: { evidenceId: evidence.evidenceId, toolCallId: evidence.toolCallId,
61
+ summary: evidence.summary, locale: evidence.locale, returnedToCloud: false, dataLevel: 'D2_sensitive', redactions: [...evidence.redactions], artifactRefs: [...evidence.artifactRefs] } } };
62
+ }
63
+ export function resourceEditExecutionMatches(record, raw) {
64
+ const op = normalizeResourceEditOperation(raw), value = record.result.observation;
65
+ return !!op && op.providerId === RESOURCE_FILE_REPLACE_PROVIDER && op.requestId === record.requestId && op.target.recipient.workspaceId === record.workspaceId && op.payloadHash === record.payloadHash && record.sessionId === (op.target.reference.task?.sessionId ?? op.target.recipient.conversationId)
66
+ && (!value || value.path === op.target.reference.path && value.resourceId === op.target.base.resourceId && value.expectedVersion === op.target.base.contentVersion && value.proposedVersion === op.proposedVersion);
67
+ }
68
+ /** Caller must have obtained this record from the actual host execution index, never model text. */
69
+ export function resourceEditExecutionReceipt(record, operation) {
70
+ if (!resourceEditExecutionMatches(record, operation))
71
+ return;
72
+ const outcome = record.result.observation?.outcome ?? (record.result.status === 'cancelled' ? 'cancelled' : 'denied');
73
+ if (outcome === 'uncertain')
74
+ return;
75
+ return { outcome, toolCallId: record.call.toolCallId, evidenceRef: `tool-result://${record.call.toolCallId}`,
76
+ ...(record.result.observation?.observedVersion ? { observedVersion: record.result.observation.observedVersion } : {}) };
77
+ }
78
+ export function normalizeResourceEditPostlude(raw) {
79
+ if (!object(raw) || !bounded(raw, RESOURCE_EDIT_POSTLUDE_BYTES) || !keys(raw, ['schemaVersion', 'requestId', 'payloadHash', 'completedAt', 'status', 'reason', 'hookFinalDecision', 'hooks'])
80
+ || raw.schemaVersion !== 1 || !resourceEditToken(raw.requestId) || !resourceEditDigest(raw.payloadHash) || !timestamp(raw.completedAt) || !['recorded', 'unconfirmed'].includes(raw.status)
81
+ || raw.status === 'unconfirmed' && !text(raw.reason, 2048) || raw.reason !== undefined && !text(raw.reason, 2048) || raw.hookFinalDecision !== undefined && !['allow', 'ask', 'deny'].includes(raw.hookFinalDecision)
82
+ || raw.hooks !== undefined && (!Array.isArray(raw.hooks) || raw.hooks.length > 64))
83
+ return;
84
+ const hooks = [];
85
+ for (const item of (raw.hooks ?? [])) {
86
+ if (!object(item) || !keys(item, ['id', 'event', 'decision', 'reason', 'outcome', 'durationMs', 'exitCode']) || !['allow', 'ask', 'deny'].includes(item.decision)
87
+ || item.id !== undefined && !text(item.id, 512) || item.event !== undefined && !['PreToolUse', 'PostToolUse'].includes(item.event)
88
+ || item.reason !== undefined && !text(item.reason, 2048) || item.outcome !== undefined && !text(item.outcome, 128)
89
+ || item.durationMs !== undefined && (typeof item.durationMs !== 'number' || !Number.isFinite(item.durationMs) || item.durationMs < 0)
90
+ || item.exitCode !== undefined && item.exitCode !== null && !Number.isSafeInteger(item.exitCode))
91
+ return;
92
+ hooks.push({ ...item });
93
+ }
94
+ return { schemaVersion: 1, requestId: raw.requestId, payloadHash: raw.payloadHash, completedAt: raw.completedAt, status: raw.status,
95
+ ...(raw.reason !== undefined ? { reason: raw.reason } : {}), ...(raw.hookFinalDecision !== undefined ? { hookFinalDecision: raw.hookFinalDecision } : {}), ...(raw.hooks !== undefined ? { hooks } : {}) };
96
+ }
@@ -0,0 +1,237 @@
1
+ import type { BotDocumentReference } from './document-reference.ts';
2
+ import type { ResourceFeedbackRecipient, ResourceFeedbackPreparationIdentity } from './resource-feedback.ts';
3
+ /** Recoverable intent only. These records never grant filesystem access or prove execution. */
4
+ export interface ResourceEditTarget {
5
+ readonly recipient: ResourceFeedbackRecipient;
6
+ readonly reference: BotDocumentReference;
7
+ readonly base: {
8
+ readonly resourceId: string;
9
+ readonly contentVersion: string;
10
+ };
11
+ }
12
+ export interface ResourceTextDraft {
13
+ readonly id: string;
14
+ readonly target: ResourceEditTarget;
15
+ readonly baseText: string;
16
+ readonly text: string;
17
+ readonly revision: number;
18
+ readonly createdAt: string;
19
+ readonly updatedAt: string;
20
+ }
21
+ /** Host validates the real sender separately. A token cannot substitute for PermissionGrant. */
22
+ export interface ResourceEditWriter extends ResourceFeedbackPreparationIdentity {
23
+ readonly token: string;
24
+ readonly lease: number;
25
+ }
26
+ export interface ResourceEditReceipt {
27
+ readonly outcome: 'applied' | 'conflict' | 'denied' | 'cancelled' | 'failed';
28
+ readonly toolCallId?: string;
29
+ readonly evidenceRef?: string;
30
+ readonly observedVersion?: string;
31
+ }
32
+ export interface ResourceEditOperation {
33
+ readonly requestId: string;
34
+ readonly draftId: string;
35
+ readonly draftRevision: number;
36
+ readonly target: ResourceEditTarget;
37
+ readonly providerId: string;
38
+ readonly proposedVersion: string;
39
+ readonly payloadHash: string;
40
+ readonly createdAt: string;
41
+ readonly updatedAt: string;
42
+ readonly phase: 'prepared' | 'running' | 'uncertain' | 'settled';
43
+ readonly hostEpoch?: string;
44
+ readonly receipt?: ResourceEditReceipt;
45
+ }
46
+ export declare const RESOURCE_TEXT_DRAFT_LIMIT = 16;
47
+ export declare const RESOURCE_EDIT_OPERATION_LIMIT = 64;
48
+ export declare const RESOURCE_EDIT_TEXT_BYTES: number;
49
+ export declare const resourceEditToken: (v: unknown) => v is string;
50
+ export declare const resourceEditDigest: (v: unknown) => v is string;
51
+ export declare function validResourceEditText(v: unknown): v is string;
52
+ export declare function normalizeResourceEditTarget(raw: unknown): ResourceEditTarget | undefined;
53
+ export declare function normalizeResourceTextDraft(raw: unknown): ResourceTextDraft | undefined;
54
+ export declare function normalizeResourceEditWriter(raw: unknown): ResourceEditWriter | undefined;
55
+ export declare function normalizeResourceEditReceipt(raw: unknown): ResourceEditReceipt | undefined;
56
+ export declare function normalizeResourceEditOperation(raw: unknown): ResourceEditOperation | undefined;
57
+ /** Retained text is a version, not current filesystem authority or task acceptance. */
58
+ export interface ResourceTextSnapshot {
59
+ readonly id: string;
60
+ readonly target: ResourceEditTarget;
61
+ readonly version: string;
62
+ readonly createdAt: string;
63
+ readonly purpose: 'before' | 'after' | 'delivery';
64
+ readonly availability: 'retained' | 'cleaned';
65
+ readonly evidenceRef: string;
66
+ readonly toolCallId?: string;
67
+ readonly operationId?: string;
68
+ readonly artifactRef?: string;
69
+ }
70
+ export declare function normalizeResourceTextSnapshot(raw: unknown): ResourceTextSnapshot | undefined;
71
+ export type ResourceEditSource = {
72
+ readonly kind: 'document';
73
+ readonly reference: BotDocumentReference;
74
+ readonly observed: ResourceEditTarget['base'];
75
+ } | {
76
+ readonly kind: 'native';
77
+ readonly identity: import('./resource-window.ts').ResourceWindowIdentity;
78
+ readonly path?: string;
79
+ readonly observed: ResourceEditTarget['base'];
80
+ };
81
+ export interface ResourceEditViewHandle {
82
+ readonly viewId: string;
83
+ readonly windowId: string;
84
+ readonly generation: number;
85
+ readonly draftId: string;
86
+ }
87
+ export interface ResourceEditView {
88
+ readonly handle: ResourceEditViewHandle;
89
+ readonly draft: ResourceTextDraft;
90
+ }
91
+ export type ResourceEditResult<T extends object = Record<never, never>> = ({
92
+ readonly ok: true;
93
+ } & T) | {
94
+ readonly ok: false;
95
+ readonly code: string;
96
+ };
97
+ export interface ResourceEditScope {
98
+ readonly workspaceId: string;
99
+ readonly handle?: ResourceEditViewHandle;
100
+ }
101
+ export interface ResourceEditDraftInfo extends Omit<ResourceTextDraft, 'baseText' | 'text'> {
102
+ readonly hasChanges: boolean;
103
+ }
104
+ export interface ResourceEditNotice {
105
+ readonly workspaceId: string;
106
+ readonly draftId?: string;
107
+ readonly kind: 'writer' | 'saved' | 'discarded' | 'history' | 'operation';
108
+ readonly requestId?: string;
109
+ readonly writerViewId?: string;
110
+ readonly revision?: number;
111
+ }
112
+ export interface ResourceEditSaveReceipt {
113
+ readonly draftId: string;
114
+ readonly revision: number;
115
+ readonly updatedAt: string;
116
+ readonly textVersion: string;
117
+ }
118
+ export interface ResourceEditOperationRequest {
119
+ readonly handle: ResourceEditViewHandle;
120
+ readonly requestId: string;
121
+ }
122
+ export interface ResourceEditPermissionChallenge {
123
+ readonly requestId: string;
124
+ readonly challengeId: string;
125
+ readonly argsDigest: string;
126
+ readonly deadlineAt: string;
127
+ readonly path: string;
128
+ readonly expectedVersion: string;
129
+ readonly proposedVersion: string;
130
+ readonly reason: string;
131
+ readonly confirmation?: string;
132
+ }
133
+ export interface ResourceEditOperationStatus {
134
+ readonly operation: ResourceEditOperation;
135
+ readonly live: boolean;
136
+ readonly hostOwnedHere?: boolean;
137
+ readonly hasActualResult: boolean;
138
+ readonly governance: 'pending' | 'recorded' | 'unconfirmed' | 'unavailable';
139
+ readonly permission: ResourceEditPermissionChallenge | null;
140
+ readonly permissionElsewhere?: boolean;
141
+ readonly observation?: 'matches_proposed' | 'matches_base' | 'changed' | 'unavailable';
142
+ }
143
+ export interface ResourceEditsApi {
144
+ readonly onChanged: (listener: (notice: ResourceEditNotice) => void) => () => void;
145
+ readonly open: (request: {
146
+ readonly requestId: string;
147
+ readonly source: ResourceEditSource;
148
+ }) => Promise<ResourceEditResult<ResourceEditView>>;
149
+ readonly resume: (request: {
150
+ readonly requestId: string;
151
+ readonly workspaceId: string;
152
+ readonly draftId: string;
153
+ readonly source?: ResourceEditSource;
154
+ }) => Promise<ResourceEditResult<ResourceEditView>>;
155
+ readonly cancelOpen: (requestId: string) => Promise<ResourceEditResult>;
156
+ readonly read: (handle: ResourceEditViewHandle) => Promise<ResourceEditResult<ResourceEditView>>;
157
+ readonly acquire: (request: {
158
+ readonly handle: ResourceEditViewHandle;
159
+ readonly takeover?: boolean;
160
+ }) => Promise<ResourceEditResult<ResourceEditView & {
161
+ readonly writer: ResourceEditWriter;
162
+ }>>;
163
+ readonly save: (request: {
164
+ readonly handle: ResourceEditViewHandle;
165
+ readonly writer: ResourceEditWriter;
166
+ readonly revision: number;
167
+ readonly text: string;
168
+ }) => Promise<ResourceEditResult<{
169
+ readonly saved: ResourceEditSaveReceipt;
170
+ }>>;
171
+ readonly discard: (request: {
172
+ readonly handle: ResourceEditViewHandle;
173
+ readonly writer: ResourceEditWriter;
174
+ readonly revision: number;
175
+ }) => Promise<ResourceEditResult>;
176
+ readonly close: (handle: ResourceEditViewHandle) => Promise<ResourceEditResult>;
177
+ readonly list: (request: ResourceEditScope & {
178
+ readonly cursor?: string;
179
+ readonly limit?: number;
180
+ }) => Promise<ResourceEditResult<{
181
+ readonly drafts: readonly ResourceEditDraftInfo[];
182
+ readonly operations: readonly ResourceEditOperation[];
183
+ readonly nextCursor: string | null;
184
+ readonly staleCount: number;
185
+ }>>;
186
+ readonly history: (request: ResourceEditScope & {
187
+ readonly cursor?: string;
188
+ readonly limit?: number;
189
+ }) => Promise<ResourceEditResult<{
190
+ readonly items: readonly ResourceTextSnapshot[];
191
+ readonly nextCursor: string | null;
192
+ readonly unavailableCount: number;
193
+ }>>;
194
+ readonly readSnapshot: (request: ResourceEditScope & {
195
+ readonly id: string;
196
+ }) => Promise<ResourceEditResult<{
197
+ readonly snapshot: ResourceTextSnapshot;
198
+ readonly content: string;
199
+ }>>;
200
+ readonly cleanup: (request: ResourceEditScope & {
201
+ readonly requestIds: readonly string[];
202
+ }) => Promise<ResourceEditResult<{
203
+ readonly removedBytes: number;
204
+ }>>;
205
+ readonly archive: (request: ResourceEditScope & {
206
+ readonly requestId: string;
207
+ }) => Promise<ResourceEditResult>;
208
+ readonly clearDelivery: (request: ResourceEditScope & {
209
+ readonly id: string;
210
+ }) => Promise<ResourceEditResult<{
211
+ readonly removedBytes: number;
212
+ }>>;
213
+ readonly submit: (request: ResourceEditOperationRequest & {
214
+ readonly writer: ResourceEditWriter;
215
+ readonly revision: number;
216
+ }) => Promise<ResourceEditResult<ResourceEditOperationStatus>>;
217
+ readonly continueSubmission: (request: ResourceEditOperationRequest) => Promise<ResourceEditResult<ResourceEditOperationStatus>>;
218
+ readonly operationStatus: (request: ResourceEditOperationRequest) => Promise<ResourceEditResult<ResourceEditOperationStatus>>;
219
+ readonly reconcileSubmission: (request: ResourceEditOperationRequest) => Promise<ResourceEditResult<ResourceEditOperationStatus>>;
220
+ readonly cancelSubmission: (request: ResourceEditOperationRequest) => Promise<ResourceEditResult<ResourceEditOperationStatus>>;
221
+ readonly decideSubmissionPermission: (request: ResourceEditOperationRequest & {
222
+ readonly challengeId: string;
223
+ readonly argsDigest: string;
224
+ readonly allow: boolean;
225
+ }) => Promise<ResourceEditResult>;
226
+ readonly readExecution: (request: ResourceEditOperationRequest) => Promise<ResourceEditResult<{
227
+ readonly record: import('./resource-edit-execution.ts').ResourceEditExecutionRecord;
228
+ readonly postlude: import('./resource-edit-execution.ts').ResourceEditPostlude | null;
229
+ }>>;
230
+ readonly readSubmission: (request: ResourceEditOperationRequest) => Promise<ResourceEditResult<{
231
+ readonly operation: ResourceEditOperation;
232
+ readonly baseText: string;
233
+ readonly text: string;
234
+ }>>;
235
+ }
236
+ export declare function normalizeResourceEditSource(raw: unknown): ResourceEditSource | undefined;
237
+ export declare function normalizeResourceEditHandle(raw: unknown): ResourceEditViewHandle | undefined;
@@ -0,0 +1,134 @@
1
+ import { normalizeResourceWindowRequest } from "./resource-window.js";
2
+ export const RESOURCE_TEXT_DRAFT_LIMIT = 16;
3
+ export const RESOURCE_EDIT_OPERATION_LIMIT = 64;
4
+ export const RESOURCE_EDIT_TEXT_BYTES = 1024 * 1024;
5
+ const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
6
+ const keys = (v, allowed) => Object.keys(v).every(k => allowed.includes(k));
7
+ export const resourceEditToken = (v) => typeof v === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,255}$/.test(v) && !v.includes('..');
8
+ export const resourceEditDigest = (v) => typeof v === 'string' && /^sha256:[a-f0-9]{64}$/.test(v);
9
+ const integer = (v) => Number.isSafeInteger(v) && Number(v) >= 0;
10
+ const timestamp = (v) => typeof v === 'string' && v.length <= 40 && Number.isFinite(Date.parse(v));
11
+ const metadataText = (v) => typeof v === 'string' && !!v.trim() && v.length <= 2048 && !/[\u0000-\u001f]/.test(v);
12
+ export function validResourceEditText(v) {
13
+ if (typeof v !== 'string' || v.length > RESOURCE_EDIT_TEXT_BYTES || v.includes('\u0000'))
14
+ return false;
15
+ for (let i = 0; i < v.length; i++) {
16
+ const n = v.charCodeAt(i);
17
+ if (n >= 0xd800 && n <= 0xdbff) {
18
+ const next = v.charCodeAt(++i);
19
+ if (!(next >= 0xdc00 && next <= 0xdfff))
20
+ return false;
21
+ }
22
+ else if (n >= 0xdc00 && n <= 0xdfff)
23
+ return false;
24
+ }
25
+ return new TextEncoder().encode(v).byteLength <= RESOURCE_EDIT_TEXT_BYTES;
26
+ }
27
+ export function normalizeResourceEditTarget(raw) {
28
+ if (!object(raw) || !keys(raw, ['recipient', 'reference', 'base']) || !object(raw.recipient)
29
+ || !keys(raw.recipient, ['workspaceId', 'conversationId']) || !resourceEditToken(raw.recipient.workspaceId) || !resourceEditToken(raw.recipient.conversationId)
30
+ || !object(raw.base) || !keys(raw.base, ['resourceId', 'contentVersion']) || !resourceEditDigest(raw.base.resourceId) || !resourceEditDigest(raw.base.contentVersion))
31
+ return;
32
+ const normalized = normalizeResourceWindowRequest({ resource: { kind: 'document', mode: 'source', reference: raw.reference } });
33
+ const reference = normalized?.resource.kind === 'document' ? normalized.resource.reference : undefined;
34
+ if (!reference || reference.revision || reference.kind === 'directory' || reference.relativeTo !== undefined
35
+ || reference.workspaceId !== raw.recipient.workspaceId || !/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(reference.path))
36
+ return;
37
+ if (reference.expectedObservation && (reference.expectedObservation.resourceId !== raw.base.resourceId
38
+ || reference.expectedObservation.contentVersion !== undefined && reference.expectedObservation.contentVersion !== raw.base.contentVersion))
39
+ return;
40
+ return { recipient: { workspaceId: raw.recipient.workspaceId, conversationId: raw.recipient.conversationId },
41
+ reference: { ...reference, kind: 'file', expectedObservation: { resourceId: raw.base.resourceId, contentVersion: raw.base.contentVersion } },
42
+ base: { resourceId: raw.base.resourceId, contentVersion: raw.base.contentVersion } };
43
+ }
44
+ export function normalizeResourceTextDraft(raw) {
45
+ if (!object(raw) || !keys(raw, ['id', 'target', 'baseText', 'text', 'revision', 'createdAt', 'updatedAt']) || !resourceEditToken(raw.id)
46
+ || !validResourceEditText(raw.baseText) || !validResourceEditText(raw.text) || !integer(raw.revision) || !timestamp(raw.createdAt) || !timestamp(raw.updatedAt))
47
+ return;
48
+ const target = normalizeResourceEditTarget(raw.target);
49
+ if (!target)
50
+ return;
51
+ return { id: raw.id, target, baseText: raw.baseText, text: raw.text, revision: raw.revision,
52
+ createdAt: new Date(raw.createdAt).toISOString(), updatedAt: new Date(raw.updatedAt).toISOString() };
53
+ }
54
+ export function normalizeResourceEditWriter(raw) {
55
+ if (!object(raw) || !keys(raw, ['viewId', 'windowId', 'generation', 'token', 'lease']) || !resourceEditToken(raw.viewId) || !resourceEditToken(raw.windowId)
56
+ || !resourceEditToken(raw.token) || !integer(raw.lease) || raw.lease < 1
57
+ || !(resourceEditToken(raw.generation) || integer(raw.generation) && raw.generation > 0))
58
+ return;
59
+ return { viewId: raw.viewId, windowId: raw.windowId, generation: raw.generation, token: raw.token, lease: raw.lease };
60
+ }
61
+ export function normalizeResourceEditReceipt(raw) {
62
+ if (!object(raw) || !keys(raw, ['outcome', 'toolCallId', 'evidenceRef', 'observedVersion'])
63
+ || typeof raw.outcome !== 'string' || !['applied', 'conflict', 'denied', 'cancelled', 'failed'].includes(raw.outcome)
64
+ || raw.toolCallId !== undefined && !metadataText(raw.toolCallId) || raw.evidenceRef !== undefined && !metadataText(raw.evidenceRef)
65
+ || (raw.toolCallId === undefined) !== (raw.evidenceRef === undefined)
66
+ || raw.observedVersion !== undefined && !resourceEditDigest(raw.observedVersion)
67
+ || raw.outcome === 'applied' && (raw.toolCallId === undefined || raw.evidenceRef === undefined || raw.observedVersion === undefined))
68
+ return;
69
+ return { outcome: raw.outcome, ...(raw.toolCallId !== undefined ? { toolCallId: raw.toolCallId, evidenceRef: raw.evidenceRef } : {}),
70
+ ...(raw.observedVersion !== undefined ? { observedVersion: raw.observedVersion } : {}) };
71
+ }
72
+ export function normalizeResourceEditOperation(raw) {
73
+ if (!object(raw) || !keys(raw, ['requestId', 'draftId', 'draftRevision', 'target', 'providerId', 'proposedVersion', 'payloadHash', 'createdAt', 'updatedAt', 'phase', 'hostEpoch', 'receipt'])
74
+ || !resourceEditToken(raw.requestId) || !resourceEditToken(raw.draftId) || !integer(raw.draftRevision) || !resourceEditToken(raw.providerId)
75
+ || !resourceEditDigest(raw.proposedVersion) || !resourceEditDigest(raw.payloadHash) || !timestamp(raw.createdAt) || !timestamp(raw.updatedAt)
76
+ || typeof raw.phase !== 'string' || !['prepared', 'running', 'uncertain', 'settled'].includes(raw.phase)
77
+ || raw.hostEpoch !== undefined && !resourceEditToken(raw.hostEpoch))
78
+ return;
79
+ const target = normalizeResourceEditTarget(raw.target), receipt = raw.receipt !== undefined ? normalizeResourceEditReceipt(raw.receipt) : undefined;
80
+ if (!target || raw.receipt !== undefined && !receipt || (raw.phase === 'running' || raw.phase === 'uncertain') && raw.hostEpoch === undefined
81
+ || raw.phase === 'prepared' && raw.hostEpoch !== undefined || (raw.phase === 'settled') !== !!receipt
82
+ || receipt?.outcome === 'applied' && receipt.observedVersion !== raw.proposedVersion)
83
+ return;
84
+ return { requestId: raw.requestId, draftId: raw.draftId, draftRevision: raw.draftRevision, target, providerId: raw.providerId,
85
+ proposedVersion: raw.proposedVersion, payloadHash: raw.payloadHash, createdAt: new Date(raw.createdAt).toISOString(), updatedAt: new Date(raw.updatedAt).toISOString(),
86
+ phase: raw.phase, ...(raw.hostEpoch !== undefined ? { hostEpoch: raw.hostEpoch } : {}), ...(receipt ? { receipt } : {}) };
87
+ }
88
+ export function normalizeResourceTextSnapshot(raw) {
89
+ if (!object(raw) || !keys(raw, ['id', 'target', 'version', 'createdAt', 'purpose', 'availability', 'evidenceRef', 'toolCallId', 'operationId', 'artifactRef'])
90
+ || !resourceEditToken(raw.id) || !resourceEditDigest(raw.version) || !timestamp(raw.createdAt) || !metadataText(raw.evidenceRef)
91
+ || !['before', 'after', 'delivery'].includes(raw.purpose) || !['retained', 'cleaned'].includes(raw.availability)
92
+ || raw.toolCallId !== undefined && !metadataText(raw.toolCallId) || raw.operationId !== undefined && !resourceEditToken(raw.operationId)
93
+ || raw.artifactRef !== undefined && !metadataText(raw.artifactRef))
94
+ return;
95
+ const target = normalizeResourceEditTarget(raw.target);
96
+ if (!target)
97
+ return;
98
+ if (raw.purpose === 'delivery' ? !metadataText(raw.artifactRef) || raw.operationId !== undefined || raw.version !== target.base.contentVersion
99
+ : !resourceEditToken(raw.operationId) || !metadataText(raw.toolCallId) || raw.artifactRef !== undefined || raw.purpose === 'before' && raw.version !== target.base.contentVersion)
100
+ return;
101
+ return { id: raw.id, target, version: raw.version, createdAt: new Date(raw.createdAt).toISOString(), purpose: raw.purpose,
102
+ availability: raw.availability, evidenceRef: raw.evidenceRef,
103
+ ...(raw.toolCallId !== undefined ? { toolCallId: raw.toolCallId } : {}), ...(raw.operationId !== undefined ? { operationId: raw.operationId } : {}),
104
+ ...(raw.artifactRef !== undefined ? { artifactRef: raw.artifactRef } : {}) };
105
+ }
106
+ export function normalizeResourceEditSource(raw) {
107
+ if (!object(raw) || !object(raw.observed) || !keys(raw.observed, ['resourceId', 'contentVersion'])
108
+ || !resourceEditDigest(raw.observed.resourceId) || !resourceEditDigest(raw.observed.contentVersion))
109
+ return;
110
+ const observed = { resourceId: raw.observed.resourceId, contentVersion: raw.observed.contentVersion };
111
+ if (raw.kind === 'document') {
112
+ if (!keys(raw, ['kind', 'reference', 'observed']))
113
+ return;
114
+ const normalized = normalizeResourceWindowRequest({ resource: { kind: 'document', mode: 'source', reference: raw.reference } });
115
+ const reference = normalized?.resource.kind === 'document' ? normalized.resource.reference : undefined;
116
+ if (!reference || reference.kind === 'directory' || reference.revision || reference.expectedObservation
117
+ && (reference.expectedObservation.resourceId !== observed.resourceId || reference.expectedObservation.contentVersion !== undefined && reference.expectedObservation.contentVersion !== observed.contentVersion))
118
+ return;
119
+ return { kind: 'document', reference: { ...reference, kind: 'file', expectedObservation: observed }, observed };
120
+ }
121
+ if (raw.kind !== 'native' || !keys(raw, ['kind', 'identity', 'path', 'observed']) || !object(raw.identity)
122
+ || !keys(raw.identity, ['viewId', 'windowId', 'generation']) || !resourceEditToken(raw.identity.viewId) || !resourceEditToken(raw.identity.windowId)
123
+ || !integer(raw.identity.generation) || raw.identity.generation < 1
124
+ || raw.path !== undefined && (typeof raw.path !== 'string' || raw.path.length > 8192 || /[\u0000-\u001f]/.test(raw.path) || !/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(raw.path)))
125
+ return;
126
+ return { kind: 'native', identity: { viewId: raw.identity.viewId, windowId: raw.identity.windowId, generation: raw.identity.generation }, observed,
127
+ ...(typeof raw.path === 'string' ? { path: raw.path } : {}) };
128
+ }
129
+ export function normalizeResourceEditHandle(raw) {
130
+ if (!object(raw) || !keys(raw, ['viewId', 'windowId', 'generation', 'draftId']) || !resourceEditToken(raw.viewId) || !resourceEditToken(raw.windowId) || !resourceEditToken(raw.draftId)
131
+ || !integer(raw.generation) || raw.generation < 1)
132
+ return;
133
+ return { viewId: raw.viewId, windowId: raw.windowId, generation: raw.generation, draftId: raw.draftId };
134
+ }
@@ -0,0 +1,26 @@
1
+ import type { ProjectInputAttachment } from './delegation.ts';
2
+ import { type ResourceFeedback } from './resource-feedback.ts';
3
+ export declare const INTERACTIVE_FEEDBACK_TRANSPORT = "peer-interactive-selection-1";
4
+ export declare const INPUT_ATTACHMENT_LIMIT = 100;
5
+ export declare function isInteractiveFeedbackAttachment(raw: unknown): boolean;
6
+ export declare function interactiveFeedbackAttachment(raw: unknown): ProjectInputAttachment;
7
+ export declare function readInteractiveFeedbackAttachment(raw: unknown): ResourceFeedback | undefined;
8
+ /** Logical typed material; callers still validate the actual immutable host receipt. */
9
+ export declare function restoreResourceFeedbackTransport(rawRows: unknown, rawAttachments?: readonly unknown[]): readonly ResourceFeedback[];
10
+ /** Only known legacy fields enter shared queues/messages. No path, permission, or new input lane. */
11
+ export declare function encodeResourceFeedbackTransport(rawRows: unknown, rawAttachments?: readonly ProjectInputAttachment[]): {
12
+ attachments?: ProjectInputAttachment[] | undefined;
13
+ resourceFeedback?: ResourceFeedback[] | undefined;
14
+ };
15
+ /** Read-only user-context projection. Syntax is not proof of a host receipt or authority.
16
+ * Invalid carriers remain ordinary attachments so their original text is still recoverable.
17
+ */
18
+ export declare function projectResourceFeedbackTransport(rawRows: unknown, rawAttachments: unknown): {
19
+ resourceFeedback: readonly ResourceFeedback[];
20
+ attachments: unknown[];
21
+ invalid: boolean;
22
+ } | {
23
+ resourceFeedback: never[];
24
+ attachments: readonly unknown[];
25
+ invalid: boolean;
26
+ };
@@ -0,0 +1,94 @@
1
+ import { normalizeResourceFeedback, normalizeResourceFeedbackList } from "./resource-feedback.js";
2
+ export const INTERACTIVE_FEEDBACK_TRANSPORT = 'peer-interactive-selection-1';
3
+ export const INPUT_ATTACHMENT_LIMIT = 100;
4
+ const fail = (code) => { throw Object.assign(new TypeError(code), { code }); };
5
+ const bytes = (value) => new TextEncoder().encode(value).byteLength;
6
+ const equal = (a, b) => JSON.stringify(a) === JSON.stringify(b);
7
+ export function isInteractiveFeedbackAttachment(raw) {
8
+ const item = raw;
9
+ return !!item && (typeof item.id === 'string' && /^interactive-[a-f0-9]{64}$/.test(item.id)
10
+ || item.kind === 'text' && typeof item.text === 'string' && /^\s*\{\s*"schema"\s*:\s*"peer-interactive-selection-/.test(item.text));
11
+ }
12
+ export function interactiveFeedbackAttachment(raw) {
13
+ const row = normalizeResourceFeedback(raw);
14
+ if (row?.resource.kind !== 'interactive' || row.version.kind !== 'interactive')
15
+ return fail('INVALID_INTERACTIVE_FEEDBACK');
16
+ const body = JSON.stringify({ schema: INTERACTIVE_FEEDBACK_TRANSPORT, feedback: row });
17
+ if (bytes(body) > 33 * 1024)
18
+ return fail('INTERACTIVE_FEEDBACK_LIMIT');
19
+ return { id: `interactive-${row.version.selectionDigest.slice(7)}`, name: 'Interactive conditions.json', mimeType: 'application/json', size: bytes(body),
20
+ sourceKind: 'user_upload', kind: 'text', text: body };
21
+ }
22
+ export function readInteractiveFeedbackAttachment(raw) {
23
+ if (!isInteractiveFeedbackAttachment(raw))
24
+ return;
25
+ const item = raw;
26
+ if (item?.sourceKind !== 'user_upload' || item.kind !== 'text' || typeof item.text !== 'string' || bytes(item.text) > 33 * 1024)
27
+ return fail('INVALID_INTERACTIVE_FEEDBACK_TRANSPORT');
28
+ let parsed;
29
+ try {
30
+ parsed = JSON.parse(item.text);
31
+ }
32
+ catch {
33
+ return fail('INVALID_INTERACTIVE_FEEDBACK_TRANSPORT');
34
+ }
35
+ if (!parsed || Object.keys(parsed).length !== 2 || parsed.schema !== INTERACTIVE_FEEDBACK_TRANSPORT || !('feedback' in parsed))
36
+ return fail('INTERACTIVE_FEEDBACK_TRANSPORT_INCOMPATIBLE');
37
+ const row = normalizeResourceFeedback(parsed.feedback);
38
+ if (!row || row.resource.kind !== 'interactive' || row.version.kind !== 'interactive')
39
+ return fail('INVALID_INTERACTIVE_FEEDBACK_TRANSPORT');
40
+ const expected = interactiveFeedbackAttachment(row);
41
+ if (Object.keys(item).length !== Object.keys(expected).length || Object.entries(expected).some(([key, value]) => item[key] !== value))
42
+ return fail('INTERACTIVE_FEEDBACK_TRANSPORT_CONFLICT');
43
+ return row;
44
+ }
45
+ /** Logical typed material; callers still validate the actual immutable host receipt. */
46
+ export function restoreResourceFeedbackTransport(rawRows, rawAttachments = []) {
47
+ const rows = normalizeResourceFeedbackList(rawRows);
48
+ if (!rows)
49
+ return fail('INVALID_RESOURCE_FEEDBACK');
50
+ const selected = new Map(rows.map(row => [row.id, row]));
51
+ for (const item of rawAttachments) {
52
+ const row = readInteractiveFeedbackAttachment(item);
53
+ if (!row)
54
+ continue;
55
+ const previous = selected.get(row.id);
56
+ if (previous && !equal(previous, row))
57
+ return fail('RESOURCE_FEEDBACK_ID_CONFLICT');
58
+ selected.set(row.id, row);
59
+ }
60
+ const restored = normalizeResourceFeedbackList([...selected.values()]);
61
+ if (!restored)
62
+ return fail('RESOURCE_FEEDBACK_LIMIT');
63
+ return restored;
64
+ }
65
+ /** Only known legacy fields enter shared queues/messages. No path, permission, or new input lane. */
66
+ export function encodeResourceFeedbackTransport(rawRows, rawAttachments = []) {
67
+ const rows = restoreResourceFeedbackTransport(rawRows, rawAttachments);
68
+ const attachments = [...rawAttachments], legacy = rows.filter(row => row.resource.kind !== 'interactive');
69
+ for (const row of rows.filter(row => row.resource.kind === 'interactive')) {
70
+ const attachment = interactiveFeedbackAttachment(row), previous = attachments.find(item => item.id === attachment.id);
71
+ // Legacy upload normalizers may reconstruct the same fields in a different
72
+ // property order. The strict decoder already checked every field and byte.
73
+ if (previous && !equal(readInteractiveFeedbackAttachment(previous), row))
74
+ return fail('RESOURCE_FEEDBACK_ID_CONFLICT');
75
+ if (!previous)
76
+ attachments.push(attachment);
77
+ }
78
+ if (attachments.length > INPUT_ATTACHMENT_LIMIT)
79
+ return fail('RESOURCE_FEEDBACK_ATTACHMENT_LIMIT');
80
+ return { ...(legacy.length ? { resourceFeedback: legacy } : {}), ...(attachments.length ? { attachments } : {}) };
81
+ }
82
+ /** Read-only user-context projection. Syntax is not proof of a host receipt or authority.
83
+ * Invalid carriers remain ordinary attachments so their original text is still recoverable.
84
+ */
85
+ export function projectResourceFeedbackTransport(rawRows, rawAttachments) {
86
+ const attachments = Array.isArray(rawAttachments) ? rawAttachments : [];
87
+ try {
88
+ return { resourceFeedback: restoreResourceFeedbackTransport(rawRows, attachments),
89
+ attachments: attachments.filter(item => !isInteractiveFeedbackAttachment(item)), invalid: false };
90
+ }
91
+ catch {
92
+ return { resourceFeedback: [], attachments, invalid: true };
93
+ }
94
+ }