@peer-agent/protocol 0.1.0-rc.45 → 0.1.0-rc.47
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 +10 -0
- package/dist/delegation.js +18 -0
- package/dist/gemini-standard-pricing.json +105 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.js +8 -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-input-recovery.d.ts +10 -0
- package/dist/project-input-recovery.js +20 -0
- package/dist/project.d.ts +2 -0
- package/dist/skill-marketplace.d.ts +39 -4
- 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/dist/working-plan.d.ts +18 -0
- package/dist/working-plan.js +1 -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,12 +84,18 @@ 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;
|
|
90
95
|
readonly workspaceId: string;
|
|
91
96
|
readonly spawnedAt?: string;
|
|
97
|
+
readonly startedAt?: string;
|
|
98
|
+
readonly endedAt?: string;
|
|
92
99
|
readonly origin: DelegationOrigin;
|
|
93
100
|
readonly supersededBy?: string;
|
|
94
101
|
readonly acceptance?: 'auto' | 'confirm';
|
|
@@ -102,6 +109,7 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
|
102
109
|
readonly obligationDisposition?: 'indexed' | 'suspended' | 'current';
|
|
103
110
|
}
|
|
104
111
|
export interface WorkSession extends SessionQueueFacts {
|
|
112
|
+
readonly deliveryBinding?: WorkSessionDeliveryBinding;
|
|
105
113
|
readonly followUpEpoch?: number;
|
|
106
114
|
readonly executionOwnership?: ExecutionOwnership;
|
|
107
115
|
readonly followUp?: import('./task-overview.ts').FollowUpProjection;
|
|
@@ -121,6 +129,8 @@ export interface WorkSession extends SessionQueueFacts {
|
|
|
121
129
|
readonly cancelable?: boolean;
|
|
122
130
|
readonly needsYouReason?: TaskOverviewItem['needsYouReason'];
|
|
123
131
|
readonly spawnedAt: string;
|
|
132
|
+
readonly startedAt?: string;
|
|
133
|
+
readonly endedAt?: string;
|
|
124
134
|
readonly conversationId?: string;
|
|
125
135
|
readonly origin: DelegationOrigin;
|
|
126
136
|
readonly supersededBy?: string;
|
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) {
|
|
@@ -95,8 +110,11 @@ export function projectWorkSession(plan, conversationMeta) {
|
|
|
95
110
|
...(projected.needsYouReason ? { needsYouReason: projected.needsYouReason } : {}),
|
|
96
111
|
...(conversationMeta.coordination ? { coordination: conversationMeta.coordination } : {}),
|
|
97
112
|
spawnedAt: conversationMeta.spawnedAt ?? plan.updatedAt ?? '',
|
|
113
|
+
...(conversationMeta.startedAt ? { startedAt: conversationMeta.startedAt } : {}),
|
|
114
|
+
...(conversationMeta.endedAt ? { endedAt: conversationMeta.endedAt } : {}),
|
|
98
115
|
...(conversationMeta.conversationId ? { conversationId: conversationMeta.conversationId } : {}),
|
|
99
116
|
origin: conversationMeta.origin,
|
|
117
|
+
...(conversationMeta.deliveryBinding ? { deliveryBinding: conversationMeta.deliveryBinding } : {}),
|
|
100
118
|
...(conversationMeta.resourceBlocker ? { resourceBlocker: conversationMeta.resourceBlocker } : {}),
|
|
101
119
|
...(conversationMeta.executionClaimClosure ? { executionClaimClosure: conversationMeta.executionClaimClosure } : {}),
|
|
102
120
|
...(conversationMeta.unknownOutcomePolicy ? { unknownOutcomePolicy: conversationMeta.unknownOutcomePolicy } : {}),
|
|
@@ -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,6 +939,8 @@ 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';
|
|
945
|
+
export type { WorkingPlanStepStatus, WorkingPlanStepView, WorkingPlanView } from './working-plan.ts';
|
|
946
|
+
export * from "./parent-coordination.js";
|
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,6 @@ 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";
|
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
|
+
}
|
|
@@ -68,6 +68,16 @@ export interface ProjectInputRecoveryPort {
|
|
|
68
68
|
write(request: ProjectInputDraftWriteRequest): Promise<ProjectInputDraftWriteResult>;
|
|
69
69
|
submit(request: UnconfirmedProjectInput & ProjectInputDraftReadRequest): Promise<ProjectAgentSubmitInputResult>;
|
|
70
70
|
}
|
|
71
|
+
export type ProjectInputMutationResult = {
|
|
72
|
+
readonly ok: true;
|
|
73
|
+
} | {
|
|
74
|
+
readonly ok: false;
|
|
75
|
+
readonly code: string;
|
|
76
|
+
};
|
|
77
|
+
export declare const DEFINITE_PROJECT_INPUT_REJECTION_CODES: ReadonlySet<string>;
|
|
71
78
|
export declare function emptyInputDraft(): InputDraftValue;
|
|
72
79
|
/** A handoff failure may follow a durable receipt. Generic ok alone proves nothing. */
|
|
73
80
|
export declare function projectInputWasReceived(result: ProjectAgentSubmitInputResult | null | undefined, workspaceId: string, inputId: string): boolean;
|
|
81
|
+
export declare function isDefiniteProjectInputRejectionCode(code: string | null | undefined): boolean;
|
|
82
|
+
/** True only when the host rejected the input before enqueuing it (no durable receipt). */
|
|
83
|
+
export declare function isDefiniteProjectInputRejection(result: ProjectAgentSubmitInputResult | null | undefined, workspaceId: string, inputId: string): boolean;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
+
export const DEFINITE_PROJECT_INPUT_REJECTION_CODES = new Set([
|
|
2
|
+
'QUESTION_CLOSED',
|
|
3
|
+
'INVALID_INPUT',
|
|
4
|
+
'INVALID_INPUT_ID',
|
|
5
|
+
'INVALID_RESOURCE_FEEDBACK',
|
|
6
|
+
'RESOURCE_FEEDBACK_RECIPIENT_CHANGED',
|
|
7
|
+
'RESOURCE_FEEDBACK_ATTACHMENT_LIMIT',
|
|
8
|
+
'INTERACTIVE_FEEDBACK_UNAVAILABLE',
|
|
9
|
+
'NOT_FOUND',
|
|
10
|
+
'WORKSPACE_NOT_FOUND',
|
|
11
|
+
]);
|
|
1
12
|
export function emptyInputDraft() { return { text: '', quote: null, attachments: [] }; }
|
|
2
13
|
/** A handoff failure may follow a durable receipt. Generic ok alone proves nothing. */
|
|
3
14
|
export function projectInputWasReceived(result, workspaceId, inputId) {
|
|
4
15
|
return result?.input?.workspaceId === workspaceId && result.input.inputId === inputId;
|
|
5
16
|
}
|
|
17
|
+
export function isDefiniteProjectInputRejectionCode(code) {
|
|
18
|
+
return typeof code === 'string' && DEFINITE_PROJECT_INPUT_REJECTION_CODES.has(code);
|
|
19
|
+
}
|
|
20
|
+
/** True only when the host rejected the input before enqueuing it (no durable receipt). */
|
|
21
|
+
export function isDefiniteProjectInputRejection(result, workspaceId, inputId) {
|
|
22
|
+
if (!result || result.ok || projectInputWasReceived(result, workspaceId, inputId))
|
|
23
|
+
return false;
|
|
24
|
+
return isDefiniteProjectInputRejectionCode(result.code);
|
|
25
|
+
}
|
package/dist/project.d.ts
CHANGED
|
@@ -302,6 +302,8 @@ export type ProjectAgentStopResponseResult = {
|
|
|
302
302
|
readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_OFFLINE' | 'STALE_TURN' | 'INVALID_INPUT';
|
|
303
303
|
};
|
|
304
304
|
export interface BotListSession {
|
|
305
|
+
readonly startedAt?: string;
|
|
306
|
+
readonly endedAt?: string;
|
|
305
307
|
readonly sessionId?: string;
|
|
306
308
|
readonly title?: string;
|
|
307
309
|
readonly status: WorkSessionStatus;
|
|
@@ -40,6 +40,39 @@ export interface SkillMarketplaceInstallResult {
|
|
|
40
40
|
readonly skillId?: string;
|
|
41
41
|
readonly error?: string;
|
|
42
42
|
}
|
|
43
|
+
export interface SkillInstallTarget {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly workspaceId: string;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly path: string;
|
|
48
|
+
readonly kind: 'bot' | 'workspace';
|
|
49
|
+
readonly available: boolean;
|
|
50
|
+
readonly unavailableReason?: string;
|
|
51
|
+
readonly isActive: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface SkillInstallTargetRequest {
|
|
54
|
+
readonly workspaceId?: string;
|
|
55
|
+
readonly workspacePath?: string;
|
|
56
|
+
}
|
|
57
|
+
export type SkillInstallTargetResult = {
|
|
58
|
+
readonly workspaceId: string | null;
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly path: string | null;
|
|
61
|
+
} & ({
|
|
62
|
+
readonly ok: true;
|
|
63
|
+
readonly skillId: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly ok: false;
|
|
66
|
+
readonly error: string;
|
|
67
|
+
readonly code?: string;
|
|
68
|
+
});
|
|
69
|
+
export interface SkillInstallBatchReceipt {
|
|
70
|
+
readonly partial: boolean;
|
|
71
|
+
readonly succeededCount: number;
|
|
72
|
+
readonly failedCount: number;
|
|
73
|
+
readonly results: readonly SkillInstallTargetResult[];
|
|
74
|
+
}
|
|
75
|
+
export type SkillHubInstallResult = SkillMarketplaceInstallResult & Partial<SkillInstallBatchReceipt>;
|
|
43
76
|
/**
|
|
44
77
|
* SkillHub 官方列表排序(GET /api/skills?sortBy=):
|
|
45
78
|
* - score: 全部 / 综合评分
|
|
@@ -106,9 +139,10 @@ export interface SkillHubInstallRequest {
|
|
|
106
139
|
readonly namespace: string;
|
|
107
140
|
readonly slug: string;
|
|
108
141
|
readonly version: string;
|
|
109
|
-
/** 默认 global
|
|
142
|
+
/** 默认 global。工作区安装使用 targets,旧调用方可传 workspacePath。 */
|
|
110
143
|
readonly scope?: SkillHubInstallScope;
|
|
111
144
|
readonly workspacePath?: string;
|
|
145
|
+
readonly targets?: readonly SkillInstallTargetRequest[];
|
|
112
146
|
/** 市场图标 URL;安装时写入本地 _meta.json,供已安装列表展示。 */
|
|
113
147
|
readonly iconUrl?: string | null;
|
|
114
148
|
}
|
|
@@ -206,12 +240,13 @@ export interface QoderInstallIdentity {
|
|
|
206
240
|
readonly skillId: string;
|
|
207
241
|
readonly scope?: QoderInstallScope;
|
|
208
242
|
readonly workspacePath?: string;
|
|
243
|
+
readonly targets?: readonly SkillInstallTargetRequest[];
|
|
209
244
|
readonly iconUrl?: string | null;
|
|
210
245
|
}
|
|
211
|
-
export interface QoderInstallResult {
|
|
246
|
+
export interface QoderInstallResult extends Partial<SkillInstallBatchReceipt> {
|
|
212
247
|
readonly ok: boolean;
|
|
213
248
|
readonly skillId: string;
|
|
214
|
-
readonly installedSkillId
|
|
215
|
-
readonly version
|
|
249
|
+
readonly installedSkillId?: string;
|
|
250
|
+
readonly version?: string;
|
|
216
251
|
readonly scope: QoderInstallScope;
|
|
217
252
|
}
|
|
@@ -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 {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type WorkingPlanStepStatus = 'pending' | 'in_progress' | 'completed' | 'blocked';
|
|
2
|
+
export interface WorkingPlanStepView {
|
|
3
|
+
readonly title: string;
|
|
4
|
+
readonly status: WorkingPlanStepStatus;
|
|
5
|
+
readonly check?: string;
|
|
6
|
+
readonly note?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkingPlanView {
|
|
9
|
+
readonly epoch: number;
|
|
10
|
+
readonly revision: number;
|
|
11
|
+
readonly updatedAt: string;
|
|
12
|
+
readonly summary?: string;
|
|
13
|
+
readonly invariants?: readonly string[];
|
|
14
|
+
readonly completed: number;
|
|
15
|
+
readonly total: number;
|
|
16
|
+
readonly blocked: number;
|
|
17
|
+
readonly steps: readonly WorkingPlanStepView[];
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|