@peer-agent/protocol 0.1.0-rc.46 → 0.1.0-rc.48
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.
- package/dist/bot-git.d.ts +52 -0
- package/dist/bot-git.js +1 -0
- package/dist/conversation-execution.d.ts +2 -0
- package/dist/conversation-execution.js +31 -1
- package/dist/delegation.d.ts +6 -0
- package/dist/delegation.js +16 -0
- package/dist/document-reference.d.ts +29 -1
- package/dist/gemini-standard-pricing.json +105 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.js +9 -1
- package/dist/memory.d.ts +71 -11
- package/dist/memory.js +12 -0
- package/dist/parent-coordination.d.ts +104 -0
- package/dist/parent-coordination.js +2 -0
- package/dist/project-matter.d.ts +223 -0
- package/dist/project-matter.js +1 -0
- package/dist/spend-budget.d.ts +69 -0
- package/dist/spend-budget.js +1 -0
- package/dist/system-context.d.ts +1 -0
- package/dist/usage-accounting.d.ts +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** User-requested desktop Git operations on a registered Bot workspace. */
|
|
2
|
+
export interface BotGitRepository {
|
|
3
|
+
readonly repoKey: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly branch: string | null;
|
|
6
|
+
readonly detached: boolean;
|
|
7
|
+
readonly unborn: boolean;
|
|
8
|
+
readonly headShort: string | null;
|
|
9
|
+
readonly upstream: string | null;
|
|
10
|
+
readonly defaultRef: string | null;
|
|
11
|
+
readonly compareRef: string | null;
|
|
12
|
+
readonly ahead: number | null;
|
|
13
|
+
readonly behind: number | null;
|
|
14
|
+
readonly changedCount: number;
|
|
15
|
+
readonly stagedCount: number;
|
|
16
|
+
readonly unstagedCount: number;
|
|
17
|
+
readonly untrackedCount: number;
|
|
18
|
+
readonly clean: boolean | null;
|
|
19
|
+
}
|
|
20
|
+
export interface BotGitWorkspaceRequest {
|
|
21
|
+
readonly workspaceId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface BotGitRepositoryRequest extends BotGitWorkspaceRequest {
|
|
24
|
+
readonly repoKey: string;
|
|
25
|
+
}
|
|
26
|
+
export interface BotGitSwitchRequest extends BotGitRepositoryRequest {
|
|
27
|
+
readonly branch: string;
|
|
28
|
+
}
|
|
29
|
+
export interface BotGitCreateRequest extends BotGitRepositoryRequest {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly startPoint: string;
|
|
32
|
+
}
|
|
33
|
+
export type BotGitErrorCode = 'invalid_workspace' | 'invalid_repository' | 'invalid_branch' | 'invalid_start_point' | 'branch_missing' | 'branch_exists' | 'branch_in_use' | 'worktree_conflict' | 'repository_busy' | 'external_filter' | 'outcome_unknown' | 'git_unavailable' | 'resource_unavailable';
|
|
34
|
+
export type BotGitResult<T> = ({
|
|
35
|
+
readonly ok: true;
|
|
36
|
+
} & T) | {
|
|
37
|
+
readonly ok: false;
|
|
38
|
+
readonly code: BotGitErrorCode;
|
|
39
|
+
};
|
|
40
|
+
export type BotGitOverview = BotGitResult<{
|
|
41
|
+
readonly mode: 'none' | 'single' | 'multi';
|
|
42
|
+
readonly repos: readonly BotGitRepository[];
|
|
43
|
+
}>;
|
|
44
|
+
export type BotGitBranches = BotGitResult<{
|
|
45
|
+
readonly current: string | null;
|
|
46
|
+
readonly defaultRef: string | null;
|
|
47
|
+
readonly localBranches: readonly string[];
|
|
48
|
+
readonly remoteBranches: readonly string[];
|
|
49
|
+
}>;
|
|
50
|
+
export type BotGitMutation = BotGitResult<{
|
|
51
|
+
readonly branch: string;
|
|
52
|
+
}>;
|
package/dist/bot-git.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -31,6 +31,7 @@ export interface ConversationExecution {
|
|
|
31
31
|
readonly metadata: Readonly<Record<string, unknown>>;
|
|
32
32
|
}[];
|
|
33
33
|
readonly usage: null | {
|
|
34
|
+
readonly requestBreakdown?: readonly import("./usage-accounting.js").RequestSpend[];
|
|
34
35
|
readonly usageScope: 'runtime_turn';
|
|
35
36
|
readonly providerRequestCount: number;
|
|
36
37
|
readonly inputTokens: number;
|
|
@@ -53,6 +54,7 @@ export interface ConversationExecution {
|
|
|
53
54
|
}
|
|
54
55
|
/** Strict decoding: unknown versions/fields are preserved by the caller and block
|
|
55
56
|
* execution. Return a clone so a parser consumer cannot change the stored fact. */
|
|
57
|
+
export declare function validConversationSpend(value: unknown): boolean;
|
|
56
58
|
export declare function normalizeConversationExecution(raw: unknown): ConversationExecution;
|
|
57
59
|
export declare function conversationExecutionPermitsNewRun(raw: unknown): boolean;
|
|
58
60
|
export {};
|
|
@@ -97,6 +97,35 @@ function validHookHandle(h, metadata, runIdentity, owner, pending) {
|
|
|
97
97
|
}
|
|
98
98
|
/** Strict decoding: unknown versions/fields are preserved by the caller and block
|
|
99
99
|
* execution. Return a clone so a parser consumer cannot change the stored fact. */
|
|
100
|
+
export function validConversationSpend(value) {
|
|
101
|
+
if (!Array.isArray(value) || value.length > 1000 || new TextEncoder().encode(JSON.stringify(value)).length > 128 * 1024)
|
|
102
|
+
return false;
|
|
103
|
+
const ids = new Set();
|
|
104
|
+
return value.every(row => {
|
|
105
|
+
if (!object(row) || !keys(row, ['id', 'at', 'groupId', 'model', 'modelVersion', 'rawPromptTokens', 'usage', 'estimatedCostUsd', 'pricingSource'])
|
|
106
|
+
|| typeof row.id !== 'string' || !text(row.id, 64) || ids.has(row.id)
|
|
107
|
+
|| !text(row.at, 64) || !text(row.groupId, 200) || !text(row.model, 512)
|
|
108
|
+
|| row.modelVersion !== undefined && !text(row.modelVersion, 128)
|
|
109
|
+
|| row.rawPromptTokens !== undefined && !safe(row.rawPromptTokens))
|
|
110
|
+
return false;
|
|
111
|
+
if (row.estimatedCostUsd === null) {
|
|
112
|
+
if (row.pricingSource !== undefined)
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
else if (typeof row.estimatedCostUsd !== 'string' || row.estimatedCostUsd.length > 64
|
|
116
|
+
|| !/^\d+(?:\.\d+)?$/.test(row.estimatedCostUsd)
|
|
117
|
+
|| !['manual', 'provider', 'gemini-official-reference', 'models.dev-reference'].some(s => s === row.pricingSource)
|
|
118
|
+
|| row.usage === null)
|
|
119
|
+
return false;
|
|
120
|
+
const usage = row.usage;
|
|
121
|
+
if (usage !== null && (!object(usage) || !keys(usage, [...amountKeys, 'totalTokens'])
|
|
122
|
+
|| !amountKeys.every(k => safe(usage[k])) || !safe(usage.totalTokens)
|
|
123
|
+
|| amountKeys.reduce((sum, k) => sum + usage[k], 0) !== usage.totalTokens))
|
|
124
|
+
return false;
|
|
125
|
+
ids.add(row.id);
|
|
126
|
+
return true;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
100
129
|
export function normalizeConversationExecution(raw) {
|
|
101
130
|
const invalid = () => { throw new Error('conversation_execution_invalid'); };
|
|
102
131
|
if (!object(raw) || !keys(raw, ['schemaVersion', 'identity', 'engine', 'owner', 'revision', 'phase', 'pendingTools',
|
|
@@ -117,7 +146,8 @@ export function normalizeConversationExecution(raw) {
|
|
|
117
146
|
return invalid();
|
|
118
147
|
if (raw.usage !== null) {
|
|
119
148
|
const u = raw.usage;
|
|
120
|
-
if (!object(u) || Object.keys(u).length !== 7 || !keys(u, ['usageScope', 'providerRequestCount', ...amountKeys, 'totalTokens'])
|
|
149
|
+
if (!object(u) || Object.keys(u).length !== 7 + Number(Object.hasOwn(u, 'requestBreakdown')) || !keys(u, ['usageScope', 'providerRequestCount', ...amountKeys, 'totalTokens', 'requestBreakdown'])
|
|
150
|
+
|| u.requestBreakdown !== undefined && !validConversationSpend(u.requestBreakdown)
|
|
121
151
|
|| u.usageScope !== 'runtime_turn' || !safe(u.providerRequestCount) || !safe(u.totalTokens)
|
|
122
152
|
|| !amountKeys.every(k => safe(u[k])) || amountKeys.reduce((n, k) => n + u[k], 0) !== u.totalTokens
|
|
123
153
|
|| u.totalTokens > 0 && u.providerRequestCount === 0)
|
package/dist/delegation.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Project-agent delegation contracts. Pure projections only; nothing here runs a tool.
|
|
3
3
|
* The user-visible conclusion of a work session is `decideLifecycle`'s conclusion.
|
|
4
4
|
*/
|
|
5
|
+
import type { GoalDeliveryBinding } from './goal.ts';
|
|
5
6
|
import type { ModelSelectionSnapshot } from './model-routing.ts';
|
|
6
7
|
import { type ExecutionOwnership, type GoalPlanProjectionSnapshot, type TaskOverviewItem } from './task-overview.ts';
|
|
7
8
|
export type WorkSessionStatus = 'paused' | 'queued' | 'starting' | 'running' | 'waiting_user' | 'waiting_agent' | 'stopping' | 'awaiting_outcome' | 'verifying' | 'result_ready' | 'accepted' | 'failed' | 'cancelled' | 'superseded';
|
|
@@ -83,7 +84,11 @@ export interface SessionQueueFacts {
|
|
|
83
84
|
}[];
|
|
84
85
|
readonly queueReason?: 'dependencies' | 'dependency_missing' | 'dependency_failed' | 'read_slot' | 'write_slot' | 'disk_space' | 'isolation_failed' | 'resource_protection' | 'resource_recovery' | null;
|
|
85
86
|
}
|
|
87
|
+
/** Persisted delivery facts displayed by the work session. Legacy records may have only a commit. */
|
|
88
|
+
export type WorkSessionDeliveryBinding = Partial<Pick<GoalDeliveryBinding, 'targetBranch' | 'baseCommit' | 'taskBranch' | 'executionIsolation' | 'worktreePath' | 'targetWorkspacePath'>>;
|
|
89
|
+
export declare function projectWorkSessionDeliveryBinding(value: unknown): WorkSessionDeliveryBinding | undefined;
|
|
86
90
|
export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
91
|
+
readonly deliveryBinding?: WorkSessionDeliveryBinding;
|
|
87
92
|
readonly coordination?: import('./delegation-coordination.ts').CoordinationSessionFacts;
|
|
88
93
|
readonly sessionId?: string;
|
|
89
94
|
readonly conversationId?: string;
|
|
@@ -104,6 +109,7 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
|
104
109
|
readonly obligationDisposition?: 'indexed' | 'suspended' | 'current';
|
|
105
110
|
}
|
|
106
111
|
export interface WorkSession extends SessionQueueFacts {
|
|
112
|
+
readonly deliveryBinding?: WorkSessionDeliveryBinding;
|
|
107
113
|
readonly followUpEpoch?: number;
|
|
108
114
|
readonly executionOwnership?: ExecutionOwnership;
|
|
109
115
|
readonly followUp?: import('./task-overview.ts').FollowUpProjection;
|
package/dist/delegation.js
CHANGED
|
@@ -6,6 +6,21 @@ import { controlPhasesForOrigin } from "./session-control.js";
|
|
|
6
6
|
import { decideLifecycle, } from "./task-overview.js";
|
|
7
7
|
export const WORK_SESSION_STATUSES = ['paused', 'queued', 'starting', 'running', 'waiting_user', 'waiting_agent', 'stopping', 'awaiting_outcome', 'verifying',
|
|
8
8
|
'result_ready', 'accepted', 'failed', 'cancelled', 'superseded'];
|
|
9
|
+
export function projectWorkSessionDeliveryBinding(value) {
|
|
10
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
11
|
+
return undefined;
|
|
12
|
+
const raw = value;
|
|
13
|
+
const facts = {};
|
|
14
|
+
for (const key of ['targetBranch', 'baseCommit', 'taskBranch', 'worktreePath', 'targetWorkspacePath']) {
|
|
15
|
+
const field = raw[key];
|
|
16
|
+
if (typeof field === 'string' && field.trim())
|
|
17
|
+
facts[key] = field;
|
|
18
|
+
}
|
|
19
|
+
const isolation = raw.executionIsolation;
|
|
20
|
+
if (isolation === 'worktree' || isolation === 'none')
|
|
21
|
+
facts.executionIsolation = isolation;
|
|
22
|
+
return Object.keys(facts).length ? facts : undefined;
|
|
23
|
+
}
|
|
9
24
|
function fnv1a(text) {
|
|
10
25
|
let hash = 0x811c9dc5;
|
|
11
26
|
for (let index = 0; index < text.length; index += 1) {
|
|
@@ -99,6 +114,7 @@ export function projectWorkSession(plan, conversationMeta) {
|
|
|
99
114
|
...(conversationMeta.endedAt ? { endedAt: conversationMeta.endedAt } : {}),
|
|
100
115
|
...(conversationMeta.conversationId ? { conversationId: conversationMeta.conversationId } : {}),
|
|
101
116
|
origin: conversationMeta.origin,
|
|
117
|
+
...(conversationMeta.deliveryBinding ? { deliveryBinding: conversationMeta.deliveryBinding } : {}),
|
|
102
118
|
...(conversationMeta.resourceBlocker ? { resourceBlocker: conversationMeta.resourceBlocker } : {}),
|
|
103
119
|
...(conversationMeta.executionClaimClosure ? { executionClaimClosure: conversationMeta.executionClaimClosure } : {}),
|
|
104
120
|
...(conversationMeta.unknownOutcomePolicy ? { unknownOutcomePolicy: conversationMeta.unknownOutcomePolicy } : {}),
|
|
@@ -43,7 +43,7 @@ export interface LocalDocumentObservation extends LocalDocumentIdentity {
|
|
|
43
43
|
export interface LocalDocumentReadResult {
|
|
44
44
|
readonly metadataOnly?: boolean;
|
|
45
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';
|
|
46
|
+
readonly status: 'ok' | 'not_found' | 'not_file' | 'too_large' | 'binary' | 'invalid_path' | 'error' | 'permission_denied' | 'sensitive_path' | '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
47
|
readonly content: string;
|
|
48
48
|
readonly size?: number;
|
|
49
49
|
readonly resolvedFrom?: string;
|
|
@@ -81,3 +81,31 @@ export interface BotResourceSearchResult {
|
|
|
81
81
|
readonly visited?: number;
|
|
82
82
|
readonly error?: string;
|
|
83
83
|
}
|
|
84
|
+
/** Renderer click context is a lookup hint. The Desktop host owns the authorization. */
|
|
85
|
+
export interface DocumentPreviewRequest {
|
|
86
|
+
readonly reference: BotDocumentReference;
|
|
87
|
+
readonly conversationId: string;
|
|
88
|
+
readonly messageId?: string;
|
|
89
|
+
readonly evidenceRef?: string;
|
|
90
|
+
readonly challenge?: string;
|
|
91
|
+
}
|
|
92
|
+
export type DocumentPreviewAccessResult = {
|
|
93
|
+
readonly ok: true;
|
|
94
|
+
readonly status: 'scoped';
|
|
95
|
+
} | {
|
|
96
|
+
readonly ok: true;
|
|
97
|
+
readonly status: 'allowed';
|
|
98
|
+
readonly token: string;
|
|
99
|
+
readonly path: string;
|
|
100
|
+
readonly source: 'external' | 'conversation' | 'worktree';
|
|
101
|
+
} | {
|
|
102
|
+
readonly ok: false;
|
|
103
|
+
readonly status: 'scope_denied';
|
|
104
|
+
readonly canRequestSingleFilePreview: true;
|
|
105
|
+
readonly path: string;
|
|
106
|
+
readonly challenge: string;
|
|
107
|
+
} | {
|
|
108
|
+
readonly ok: false;
|
|
109
|
+
readonly status: LocalDocumentReadResult['status'];
|
|
110
|
+
readonly canRequestSingleFilePreview?: never;
|
|
111
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"gemini-2.5-pro": {
|
|
3
|
+
"standard": {
|
|
4
|
+
"inputPrice": "1.25",
|
|
5
|
+
"outputPrice": "10",
|
|
6
|
+
"cacheReadPrice": "0.125"
|
|
7
|
+
},
|
|
8
|
+
"longContext": {
|
|
9
|
+
"inputPrice": "2.50",
|
|
10
|
+
"outputPrice": "15",
|
|
11
|
+
"cacheReadPrice": "0.25"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"gemini-2.5-flash": {
|
|
15
|
+
"standard": {
|
|
16
|
+
"inputPrice": "0.30",
|
|
17
|
+
"outputPrice": "2.50",
|
|
18
|
+
"cacheReadPrice": "0.03",
|
|
19
|
+
"audioInputPrice": "1.00",
|
|
20
|
+
"audioCacheReadPrice": "0.10"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"gemini-2.5-flash-lite": {
|
|
24
|
+
"standard": {
|
|
25
|
+
"inputPrice": "0.10",
|
|
26
|
+
"outputPrice": "0.40",
|
|
27
|
+
"cacheReadPrice": "0.01",
|
|
28
|
+
"audioInputPrice": "0.30",
|
|
29
|
+
"audioCacheReadPrice": "0.03"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"gemini-3-pro-preview": {
|
|
33
|
+
"standard": {
|
|
34
|
+
"inputPrice": "2",
|
|
35
|
+
"outputPrice": "12",
|
|
36
|
+
"cacheReadPrice": "0.20"
|
|
37
|
+
},
|
|
38
|
+
"longContext": {
|
|
39
|
+
"inputPrice": "4",
|
|
40
|
+
"outputPrice": "18",
|
|
41
|
+
"cacheReadPrice": "0.40"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"gemini-3.1-pro-preview": {
|
|
45
|
+
"standard": {
|
|
46
|
+
"inputPrice": "2",
|
|
47
|
+
"outputPrice": "12",
|
|
48
|
+
"cacheReadPrice": "0.20"
|
|
49
|
+
},
|
|
50
|
+
"longContext": {
|
|
51
|
+
"inputPrice": "4",
|
|
52
|
+
"outputPrice": "18",
|
|
53
|
+
"cacheReadPrice": "0.40"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"gemini-3.1-pro-preview-customtools": {
|
|
57
|
+
"standard": {
|
|
58
|
+
"inputPrice": "2",
|
|
59
|
+
"outputPrice": "12",
|
|
60
|
+
"cacheReadPrice": "0.20"
|
|
61
|
+
},
|
|
62
|
+
"longContext": {
|
|
63
|
+
"inputPrice": "4",
|
|
64
|
+
"outputPrice": "18",
|
|
65
|
+
"cacheReadPrice": "0.40"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"gemini-3-flash-preview": {
|
|
69
|
+
"standard": {
|
|
70
|
+
"inputPrice": "0.50",
|
|
71
|
+
"outputPrice": "3",
|
|
72
|
+
"cacheReadPrice": "0.05",
|
|
73
|
+
"audioInputPrice": "1",
|
|
74
|
+
"audioCacheReadPrice": "0.10"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"gemini-3.1-flash-lite": {
|
|
78
|
+
"standard": {
|
|
79
|
+
"inputPrice": "0.25",
|
|
80
|
+
"outputPrice": "1.50",
|
|
81
|
+
"cacheReadPrice": "0.025",
|
|
82
|
+
"audioInputPrice": "0.50",
|
|
83
|
+
"audioCacheReadPrice": "0.05"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"gemini-3.5-flash-lite": {
|
|
87
|
+
"standard": {
|
|
88
|
+
"inputPrice": "0.30",
|
|
89
|
+
"outputPrice": "2.50",
|
|
90
|
+
"cacheReadPrice": "0.03"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"gemini-3.8-flash": {
|
|
94
|
+
"standard": {
|
|
95
|
+
"inputPrice": "0.75",
|
|
96
|
+
"outputPrice": "3.75",
|
|
97
|
+
"cacheReadPrice": "0.075"
|
|
98
|
+
},
|
|
99
|
+
"afterNewYear": {
|
|
100
|
+
"inputPrice": "1.50",
|
|
101
|
+
"outputPrice": "7.50",
|
|
102
|
+
"cacheReadPrice": "0.15"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -367,7 +367,7 @@ export type LlmDiagnosticStageStatus = 'passed' | 'failed' | 'skipped' | 'pendin
|
|
|
367
367
|
* 面向用户的错误分类(诊断 / 聊天修复共用)。
|
|
368
368
|
* 技术错误码可进入 sanitizedDetail,不应直接作为主文案。
|
|
369
369
|
*/
|
|
370
|
-
export type LlmDiagnosticErrorCategory = 'credential_missing' | 'credential_invalid' | 'auth_expired' | 'endpoint_unreachable' | 'rate_limited' | 'quota_exhausted' | 'permission_denied' | 'model_not_found' | 'protocol_mismatch' | 'capability_mismatch' | 'local_runtime_stopped' | 'timeout' | 'unknown';
|
|
370
|
+
export type LlmDiagnosticErrorCategory = 'credential_missing' | 'credential_invalid' | 'auth_expired' | 'endpoint_unreachable' | 'gemini_rate_limited' | 'gemini_spend_or_quota_exhausted' | 'gemini_usage_limit_unknown' | 'rate_limited' | 'quota_exhausted' | 'permission_denied' | 'model_not_found' | 'protocol_mismatch' | 'capability_mismatch' | 'local_runtime_stopped' | 'timeout' | 'unknown';
|
|
371
371
|
export interface LlmDiagnosticStage {
|
|
372
372
|
readonly id: LlmDiagnosticStageId;
|
|
373
373
|
readonly status: LlmDiagnosticStageStatus;
|
|
@@ -466,7 +466,10 @@ export interface LlmSubscriptionQuotaWindow {
|
|
|
466
466
|
/**
|
|
467
467
|
* success=false 时用 status/error 表达未登录、过期或拉取失败,UI 应降级展示。
|
|
468
468
|
*/
|
|
469
|
+
export * from "./spend-budget.js";
|
|
470
|
+
export { default as geminiStandardPricing } from "./gemini-standard-pricing.json";
|
|
469
471
|
export interface LlmSubscriptionQuota {
|
|
472
|
+
readonly localBudget?: import("./spend-budget.js").ChannelLocalBudgetSnapshot;
|
|
470
473
|
readonly accountUsageRevision?: string;
|
|
471
474
|
/** Remote query outcome; localUsage can remain available on failure. */
|
|
472
475
|
readonly success: boolean;
|
|
@@ -504,7 +507,7 @@ export interface LlmProviderConfig {
|
|
|
504
507
|
readonly model: string;
|
|
505
508
|
readonly modelLabel?: string;
|
|
506
509
|
readonly metadataSource?: 'remote' | 'models.dev' | 'builtin' | 'local' | 'manual';
|
|
507
|
-
readonly pricingSource?: 'provider' | 'models.dev-reference';
|
|
510
|
+
readonly pricingSource?: 'manual' | 'provider' | 'models.dev-reference' | 'gemini-official-reference';
|
|
508
511
|
readonly metadataSyncedAt?: string;
|
|
509
512
|
readonly enabled: boolean;
|
|
510
513
|
readonly isDefault: boolean;
|
|
@@ -546,6 +549,7 @@ export interface LlmProviderConfig {
|
|
|
546
549
|
readonly lastErrorCategory?: LlmDiagnosticErrorCategory;
|
|
547
550
|
}
|
|
548
551
|
export interface LlmProviderConfigView extends LlmProviderConfig {
|
|
552
|
+
readonly spendBudget?: import("./spend-budget.js").ChannelSpendBudgetConfig;
|
|
549
553
|
/** Ephemeral main-owned identity for account observations; contains no credential material. */
|
|
550
554
|
readonly accountUsageRevision?: string;
|
|
551
555
|
readonly apiKeyMasked: string;
|
|
@@ -585,6 +589,7 @@ export interface LlmModelConfig {
|
|
|
585
589
|
readonly customHeadersInvalid?: boolean;
|
|
586
590
|
}
|
|
587
591
|
export interface LlmProviderGroupConfig {
|
|
592
|
+
readonly spendBudget?: import("./spend-budget.js").ChannelSpendBudgetConfig;
|
|
588
593
|
readonly id: string;
|
|
589
594
|
readonly provider: LlmProviderType;
|
|
590
595
|
readonly channelId?: LlmChannelId;
|
|
@@ -632,7 +637,7 @@ export interface LlmModelInfo {
|
|
|
632
637
|
readonly supportsReasoning?: boolean;
|
|
633
638
|
readonly reasoningEffortValues?: readonly string[];
|
|
634
639
|
readonly metadataSource?: 'provider' | 'models.dev';
|
|
635
|
-
readonly pricingSource?: 'provider' | 'models.dev-reference';
|
|
640
|
+
readonly pricingSource?: 'manual' | 'provider' | 'models.dev-reference' | 'gemini-official-reference';
|
|
636
641
|
readonly inputPrice?: number;
|
|
637
642
|
readonly outputPrice?: number;
|
|
638
643
|
readonly cacheReadPrice?: number;
|
|
@@ -902,6 +907,7 @@ export * from './automation.ts';
|
|
|
902
907
|
export * from './task-overview.ts';
|
|
903
908
|
export * from './skill-marketplace.ts';
|
|
904
909
|
export * from './delegation.ts';
|
|
910
|
+
export * from './bot-git.ts';
|
|
905
911
|
export * from './model-routing.ts';
|
|
906
912
|
export * from './document-reference.ts';
|
|
907
913
|
export * from './project.ts';
|
|
@@ -933,7 +939,9 @@ export { controlPhasesForOrigin, normalizeSessionExecutionIdentity, normalizeExe
|
|
|
933
939
|
export * from './input-prediction.ts';
|
|
934
940
|
export * from './interactive-result.ts';
|
|
935
941
|
export * from './interactive-verification.ts';
|
|
936
|
-
export { normalizeConversationExecution, conversationExecutionPermitsNewRun } from './conversation-execution.ts';
|
|
942
|
+
export { normalizeConversationExecution, conversationExecutionPermitsNewRun, validConversationSpend } from './conversation-execution.ts';
|
|
937
943
|
export type { ConversationExecutionIdentity, ConversationExecution } from './conversation-execution.ts';
|
|
938
944
|
export * from './quiet-reply.js';
|
|
939
945
|
export type { WorkingPlanStepStatus, WorkingPlanStepView, WorkingPlanView } from './working-plan.ts';
|
|
946
|
+
export * from "./parent-coordination.js";
|
|
947
|
+
export * from "./project-matter.ts";
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,11 @@ export { evaluateUiDelivery } from "./ui-delivery-verification.js";
|
|
|
9
9
|
export { DESKTOP_PREVIEW_PROTOCOL, DESKTOP_PREVIEW_CAPABILITY, DESKTOP_PREVIEW_TOOL } from "./desktop-preview.js";
|
|
10
10
|
export { REMOTE_PROTOCOL_VERSION, parseRemoteReadRequest, admitRemoteRead } from "./remote-access.js";
|
|
11
11
|
export { REMOTE_PROJECT_LIMITS, parseRemoteProjectRequest, admitRemoteProject, parseRemoteDelegationProjection } from "./remote-access.js";
|
|
12
|
+
/**
|
|
13
|
+
* success=false 时用 status/error 表达未登录、过期或拉取失败,UI 应降级展示。
|
|
14
|
+
*/
|
|
15
|
+
export * from "./spend-budget.js";
|
|
16
|
+
export { default as geminiStandardPricing } from "./gemini-standard-pricing.json" with { type: "json" };
|
|
12
17
|
export function resolveLlmModelOptionValues(definitions, values) {
|
|
13
18
|
if (!definitions?.length)
|
|
14
19
|
return {};
|
|
@@ -39,6 +44,7 @@ export * from "./automation.js";
|
|
|
39
44
|
export * from "./task-overview.js";
|
|
40
45
|
export * from "./skill-marketplace.js";
|
|
41
46
|
export * from "./delegation.js";
|
|
47
|
+
export * from "./bot-git.js";
|
|
42
48
|
export * from "./model-routing.js";
|
|
43
49
|
export * from "./document-reference.js";
|
|
44
50
|
export * from "./project.js";
|
|
@@ -65,5 +71,7 @@ export { controlPhasesForOrigin, normalizeSessionExecutionIdentity, normalizeExe
|
|
|
65
71
|
export * from "./input-prediction.js";
|
|
66
72
|
export * from "./interactive-result.js";
|
|
67
73
|
export * from "./interactive-verification.js";
|
|
68
|
-
export { normalizeConversationExecution, conversationExecutionPermitsNewRun } from "./conversation-execution.js";
|
|
74
|
+
export { normalizeConversationExecution, conversationExecutionPermitsNewRun, validConversationSpend } from "./conversation-execution.js";
|
|
69
75
|
export * from './quiet-reply.js';
|
|
76
|
+
export * from "./parent-coordination.js";
|
|
77
|
+
export * from "./project-matter.js";
|
package/dist/memory.d.ts
CHANGED
|
@@ -4,7 +4,43 @@
|
|
|
4
4
|
import type { MessageDisposition } from './delegation.ts';
|
|
5
5
|
export type MemoryKind = 'fact' | 'preference' | 'decision' | 'procedure' | 'responsibility';
|
|
6
6
|
export type MemoryTrust = 'verified' | 'stated' | 'inferred';
|
|
7
|
-
export type MemoryStatus = 'active' | '
|
|
7
|
+
export type MemoryStatus = 'active' | 'needs_reverify' | 'conflicted' | 'quarantined' | 'archived';
|
|
8
|
+
export type LegacyMemoryStatus = Extract<MemoryStatus, 'active' | 'conflicted'> | 'forgotten' | 'expired';
|
|
9
|
+
export type MemoryScopeKey = 'global' | `project:${string}`;
|
|
10
|
+
export type MemoryRevision = string;
|
|
11
|
+
export declare function isMemoryScopeKey(value: unknown): value is MemoryScopeKey;
|
|
12
|
+
export declare function isMemoryRevision(value: unknown): value is MemoryRevision;
|
|
13
|
+
export interface MemoryRef {
|
|
14
|
+
readonly scopeKey: MemoryScopeKey;
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly revision: MemoryRevision;
|
|
17
|
+
}
|
|
18
|
+
export type MemorySourceKind = 'user_message_span' | 'local_user_edit' | 'independent_verification' | 'workspace_file' | 'web' | 'attachment' | 'mcp' | 'model' | 'unknown';
|
|
19
|
+
export interface MemoryProvenance {
|
|
20
|
+
readonly sourceKind: MemorySourceKind;
|
|
21
|
+
readonly sources: readonly string[];
|
|
22
|
+
readonly taintSet: readonly MemorySourceKind[];
|
|
23
|
+
readonly refs: readonly MemoryRef[];
|
|
24
|
+
}
|
|
25
|
+
export type MemoryErrorCode = 'parse_warning' | 'quarantined' | 'revision_conflict' | 'commit_unknown' | 'memory_governance_unavailable' | 'invalid_scope' | 'path_escape' | 'duplicate_id' | 'memory_disabled' | 'invalid_id' | 'invalid_revision' | 'needs_reverify' | 'not_eligible' | 'missing_id' | 'not_found' | 'cancelled' | 'revoked' | 'purged' | 'storage_unavailable';
|
|
26
|
+
export type MemoryMutationStatus = 'prepared' | 'committed' | 'conflict' | 'blocked';
|
|
27
|
+
export interface MemoryMutationReceipt {
|
|
28
|
+
readonly mutationId: string;
|
|
29
|
+
readonly scopeKey: MemoryScopeKey;
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly revision?: MemoryRevision;
|
|
32
|
+
readonly previousRevision?: MemoryRevision;
|
|
33
|
+
readonly status: MemoryMutationStatus;
|
|
34
|
+
readonly code?: MemoryErrorCode;
|
|
35
|
+
readonly reason?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface MemoryHealth {
|
|
38
|
+
readonly scopeKey: MemoryScopeKey;
|
|
39
|
+
readonly code: MemoryErrorCode;
|
|
40
|
+
readonly line?: number;
|
|
41
|
+
readonly column?: number;
|
|
42
|
+
readonly reason?: string;
|
|
43
|
+
}
|
|
8
44
|
export interface MemoryValidityFields {
|
|
9
45
|
readonly expiresAt?: string;
|
|
10
46
|
readonly topicKey?: string;
|
|
@@ -28,7 +64,7 @@ export interface MemoryItem extends MemoryValidityFields {
|
|
|
28
64
|
readonly trust: MemoryTrust;
|
|
29
65
|
readonly sourceRefs: readonly string[];
|
|
30
66
|
readonly pinned: boolean;
|
|
31
|
-
readonly status:
|
|
67
|
+
readonly status: LegacyMemoryStatus;
|
|
32
68
|
readonly confirmedCount: number;
|
|
33
69
|
readonly createdAt: string;
|
|
34
70
|
readonly lastUsedAt?: string;
|
|
@@ -60,7 +96,7 @@ export interface ProjectMemoryRecord extends MemoryValidityFields {
|
|
|
60
96
|
readonly trust: MemoryTrust;
|
|
61
97
|
readonly sourceRefs: readonly string[];
|
|
62
98
|
readonly pinned: boolean;
|
|
63
|
-
readonly status:
|
|
99
|
+
readonly status: LegacyMemoryStatus;
|
|
64
100
|
readonly confirmedCount: number;
|
|
65
101
|
readonly createdAt: string;
|
|
66
102
|
readonly updatedAt: string;
|
|
@@ -68,23 +104,42 @@ export interface ProjectMemoryRecord extends MemoryValidityFields {
|
|
|
68
104
|
readonly anchorMessageId?: string;
|
|
69
105
|
readonly forgetReason?: string;
|
|
70
106
|
}
|
|
71
|
-
export interface
|
|
72
|
-
readonly
|
|
107
|
+
export interface EffectiveMemoryPolicy {
|
|
108
|
+
readonly workspaceId: string;
|
|
109
|
+
readonly settingsRevision: string;
|
|
110
|
+
readonly profileRevision: string;
|
|
111
|
+
readonly policyEpoch: number;
|
|
112
|
+
readonly globalEnabled: boolean | null;
|
|
113
|
+
readonly projectEnabled: boolean | null;
|
|
114
|
+
readonly rawAutoCurate: boolean | null;
|
|
115
|
+
readonly rawLearnPreferences: boolean | null;
|
|
73
116
|
readonly useMemory: boolean;
|
|
117
|
+
readonly collectEpisodes: boolean;
|
|
118
|
+
readonly autoCurate: boolean;
|
|
74
119
|
readonly learnPreferences: boolean;
|
|
120
|
+
readonly reasonCodes: readonly string[];
|
|
121
|
+
readonly rootStatus: {
|
|
122
|
+
readonly status: string;
|
|
123
|
+
readonly readOnly: boolean;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export interface ProjectMemoryPolicyResult {
|
|
127
|
+
readonly ok: boolean;
|
|
128
|
+
readonly code?: string;
|
|
129
|
+
readonly policy?: EffectiveMemoryPolicy;
|
|
75
130
|
}
|
|
76
131
|
export interface ProjectMemoryListRequest {
|
|
77
132
|
readonly workspaceId: string;
|
|
78
133
|
readonly kind?: MemoryKind;
|
|
79
134
|
readonly trust?: MemoryTrust;
|
|
80
|
-
readonly status?:
|
|
135
|
+
readonly status?: LegacyMemoryStatus;
|
|
81
136
|
readonly ids?: readonly string[];
|
|
82
137
|
}
|
|
83
138
|
export interface ProjectMemoryListResult {
|
|
84
139
|
readonly ok: boolean;
|
|
85
140
|
readonly code?: string;
|
|
86
141
|
readonly items?: readonly ProjectMemoryRecord[];
|
|
87
|
-
readonly
|
|
142
|
+
readonly policy?: EffectiveMemoryPolicy;
|
|
88
143
|
}
|
|
89
144
|
export interface ProjectMemoryPinRequest {
|
|
90
145
|
readonly workspaceId: string;
|
|
@@ -124,14 +179,19 @@ export interface ProjectMemoryExportResult {
|
|
|
124
179
|
}
|
|
125
180
|
export interface ProjectMemorySetSwitchesRequest {
|
|
126
181
|
readonly workspaceId: string;
|
|
127
|
-
readonly
|
|
128
|
-
readonly
|
|
129
|
-
readonly learnPreferences?: boolean;
|
|
182
|
+
readonly patch: Partial<Record<'globalEnabled' | 'projectEnabled' | 'autoCurate' | 'learnPreferences', boolean>>;
|
|
183
|
+
readonly expected: Pick<EffectiveMemoryPolicy, 'settingsRevision' | 'profileRevision'>;
|
|
130
184
|
}
|
|
185
|
+
export type MemoryPolicyCommitStatus = 'unchanged' | 'applied' | 'conflict' | 'invalid' | 'failed' | 'unconfirmed';
|
|
131
186
|
export interface ProjectMemorySetSwitchesResult {
|
|
132
187
|
readonly ok: boolean;
|
|
133
188
|
readonly code?: string;
|
|
134
|
-
readonly
|
|
189
|
+
readonly settingsRevision?: string;
|
|
190
|
+
readonly profileRevision?: string;
|
|
191
|
+
readonly policyEpoch?: number;
|
|
192
|
+
readonly settingsCommit?: MemoryPolicyCommitStatus;
|
|
193
|
+
readonly profileCommit?: MemoryPolicyCommitStatus;
|
|
194
|
+
readonly effective?: EffectiveMemoryPolicy;
|
|
135
195
|
}
|
|
136
196
|
export type MemoryAdmission = {
|
|
137
197
|
readonly ok: true;
|
package/dist/memory.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project memory contracts. Entries are facts for continuity, not instructions.
|
|
3
3
|
*/
|
|
4
|
+
export function isMemoryScopeKey(value) {
|
|
5
|
+
if (value === 'global')
|
|
6
|
+
return true;
|
|
7
|
+
if (typeof value !== 'string' || !value.startsWith('project:'))
|
|
8
|
+
return false;
|
|
9
|
+
const workspace = value.slice('project:'.length);
|
|
10
|
+
return /^[a-z0-9][a-z0-9_.-]{0,127}$(?![\s\S])/i.test(workspace) && !workspace.endsWith('.') &&
|
|
11
|
+
!/^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(workspace);
|
|
12
|
+
}
|
|
13
|
+
export function isMemoryRevision(value) {
|
|
14
|
+
return typeof value === 'string' && /^[a-f0-9]{64}$(?![\s\S])/.test(value);
|
|
15
|
+
}
|
|
4
16
|
const SECRET = /sk-[A-Za-z0-9]{8,}|api[_-]?key\s*[:=]|bearer\s+[A-Za-z0-9._\-]{8,}/i;
|
|
5
17
|
const LOOSENING = /不用确认|跳过批准|跳过审批|always allow|skip approval|full_local|不用我批/i;
|
|
6
18
|
const STANDING_ORDER = /以后都|下次都|always do this/i;
|
|
@@ -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,223 @@
|
|
|
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
|
+
briefRevision?: number | null;
|
|
87
|
+
};
|
|
88
|
+
export type MatterActivity = {
|
|
89
|
+
activityId: string;
|
|
90
|
+
seq: number;
|
|
91
|
+
kind: string;
|
|
92
|
+
actorKind: string;
|
|
93
|
+
body: string;
|
|
94
|
+
payload: Record<string, unknown>;
|
|
95
|
+
createdAt: string;
|
|
96
|
+
};
|
|
97
|
+
export type MatterChanged = {
|
|
98
|
+
workspaceId: string;
|
|
99
|
+
matterId: string;
|
|
100
|
+
revision: number;
|
|
101
|
+
};
|
|
102
|
+
export type MatterListPage = {
|
|
103
|
+
limit?: number;
|
|
104
|
+
deliveredLimit?: number;
|
|
105
|
+
} & Partial<Record<`${MatterGroup}Cursor`, string>>;
|
|
106
|
+
export type MatterDetailPage = {
|
|
107
|
+
afterSeq?: number;
|
|
108
|
+
activityLimit?: number;
|
|
109
|
+
runOffset?: number;
|
|
110
|
+
runLimit?: number;
|
|
111
|
+
};
|
|
112
|
+
type Scope = {
|
|
113
|
+
workspaceId: string;
|
|
114
|
+
version?: 1;
|
|
115
|
+
};
|
|
116
|
+
type Write = Scope & {
|
|
117
|
+
operationId: string;
|
|
118
|
+
};
|
|
119
|
+
type Target = {
|
|
120
|
+
matterId: string;
|
|
121
|
+
};
|
|
122
|
+
type CAS = {
|
|
123
|
+
revision: number;
|
|
124
|
+
briefRevision?: number;
|
|
125
|
+
};
|
|
126
|
+
type Answer = {
|
|
127
|
+
requestId: string;
|
|
128
|
+
} & ({
|
|
129
|
+
optionId: string;
|
|
130
|
+
text?: never;
|
|
131
|
+
} | {
|
|
132
|
+
text: string;
|
|
133
|
+
optionId?: never;
|
|
134
|
+
});
|
|
135
|
+
type Patch = {
|
|
136
|
+
brief?: MatterBrief;
|
|
137
|
+
status?: MatterStatus;
|
|
138
|
+
waiting?: {
|
|
139
|
+
reason: string;
|
|
140
|
+
source: MatterSource & {
|
|
141
|
+
ref: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
decision?: MatterDecisionDraft;
|
|
145
|
+
userReceiptRef?: string;
|
|
146
|
+
delivery?: {
|
|
147
|
+
summary: string;
|
|
148
|
+
sessionId?: string;
|
|
149
|
+
followUpEpoch?: number;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export type MatterList = Record<MatterGroup, readonly MatterSummary[]> & Record<`${MatterGroup}Cursor`, string | null> & {
|
|
153
|
+
activeCount: number;
|
|
154
|
+
cancelledCount: number;
|
|
155
|
+
};
|
|
156
|
+
export type MatterDetail = {
|
|
157
|
+
matter: Matter;
|
|
158
|
+
activities: readonly MatterActivity[];
|
|
159
|
+
runs: readonly MatterRun[];
|
|
160
|
+
nextActivitySeq: number | null;
|
|
161
|
+
nextRunOffset: number | null;
|
|
162
|
+
};
|
|
163
|
+
type Receipt = Target & CAS & {
|
|
164
|
+
number: number;
|
|
165
|
+
status: MatterStatus;
|
|
166
|
+
seq?: number;
|
|
167
|
+
activityId?: string;
|
|
168
|
+
};
|
|
169
|
+
interface MatterRequests {
|
|
170
|
+
list: Scope & {
|
|
171
|
+
page?: MatterListPage;
|
|
172
|
+
};
|
|
173
|
+
get: Scope & Target & {
|
|
174
|
+
page?: MatterDetailPage;
|
|
175
|
+
};
|
|
176
|
+
create: Write & {
|
|
177
|
+
brief: MatterBrief;
|
|
178
|
+
};
|
|
179
|
+
update: Write & Target & CAS & {
|
|
180
|
+
patch: Patch;
|
|
181
|
+
};
|
|
182
|
+
comment: Write & Target & {
|
|
183
|
+
body: string;
|
|
184
|
+
};
|
|
185
|
+
answer_decision: Write & Target & CAS & {
|
|
186
|
+
answer: Answer;
|
|
187
|
+
};
|
|
188
|
+
reopen: Write & Target & CAS & {
|
|
189
|
+
reason: string;
|
|
190
|
+
};
|
|
191
|
+
cancel: Write & Target & CAS & {
|
|
192
|
+
reason: string;
|
|
193
|
+
};
|
|
194
|
+
claim_session: Write & {
|
|
195
|
+
claim: {
|
|
196
|
+
sessionId: string;
|
|
197
|
+
} & ({
|
|
198
|
+
brief: MatterBrief;
|
|
199
|
+
} | (Target & Pick<CAS, 'revision'>));
|
|
200
|
+
};
|
|
201
|
+
export_markdown: Scope & Target;
|
|
202
|
+
}
|
|
203
|
+
type ReadResults = {
|
|
204
|
+
list: MatterList;
|
|
205
|
+
get: MatterDetail;
|
|
206
|
+
export_markdown: Target & {
|
|
207
|
+
markdown: string;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
type MatterFailure = {
|
|
211
|
+
ok: false;
|
|
212
|
+
code: string;
|
|
213
|
+
revision?: number;
|
|
214
|
+
briefRevision?: number;
|
|
215
|
+
};
|
|
216
|
+
export type MatterResult<K extends keyof MatterRequests> = MatterFailure | ({
|
|
217
|
+
ok: true;
|
|
218
|
+
version: 1;
|
|
219
|
+
} & (K extends keyof ReadResults ? ReadResults[K] : Receipt));
|
|
220
|
+
export type ProjectMatterRpc = <K extends keyof MatterRequests>(request: MatterRequests[K] & {
|
|
221
|
+
method: K;
|
|
222
|
+
}) => Promise<MatterResult<K>>;
|
|
223
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type ChannelSpendAnchorSource = 'ai_studio_browser' | 'manual';
|
|
2
|
+
export interface ChannelSpendAnchor {
|
|
3
|
+
readonly periodKey: string;
|
|
4
|
+
readonly amountUsd: string;
|
|
5
|
+
readonly monthlyLimitUsd?: string;
|
|
6
|
+
readonly capturedAtUtc: string;
|
|
7
|
+
readonly source: ChannelSpendAnchorSource;
|
|
8
|
+
readonly projectLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ChannelSpendBudgetConfig {
|
|
11
|
+
readonly enabled?: boolean;
|
|
12
|
+
readonly monthlyLimitUsd?: string;
|
|
13
|
+
readonly resetTimezone?: string;
|
|
14
|
+
readonly warnThresholds?: readonly [number, number];
|
|
15
|
+
readonly policy?: 'warn_only';
|
|
16
|
+
readonly sharedProjectKey?: string;
|
|
17
|
+
readonly anchor?: ChannelSpendAnchor;
|
|
18
|
+
}
|
|
19
|
+
export interface ChannelLocalBudgetSnapshot {
|
|
20
|
+
readonly groupId: string;
|
|
21
|
+
readonly periodKey: string;
|
|
22
|
+
readonly resetTimezone: string;
|
|
23
|
+
readonly windowStartUtc: string;
|
|
24
|
+
readonly windowEndUtc: string;
|
|
25
|
+
readonly nextResetAtUtc: string;
|
|
26
|
+
readonly effectiveLimitUsd: string | null;
|
|
27
|
+
readonly limitSource: 'configured' | 'anchor' | 'none';
|
|
28
|
+
readonly estimatedSpendUsd: string | null;
|
|
29
|
+
readonly localDeltaSpendUsd: string | null;
|
|
30
|
+
readonly anchor: ChannelSpendAnchor | null;
|
|
31
|
+
readonly anchorActive: boolean;
|
|
32
|
+
readonly anchorExpired: boolean;
|
|
33
|
+
readonly sourceKind: 'local_estimate' | 'anchor_plus_local' | 'manual_anchor_plus_local';
|
|
34
|
+
readonly scopeLabel: 'channel_group' | 'shared_project';
|
|
35
|
+
readonly coverage: 'complete' | 'partial' | 'none';
|
|
36
|
+
readonly unpricedRequestCount: number;
|
|
37
|
+
readonly truncated: boolean;
|
|
38
|
+
readonly percentUsed: number | null;
|
|
39
|
+
readonly alertLevel: 'normal' | 'warning' | 'critical' | 'exceeded';
|
|
40
|
+
readonly pricingNote: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface ChannelBudgetView {
|
|
43
|
+
readonly revision: string;
|
|
44
|
+
readonly config: ChannelSpendBudgetConfig | null;
|
|
45
|
+
readonly periodKey: string;
|
|
46
|
+
readonly localBudget: ChannelLocalBudgetSnapshot | null;
|
|
47
|
+
}
|
|
48
|
+
export interface ChannelBudgetUpdate {
|
|
49
|
+
readonly groupId: string;
|
|
50
|
+
readonly revision: string;
|
|
51
|
+
readonly config: ChannelSpendBudgetConfig;
|
|
52
|
+
}
|
|
53
|
+
export type BillingSyncResult<T = object> = ({
|
|
54
|
+
readonly ok: true;
|
|
55
|
+
} & T) | {
|
|
56
|
+
readonly ok: false;
|
|
57
|
+
readonly reason: string;
|
|
58
|
+
};
|
|
59
|
+
export interface BillingSyncPreview {
|
|
60
|
+
readonly previewId: string;
|
|
61
|
+
readonly anchor: ChannelSpendAnchor;
|
|
62
|
+
}
|
|
63
|
+
export interface BillingSyncConfirm {
|
|
64
|
+
readonly syncId: string;
|
|
65
|
+
readonly previewId: string;
|
|
66
|
+
readonly amountUsd: string;
|
|
67
|
+
readonly monthlyLimitUsd?: string;
|
|
68
|
+
readonly projectLabel?: string;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/system-context.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface ChatStreamFailure {
|
|
|
4
4
|
readonly code: string;
|
|
5
5
|
readonly causeCode?: string;
|
|
6
6
|
readonly precedingCode?: string;
|
|
7
|
+
readonly retryAfterMs?: number;
|
|
7
8
|
}
|
|
8
9
|
export type AttachmentContextTransport = 'provider_image_part' | 'user_text_part' | 'metadata_only' | string;
|
|
9
10
|
/**
|
|
@@ -18,10 +18,22 @@ export interface ProviderRequestUsage extends UsageAmounts {
|
|
|
18
18
|
readonly requestPurpose: 'agent' | 'compaction_summary' | 'input_prediction';
|
|
19
19
|
readonly requestFingerprint?: string;
|
|
20
20
|
}
|
|
21
|
+
export interface RequestSpend {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly at: string;
|
|
24
|
+
readonly groupId: string;
|
|
25
|
+
readonly model: string;
|
|
26
|
+
readonly modelVersion?: string;
|
|
27
|
+
readonly rawPromptTokens?: number;
|
|
28
|
+
readonly usage: UsageAmounts | null;
|
|
29
|
+
readonly estimatedCostUsd: string | null;
|
|
30
|
+
readonly pricingSource?: 'manual' | 'provider' | 'gemini-official-reference' | 'models.dev-reference';
|
|
31
|
+
}
|
|
21
32
|
/** Billable sum of every provider request executed by one user/runtime turn. */
|
|
22
33
|
export interface RuntimeTurnUsage extends UsageAmounts {
|
|
23
34
|
readonly usageScope: 'runtime_turn';
|
|
24
35
|
readonly providerRequestCount: number;
|
|
36
|
+
readonly requestBreakdown?: readonly RequestSpend[];
|
|
25
37
|
}
|
|
26
38
|
/** ADR131 canonical billing snapshot. It never seeds context or proves execution. */
|
|
27
39
|
export interface NativeRuntimeUsageSnapshot {
|