@peer-agent/protocol 0.1.0-rc.26 → 0.1.0-rc.28

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.
@@ -14,3 +14,12 @@ export interface CoordinationUsageObservation {
14
14
  readonly tokens: number | null;
15
15
  readonly costUsd: number | null;
16
16
  }
17
+ /** A durable input receipt is independent of this execution/recovery barrier. */
18
+ export interface BotRecoveryStatus {
19
+ readonly state: 'blocked';
20
+ readonly reason: 'history_conflict' | 'reconciliation_required' | 'recovery_failed';
21
+ readonly code: string;
22
+ readonly phase: string;
23
+ readonly retryable: boolean;
24
+ }
25
+ export declare function projectBotRecoveryStatus(error: unknown, phase?: string): BotRecoveryStatus;
@@ -1 +1,9 @@
1
- export {};
1
+ export function projectBotRecoveryStatus(error, phase = 'unknown') {
2
+ const code = typeof error === 'string' && /^[a-zA-Z0-9_:-]{1,120}$/.test(error) ? error : 'RECOVERY_FAILED';
3
+ const conflict = ['coordination_legacy_changed', 'coordination_hash_mismatch', 'coordination_journal_missing',
4
+ 'coordination_legacy_seal_invalid', 'coordination_repair_incomplete', 'coordination_fence_incomplete', 'coordination_fence_invalid', 'coordination_writer_fence_missing',
5
+ 'coordination_writer_upgrade_required', 'coordination_schema_unsupported'].includes(code);
6
+ const held = code === 'coordination_reconciliation_required';
7
+ return { state: 'blocked', reason: held ? 'reconciliation_required' : conflict ? 'history_conflict' : 'recovery_failed', code,
8
+ phase: /^[a-z_]{1,40}$/.test(phase) ? phase : 'unknown', retryable: !conflict && !held };
9
+ }
@@ -0,0 +1,48 @@
1
+ /** Native address copies have independent instance identities; never a migrated webview. */
2
+ export interface BrowserWindowIdentity {
3
+ readonly viewId: string;
4
+ readonly windowId: string;
5
+ readonly generation: string;
6
+ }
7
+ export interface BrowserWindowCopyRequest {
8
+ readonly conversationId: string;
9
+ readonly browserTabId: string;
10
+ readonly webContentsId: number;
11
+ }
12
+ export type BrowserWindowAction = 'navigate' | 'back' | 'forward' | 'reload' | 'stop' | 'return' | 'close';
13
+ export interface BrowserWindowState {
14
+ readonly identity: BrowserWindowIdentity;
15
+ readonly conversationId: string;
16
+ readonly browserTabId: string;
17
+ readonly url: string;
18
+ readonly title: string;
19
+ readonly loading: boolean;
20
+ readonly canBack: boolean;
21
+ readonly canForward: boolean;
22
+ readonly failure: string | null;
23
+ readonly sequence: number;
24
+ readonly copy: true;
25
+ }
26
+ export type BrowserWindowResult = {
27
+ readonly ok: true;
28
+ readonly state: BrowserWindowState;
29
+ readonly returnStatus?: 'returned' | 'source_tab_closed';
30
+ } | {
31
+ readonly ok: false;
32
+ readonly status: 'invalid_request' | 'scope_denied' | 'source_unavailable' | 'limit_reached' | 'stale_view' | 'cancelled';
33
+ };
34
+ export interface BrowserWindowReturnRequest {
35
+ readonly requestId: string;
36
+ readonly identity: BrowserWindowIdentity;
37
+ readonly conversationId: string;
38
+ readonly workspaceId?: string;
39
+ readonly browserTabId: string;
40
+ readonly expiresAt: number;
41
+ }
42
+ export interface BrowserWindowReturnAck {
43
+ readonly requestId: string;
44
+ readonly identity: BrowserWindowIdentity;
45
+ readonly status: 'returned' | 'source_tab_closed' | 'cancelled';
46
+ }
47
+ export declare function normalizeBrowserWindowUrl(raw: unknown): string | null;
48
+ export declare function normalizeBrowserWindowCopyRequest(raw: unknown): BrowserWindowCopyRequest | null;
@@ -0,0 +1,23 @@
1
+ export function normalizeBrowserWindowUrl(raw) {
2
+ if (typeof raw !== 'string' || raw.length > 8192)
3
+ return null;
4
+ try {
5
+ const url = new URL(raw);
6
+ return ['http:', 'https:'].includes(url.protocol) && !url.username && !url.password ? url.href : null;
7
+ }
8
+ catch {
9
+ return null;
10
+ }
11
+ }
12
+ export function normalizeBrowserWindowCopyRequest(raw) {
13
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw))
14
+ return null;
15
+ const v = raw;
16
+ if (Object.keys(v).some(k => !['conversationId', 'browserTabId', 'webContentsId'].includes(k)))
17
+ return null;
18
+ if (![v.conversationId, v.browserTabId].every(x => typeof x === 'string' && x.length > 0 && x.length <= 256))
19
+ return null;
20
+ if (!Number.isSafeInteger(v.webContentsId) || v.webContentsId <= 0)
21
+ return null;
22
+ return { conversationId: v.conversationId, browserTabId: v.browserTabId, webContentsId: v.webContentsId };
23
+ }
@@ -0,0 +1,20 @@
1
+ /** A factual refusal layer; it never grants permission or changes acceptance. */
2
+ export interface CapabilityBlocker {
3
+ readonly stage: 'projection' | 'role' | 'delegation_admission' | 'permission' | 'execution';
4
+ readonly reason: string;
5
+ readonly capabilityId?: string;
6
+ readonly required?: readonly string[];
7
+ readonly available?: readonly string[];
8
+ readonly missing?: readonly string[];
9
+ readonly criterionIds?: readonly string[];
10
+ readonly alternatives?: readonly string[];
11
+ readonly retryable: boolean;
12
+ readonly userActionRequired: boolean;
13
+ }
14
+ export interface DelegationCapabilityAdmission {
15
+ readonly required: readonly string[];
16
+ readonly inventoryHash: string | null;
17
+ readonly inventoryKnown: boolean;
18
+ readonly requirementsDeclared: boolean;
19
+ readonly checkedAt: string;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -31,6 +31,7 @@ export interface CoordinationDecision {
31
31
  }
32
32
  export type TaskTransitionPhase = 'recorded' | 'stopping' | 'awaiting_outcome' | 'ready' | 'started' | 'completed' | 'blocked';
33
33
  export interface TaskTransition {
34
+ diagnostic?: import('./capability-admission.ts').CapabilityBlocker;
34
35
  schemaVersion: 1;
35
36
  operationId: string;
36
37
  workId: string;
@@ -8,6 +8,7 @@ export type WorkSessionStatus = 'paused' | 'queued' | 'starting' | 'running' | '
8
8
  export declare const WORK_SESSION_STATUSES: readonly ["paused", "queued", "starting", "running", "waiting_user", "waiting_agent", "stopping", "awaiting_outcome", "verifying", "result_ready", "accepted", "failed", "cancelled", "superseded"];
9
9
  export type InputSurface = 'desktop' | 'quick_chat' | 'tui' | 'remote';
10
10
  export interface DelegationOrigin {
11
+ readonly capabilityAdmission?: import('./capability-admission.ts').DelegationCapabilityAdmission;
11
12
  readonly takeover?: {
12
13
  operationId: string;
13
14
  phase: 'stopping' | 'completed';
@@ -24,7 +25,9 @@ export interface DelegationOrigin {
24
25
  readonly requestedAt: string;
25
26
  readonly completedAt?: string;
26
27
  readonly evidenceCalls?: readonly string[];
28
+ readonly preserveArtifacts?: boolean;
27
29
  };
30
+ readonly retainedForRecovery?: boolean;
28
31
  readonly workId?: string;
29
32
  readonly anchorMessageId: string;
30
33
  readonly inputId: string;
@@ -355,6 +358,7 @@ export interface ProjectInput {
355
358
  readonly quoteRefs: readonly string[];
356
359
  readonly attachmentRefs: readonly string[];
357
360
  readonly attachments?: readonly ProjectInputAttachment[];
361
+ readonly resourceFeedback?: readonly import('./resource-feedback.ts').ResourceFeedback[];
358
362
  readonly createdAt: string;
359
363
  }
360
364
  /** Existing durable input receipt. A later handoff can fail after input was saved. */
@@ -0,0 +1,81 @@
1
+ export interface GitDocumentRevision {
2
+ readonly kind: 'git';
3
+ /** Complete immutable commit SHA only; never a branch or Git expression. */
4
+ readonly commit: string;
5
+ /** Host-confirmed device-local repository binding, not an authorization ticket. */
6
+ readonly repositoryId?: string;
7
+ }
8
+ export interface ConfirmedGitDocumentRevision extends GitDocumentRevision {
9
+ readonly repositoryId: string;
10
+ readonly path: string;
11
+ }
12
+ /** Human-initiated preview only. This reference never grants model/tool access. */
13
+ export interface BotDocumentReference {
14
+ readonly workspaceId: string;
15
+ readonly path: string;
16
+ readonly relativeTo?: string;
17
+ /** Host revalidates Session/GoalPlan ownership on every read; never a root or grant. */
18
+ readonly task?: {
19
+ readonly sessionId: string;
20
+ readonly planId: string;
21
+ };
22
+ /** Explicit UI navigation intent; never an authorization root. */
23
+ readonly kind?: 'file' | 'directory';
24
+ /** Resolve/stat only; never returns file contents. */
25
+ readonly metadataOnly?: boolean;
26
+ /** Conditional text/image read only; an observation never grants access. */
27
+ readonly expectedObservation?: {
28
+ readonly resourceId: string;
29
+ readonly contentVersion?: string;
30
+ };
31
+ readonly revision?: GitDocumentRevision;
32
+ }
33
+ /** Device-local locator identity, revalidated by the host on every access. */
34
+ export interface LocalDocumentIdentity {
35
+ readonly sourceId: string;
36
+ readonly resourceId: string;
37
+ readonly relativePath: string;
38
+ }
39
+ /** Version of the actual bytes returned by a successful read; not a saved snapshot. */
40
+ export interface LocalDocumentObservation extends LocalDocumentIdentity {
41
+ readonly contentVersion: string;
42
+ }
43
+ export interface LocalDocumentReadResult {
44
+ readonly metadataOnly?: boolean;
45
+ readonly ok: boolean;
46
+ readonly status: 'ok' | 'not_found' | 'not_file' | 'too_large' | 'binary' | 'invalid_path' | 'error' | 'permission_denied' | 'scope_denied' | 'ambiguous_path' | 'workspace_unavailable' | 'relative_base_required' | 'version_changed' | 'source_changed' | 'version_unavailable' | 'not_git_repo' | 'invalid_ref' | 'revision_unavailable' | 'unsupported_entry';
47
+ readonly content: string;
48
+ readonly size?: number;
49
+ readonly resolvedFrom?: string;
50
+ readonly resolvedPath?: string;
51
+ readonly identity?: LocalDocumentIdentity;
52
+ readonly observation?: LocalDocumentObservation;
53
+ readonly revision?: ConfirmedGitDocumentRevision;
54
+ /** Confirmed locations for an explicit human choice; never an authorization ticket. */
55
+ readonly candidates?: readonly {
56
+ readonly path: string;
57
+ readonly root: string;
58
+ }[];
59
+ readonly error?: string;
60
+ }
61
+ /** Bounded presentation metadata from a known local file Tool Result in the same turn.
62
+ * A restored hint must be re-resolved under the current Bot scope before reading. */
63
+ export interface BotResourceReferenceHint {
64
+ readonly path: string;
65
+ readonly tool: 'read_file' | 'write_file' | 'edit_file';
66
+ }
67
+ /** Human-initiated, bounded filename discovery; every selected hit is re-authorized on read. */
68
+ export interface BotResourceSearchResult {
69
+ readonly ok: boolean;
70
+ readonly status: LocalDocumentReadResult['status'] | 'not_dir';
71
+ readonly scoped?: boolean;
72
+ readonly workspacePath?: string;
73
+ readonly files: readonly {
74
+ readonly relPath: string;
75
+ readonly name: string;
76
+ readonly kind: 'file' | 'directory';
77
+ }[];
78
+ readonly truncated?: boolean;
79
+ readonly visited?: number;
80
+ readonly error?: string;
81
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { BotDocumentReference } from './document-reference.ts';
1
2
  /** Read-only display facts. A saved operation is not proof that its task completed. */
2
3
  export interface EvidenceSourceDescription {
3
4
  readonly evidenceRef: string;
@@ -5,11 +6,17 @@ export interface EvidenceSourceDescription {
5
6
  readonly createdAt?: string;
6
7
  }
7
8
  export interface ProjectAgentEvidenceReadRequest {
9
+ readonly context?: {
10
+ readonly workspaceId: string;
11
+ readonly task?: BotDocumentReference['task'];
12
+ };
8
13
  readonly evidenceRef?: string;
9
14
  /** Source descriptions only; at most 100 unique references, no body or artifact reads. */
10
15
  readonly evidenceRefs?: readonly string[];
11
16
  }
12
17
  export interface ProjectAgentEvidenceReadResult {
18
+ readonly deliveryStatus?: 'available' | 'scope_denied' | 'unavailable';
19
+ readonly deliveries?: readonly EvidenceDelivery[];
13
20
  readonly ok: boolean;
14
21
  readonly code?: string;
15
22
  readonly evidenceRef?: string;
@@ -20,3 +27,25 @@ export interface ProjectAgentEvidenceReadResult {
20
27
  readonly source?: EvidenceSourceDescription;
21
28
  readonly items?: readonly EvidenceSourceDescription[];
22
29
  }
30
+ /** Navigation provenance only; revalidated against the canonical index after restore. */
31
+ export interface EvidenceDeliveryBinding {
32
+ readonly evidenceRef: string;
33
+ readonly artifactRef: string;
34
+ }
35
+ export interface EvidenceDelivery extends EvidenceDeliveryBinding {
36
+ readonly kind: 'file' | 'code-change' | 'image';
37
+ readonly label: string;
38
+ /** A locator, never a grant or proof of historical bytes. Read through the existing scoped service. */
39
+ readonly reference?: BotDocumentReference;
40
+ readonly savedPreview?: {
41
+ readonly kind: 'diff-summary';
42
+ readonly text: string;
43
+ readonly truncated: true;
44
+ } | {
45
+ readonly kind: 'image';
46
+ readonly dataUrl: string;
47
+ readonly width: number;
48
+ readonly height: number;
49
+ };
50
+ readonly previewUnavailable?: boolean;
51
+ }
package/dist/goal.d.ts CHANGED
@@ -166,7 +166,7 @@ export interface EvidenceIndexRecord {
166
166
  readonly artifactRefs?: readonly string[];
167
167
  /** Redacted, bounded execution-time snapshot of a successful local Tool Result. */
168
168
  readonly bodyPreview?: {
169
- readonly kind: 'file' | 'command';
169
+ readonly kind: 'file' | 'command' | 'observation';
170
170
  readonly text: string;
171
171
  readonly truncated: boolean;
172
172
  };
@@ -446,6 +446,7 @@ export interface GoalRunTrace {
446
446
  }
447
447
  export type GoalSuccessCriterionKind = 'command' | 'test' | 'file-contains' | 'file-exists' | 'model_review' | 'manual';
448
448
  export interface GoalSuccessCriterion {
449
+ readonly requiredCapabilities?: readonly string[];
449
450
  readonly id: string;
450
451
  readonly kind: GoalSuccessCriterionKind;
451
452
  readonly description: string;
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { ProjectWorkBudgetLimits, ProjectWorkBudgetBoundary, ProjectReplyRe
3
3
  export type { CoordinationAction, CoordinationLifecycle, CoordinationMandate, CoordinationDecision, TaskTransitionPhase, TaskTransition, CoordinationExecutionBinding, CoordinationSessionFacts } from './delegation-coordination.ts';
4
4
  export { deriveSessionFacts, type SessionFactSnapshot } from './session-facts.ts';
5
5
  export { projectAgentFailureKind, classifyProjectAgentFailure, type ProjectRecoveryFailureKind, type ProviderRequestRecovery, type ProjectAgentTurnRecovery, type ReplyAnchorCandidate } from './project-agent-failure.ts';
6
- export type { EvidenceSourceDescription, ProjectAgentEvidenceReadRequest, ProjectAgentEvidenceReadResult } from './evidence-inspection.ts';
6
+ export type { EvidenceSourceDescription, EvidenceDeliveryBinding, EvidenceDelivery, ProjectAgentEvidenceReadRequest, ProjectAgentEvidenceReadResult } from './evidence-inspection.ts';
7
7
  export { toolActivityPreview, toolActivitySummary } from './tool-activity-preview.ts';
8
8
  export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort, type ModelReasoningEffort } from './model-reasoning.ts';
9
9
  export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead } from './selection-reference.ts';
@@ -890,9 +890,22 @@ export * from './task-overview.ts';
890
890
  export * from './skill-marketplace.ts';
891
891
  export * from './delegation.ts';
892
892
  export * from './model-routing.ts';
893
+ export * from './document-reference.ts';
893
894
  export * from './project.ts';
894
895
  export * from './objectives.ts';
895
896
  export * from './remote-access-settings.ts';
896
897
  export type { BotModelSelectionUpdateRequest, BotModelSelectionUpdateResult } from './bot-model-selection.ts';
897
898
  export * from './local-image.ts';
898
899
  export * from './bot-conversation-read.ts';
900
+ export * from './project-recovery.ts';
901
+ export * from './local-git.ts';
902
+ export type { CapabilityBlocker, DelegationCapabilityAdmission } from './capability-admission.ts';
903
+ export * from './project-input-recovery.ts';
904
+ export { botResourceReferences } from './resource-reference-hints.ts';
905
+ export type { ResourceWindowCheckpointRequest, ResourceWindowCheckpointAck, ResourceWindowCloseBlocked, ResourceWindowReturnRequest, ResourceWindowReturnAck, ResourceWindowHistoryEntry, ResourceWindowHistoryResult, ResourceWindowReadRequest, ResourceWindowReadResult, ResourceWindowResource, ResourceWindowNavigation, ResourceWindowOpenRequest, ResourceWindowOwner, ResourceWindowIdentity, ResourceWindowContext, ResourceWindowStatus, ResourceWindowResult } from './resource-window.ts';
906
+ export { normalizeResourceWindowRequest, normalizeResourceWindowOwner, normalizeResourceWindowNavigation } from './resource-window.ts';
907
+ export * from './browser-window.js';
908
+ export * from './resource-feedback.js';
909
+ export * from './resource-edit.ts';
910
+ export * from './resource-file-replace.ts';
911
+ export * from './resource-edit-execution.ts';
package/dist/index.js CHANGED
@@ -38,8 +38,19 @@ export * from "./task-overview.js";
38
38
  export * from "./skill-marketplace.js";
39
39
  export * from "./delegation.js";
40
40
  export * from "./model-routing.js";
41
+ export * from "./document-reference.js";
41
42
  export * from "./project.js";
42
43
  export * from "./objectives.js";
43
44
  export * from "./remote-access-settings.js";
44
45
  export * from "./local-image.js";
45
46
  export * from "./bot-conversation-read.js";
47
+ export * from "./project-recovery.js";
48
+ export * from "./local-git.js";
49
+ export * from "./project-input-recovery.js";
50
+ export { botResourceReferences } from "./resource-reference-hints.js";
51
+ export { normalizeResourceWindowRequest, normalizeResourceWindowOwner, normalizeResourceWindowNavigation } from "./resource-window.js";
52
+ export * from './browser-window.js';
53
+ export * from './resource-feedback.js';
54
+ export * from "./resource-edit.js";
55
+ export * from "./resource-file-replace.js";
56
+ export * from "./resource-edit-execution.js";
@@ -0,0 +1,44 @@
1
+ /** ADR106: bounded repository observations; never arbitrary commands. */
2
+ export declare const LOCAL_GIT_CAPABILITY: "local.git.query";
3
+ export declare const LOCAL_GIT_TOOL: "git_query";
4
+ export type GitReadOperation = 'snapshot' | 'status' | 'log';
5
+ export interface GitReadQuery {
6
+ readonly path: string;
7
+ readonly operation?: GitReadOperation;
8
+ readonly limit?: number;
9
+ }
10
+ export interface GitReadObservation {
11
+ readonly repositoryPath: string;
12
+ readonly gitDirectory: string;
13
+ readonly commonDirectory: string;
14
+ readonly configurationSources: readonly string[];
15
+ readonly operation: GitReadOperation;
16
+ readonly startedAt: string;
17
+ readonly finishedAt: string;
18
+ readonly head: string | null;
19
+ readonly branch: string | null;
20
+ readonly unborn: boolean;
21
+ readonly origin: readonly string[];
22
+ readonly consistent: boolean;
23
+ readonly atomic: false;
24
+ readonly status?: {
25
+ readonly clean: boolean | null;
26
+ readonly submoduleCount: number;
27
+ readonly submodulesInspected: false;
28
+ readonly filtersDisabled: boolean;
29
+ readonly changed: number;
30
+ readonly untracked: number;
31
+ readonly entries: readonly {
32
+ readonly index: string;
33
+ readonly worktree: string;
34
+ readonly path: string;
35
+ readonly from?: string;
36
+ }[];
37
+ readonly truncated: boolean;
38
+ };
39
+ readonly commits: readonly {
40
+ readonly hash: string;
41
+ readonly committedAt: string;
42
+ readonly subject: string;
43
+ }[];
44
+ }
@@ -0,0 +1,3 @@
1
+ /** ADR106: bounded repository observations; never arbitrary commands. */
2
+ export const LOCAL_GIT_CAPABILITY = 'local.git.query';
3
+ export const LOCAL_GIT_TOOL = 'git_query';
@@ -5,21 +5,35 @@ import { type ModelReasoningEffort } from './model-reasoning.ts';
5
5
  */
6
6
  export type ModelTier = 'strong' | 'fast' | 'economy' | 'vision';
7
7
  export type ModelRole = 'project_agent' | 'session_worker' | 'explorer' | 'verifier' | 'visual_verifier' | 'memory_curator' | 'objective_probe' | 'compactor';
8
- export type RoleSetting = {
8
+ export type RoleSetting = ({
9
9
  readonly mode: 'tier';
10
10
  readonly tier: ModelTier;
11
11
  } | {
12
12
  readonly mode: 'fixed';
13
13
  readonly modelProviderId: string;
14
- readonly reasoningEffort?: ModelReasoningEffort;
15
14
  } | {
16
15
  readonly mode: 'auto';
17
16
  readonly pool: readonly string[];
17
+ }) & {
18
+ /** Undefined inherits the tier; null explicitly uses the model default. */
19
+ readonly reasoningEffort?: ModelReasoningEffort | null;
20
+ /** Undefined inherits the tier; false explicitly selects the normal channel. */
21
+ readonly fastMode?: boolean;
18
22
  };
19
23
  export interface ModelTierBinding {
20
24
  readonly primary: string;
21
25
  readonly fallbacks?: readonly string[];
26
+ readonly reasoningEffort?: ModelReasoningEffort;
27
+ readonly fastMode?: boolean;
22
28
  }
29
+ /** Admission matches the existing priority request encoders, never a model-name guess. */
30
+ export declare function modelSupportsFastMode(provider: {
31
+ readonly authMethod?: unknown;
32
+ }): boolean;
33
+ export declare function routingParameters(setting: RoleSetting, tiers: Partial<Record<ModelTier, ModelTierBinding>>): {
34
+ reasoningEffort: ModelReasoningEffort | undefined;
35
+ fastMode: boolean;
36
+ };
23
37
  export interface ModelRoutingSettings {
24
38
  readonly tiers: Partial<Record<ModelTier, ModelTierBinding>>;
25
39
  readonly roles: Partial<Record<ModelRole, RoleSetting>>;
@@ -42,6 +56,8 @@ export interface RuntimeModelSelection {
42
56
  readonly modelId: string;
43
57
  readonly modelProviderId: string;
44
58
  readonly reasoningEffort?: string;
59
+ /** Subscription priority channel. Encoding still admits only ChatGPT and Grok OAuth. */
60
+ readonly fastMode?: boolean;
45
61
  readonly family: string;
46
62
  }
47
63
  export interface ModelSelectionSnapshot {
@@ -110,6 +126,7 @@ export interface CatalogModel {
110
126
  readonly local?: boolean;
111
127
  readonly reasoningEffort?: string;
112
128
  readonly reasoningEffortLevels?: readonly ModelReasoningEffort[];
129
+ readonly supportsFastMode?: boolean;
113
130
  }
114
131
  export type ModelResolution = {
115
132
  readonly ok: true;
@@ -118,7 +135,7 @@ export type ModelResolution = {
118
135
  readonly sameFamilyAsWorker?: boolean;
119
136
  } | {
120
137
  readonly ok: false;
121
- readonly reason: 'capability' | 'scope' | 'auto_pool' | 'empty' | 'reasoning';
138
+ readonly reason: 'capability' | 'scope' | 'auto_pool' | 'empty' | 'reasoning' | 'fast_mode';
122
139
  readonly missing: string;
123
140
  };
124
141
  export interface RoleModelRequest {
@@ -1,4 +1,15 @@
1
1
  import { modelDefaultReasoningEffort, modelReasoningLevels } from "./model-reasoning.js";
2
+ /** Admission matches the existing priority request encoders, never a model-name guess. */
3
+ export function modelSupportsFastMode(provider) {
4
+ return provider.authMethod === 'oauth_chatgpt' || provider.authMethod === 'oauth_grok';
5
+ }
6
+ export function routingParameters(setting, tiers) {
7
+ const tier = setting.mode === 'tier' ? tiers[setting.tier] : undefined;
8
+ return {
9
+ reasoningEffort: (setting.reasoningEffort === undefined ? tier?.reasoningEffort : setting.reasoningEffort) ?? undefined,
10
+ fastMode: setting.fastMode ?? tier?.fastMode ?? false,
11
+ };
12
+ }
2
13
  /** Project one configured provider into the routing menu contract. */
3
14
  export function projectModelRoutingMenuOption(provider) {
4
15
  if (!provider || typeof provider.id !== 'string' || !provider.id.trim())
@@ -75,6 +86,8 @@ function inScope(model, policy) {
75
86
  return true;
76
87
  }
77
88
  function missingText(input, reason) {
89
+ if (reason === 'fast_mode')
90
+ return '所选连接不支持快速通道,请选择正常通道或支持的连接';
78
91
  if (reason === 'reasoning')
79
92
  return '所选模型不支持该推理强度';
80
93
  if (reason === 'auto_pool')
@@ -228,13 +241,20 @@ export function resolveRoleModel(input) {
228
241
  const chosen = ordered[0];
229
242
  if (!chosen)
230
243
  return fail(input, 'empty');
231
- const requestedEffort = layer.setting.mode === 'fixed' ? layer.setting.reasoningEffort : undefined;
244
+ const parameters = routingParameters(layer.setting, input.routing.tiers);
245
+ const requestedEffort = parameters.reasoningEffort;
232
246
  if (requestedEffort !== undefined && !chosen.reasoningEffortLevels?.includes(requestedEffort))
233
247
  return fail(input, 'reasoning');
248
+ if (parameters.fastMode && chosen.supportsFastMode !== true)
249
+ return fail(input, 'fast_mode');
234
250
  const source = layer.setting.mode === 'auto' ? 'auto' : layer.source;
235
251
  return {
236
252
  ok: true,
237
- selection: { ...toSelection(chosen), ...(requestedEffort !== undefined ? { reasoningEffort: requestedEffort } : {}) },
253
+ selection: {
254
+ ...toSelection(chosen),
255
+ ...(requestedEffort !== undefined ? { reasoningEffort: requestedEffort } : {}),
256
+ fastMode: parameters.fastMode,
257
+ },
238
258
  source,
239
259
  ...(input.role === 'verifier'
240
260
  ? { sameFamilyAsWorker: sameFamily(chosen, input.workerModel) }
@@ -0,0 +1,65 @@
1
+ import type { ResourceFeedback } from './resource-feedback.ts';
2
+ import type { ProjectInputAttachment, ProjectAgentSubmitInputResult } 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 InputDraftValue {
9
+ readonly text: string;
10
+ readonly quote: InputDraftQuote | null;
11
+ readonly attachments: readonly ProjectInputAttachment[];
12
+ readonly resourceFeedback?: readonly ResourceFeedback[];
13
+ }
14
+ /** User intent only. Presence here never means the input was received or executed. */
15
+ export interface UnconfirmedProjectInput {
16
+ readonly inputId: string;
17
+ readonly text: string;
18
+ readonly quoteRefs: readonly string[];
19
+ readonly answerTo?: string;
20
+ readonly attachments: readonly ProjectInputAttachment[];
21
+ readonly resourceFeedback?: readonly ResourceFeedback[];
22
+ readonly createdAt: string;
23
+ }
24
+ export interface ProjectInputDraftSnapshot {
25
+ readonly revision: number;
26
+ readonly draft: InputDraftValue;
27
+ readonly pending: readonly UnconfirmedProjectInput[];
28
+ }
29
+ export interface ProjectInputDraftReadRequest {
30
+ readonly workspaceId: string;
31
+ readonly surface: LocalInputSurface;
32
+ }
33
+ export type ProjectInputDraftReadResult = {
34
+ readonly ok: true;
35
+ readonly snapshot: ProjectInputDraftSnapshot;
36
+ } | {
37
+ readonly ok: false;
38
+ readonly code: string;
39
+ };
40
+ export interface ProjectInputDraftWriteRequest extends ProjectInputDraftReadRequest {
41
+ readonly revision: number;
42
+ readonly draft: Omit<InputDraftValue, 'attachments'> & {
43
+ readonly attachmentIds: readonly string[];
44
+ };
45
+ readonly pending: readonly (Omit<UnconfirmedProjectInput, 'attachments'> & {
46
+ readonly attachmentIds: readonly string[];
47
+ })[];
48
+ /** Already-stored attachments are referred to by ID; large bytes are sent only once. */
49
+ readonly uploads: readonly ProjectInputAttachment[];
50
+ }
51
+ export type ProjectInputDraftWriteResult = {
52
+ readonly ok: true;
53
+ readonly revision: number;
54
+ } | {
55
+ readonly ok: false;
56
+ readonly code: string;
57
+ };
58
+ export interface ProjectInputRecoveryPort {
59
+ read(request: ProjectInputDraftReadRequest): Promise<ProjectInputDraftReadResult>;
60
+ write(request: ProjectInputDraftWriteRequest): Promise<ProjectInputDraftWriteResult>;
61
+ submit(request: UnconfirmedProjectInput & ProjectInputDraftReadRequest): Promise<ProjectAgentSubmitInputResult>;
62
+ }
63
+ export declare function emptyInputDraft(): InputDraftValue;
64
+ /** A handoff failure may follow a durable receipt. Generic ok alone proves nothing. */
65
+ export declare function projectInputWasReceived(result: ProjectAgentSubmitInputResult | null | undefined, workspaceId: string, inputId: string): boolean;
@@ -0,0 +1,5 @@
1
+ export function emptyInputDraft() { return { text: '', quote: null, attachments: [] }; }
2
+ /** A handoff failure may follow a durable receipt. Generic ok alone proves nothing. */
3
+ export function projectInputWasReceived(result, workspaceId, inputId) {
4
+ return result?.input?.workspaceId === workspaceId && result.input.inputId === inputId;
5
+ }
@@ -0,0 +1,42 @@
1
+ /** Local maintenance controls. These commands never accept an execution verdict or a filesystem path. */
2
+ export interface ProjectRecoveryRequest {
3
+ readonly workspaceId: string;
4
+ readonly action: 'inspect' | 'restore' | 'retain';
5
+ readonly planToken?: string;
6
+ readonly workId?: string;
7
+ readonly sessionId?: string;
8
+ }
9
+ export interface ProjectRecoveryWork {
10
+ readonly workId: string;
11
+ readonly title: string;
12
+ readonly disposition: 'held' | 'resume';
13
+ readonly reason: string;
14
+ }
15
+ export interface ProjectRecoveryView {
16
+ readonly phase: 'occupied' | 'inspection' | 'stopping' | 'backing_up' | 'restoring' | 'reconciling' | 'ready' | 'failed';
17
+ readonly planToken?: string;
18
+ readonly restored: boolean;
19
+ readonly canContinue: boolean;
20
+ readonly runtimeReady: boolean;
21
+ readonly completedCount: number;
22
+ readonly works: readonly ProjectRecoveryWork[];
23
+ readonly sessions: readonly {
24
+ readonly sessionId: string;
25
+ readonly title: string;
26
+ }[];
27
+ readonly holder?: {
28
+ readonly surface: 'desktop' | 'tui';
29
+ readonly version: string;
30
+ };
31
+ readonly backupAvailable: boolean;
32
+ readonly backupLocation?: string;
33
+ readonly code?: string;
34
+ }
35
+ export type ProjectRecoveryResult = {
36
+ readonly ok: true;
37
+ readonly view: ProjectRecoveryView;
38
+ } | {
39
+ readonly ok: false;
40
+ readonly code: string;
41
+ readonly view?: ProjectRecoveryView;
42
+ };
@@ -0,0 +1 @@
1
+ export {};
package/dist/project.d.ts CHANGED
@@ -219,6 +219,8 @@ export interface ProjectAgentPublicUpdate {
219
219
  }
220
220
  /** Ephemeral interactive-turn presentation, including explicit wake retries. No hidden reasoning or Evidence. */
221
221
  export interface ProjectAgentActivity {
222
+ /** Same-turn successful local file results only; navigation hints never grant access. */
223
+ readonly resourceReferences?: readonly import('./document-reference.ts').BotResourceReferenceHint[];
222
224
  readonly workspaceId: string;
223
225
  readonly conversationId: string;
224
226
  readonly turnId: string;