@lincyaw/kernel 1.0.0-rc.44 → 1.0.0-rc.45
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/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Member } from './server.ts'
|
|
2
|
+
import type { ReviewChange, ReviewStep } from './workspace.ts'
|
|
3
|
+
|
|
4
|
+
export const WORKSPACE_REVIEW_MAX_REQUEST_CHARS = 8192
|
|
5
|
+
export const WORKSPACE_REVIEW_MAX_RESPONSE_CHARS = 7168
|
|
6
|
+
export const WORKSPACE_REVIEW_FRAGMENT_CHARS = 4000
|
|
7
|
+
export interface WorkspaceReviewQuery { part?: 'summary' | 'files' | 'steps' | 'diff', path?: string, step?: string, offset?: number, snapshot?: string }
|
|
8
|
+
export interface WorkspaceReviewSummary { id: string, document: string, running: boolean, mode: 'required' | 'auto', files: number, steps: number }
|
|
9
|
+
export interface WorkspaceReviewAnswer {
|
|
10
|
+
review: WorkspaceReviewSummary | null
|
|
11
|
+
snapshot?: string
|
|
12
|
+
files?: Omit<ReviewChange, 'diff'>[]
|
|
13
|
+
steps?: (Omit<ReviewStep, 'changes'> & { files: number })[]
|
|
14
|
+
nextOffset?: number
|
|
15
|
+
diff?: { path: string, step?: string, text: string, offset: number, totalChars: number, sha256: string }
|
|
16
|
+
}
|
|
17
|
+
export type WorkspaceReviewChange =
|
|
18
|
+
| { action: 'accept', snapshot: string, reject?: string[], message?: string }
|
|
19
|
+
| { action: 'reject', snapshot: string, paths?: string[], confirm: true }
|
|
20
|
+
| { action: 'restore', snapshot: string, step: string, confirm: true }
|
|
21
|
+
export interface WorkspaceReviewChanged { outcome: 'accepted' | 'rejected' | 'restored' | 'updated' | 'empty', revision?: string, files?: number, remainingFiles?: number }
|
|
22
|
+
/** Workspace publication authority; document-scoped agent credentials must never receive this service. */
|
|
23
|
+
export interface WorkspaceReview {
|
|
24
|
+
read(query: WorkspaceReviewQuery, member: Member): Promise<WorkspaceReviewAnswer>
|
|
25
|
+
check(change: WorkspaceReviewChange, member: Member): Promise<void>
|
|
26
|
+
change(change: WorkspaceReviewChange, member: Member, signal?: AbortSignal): Promise<WorkspaceReviewChanged>
|
|
27
|
+
}
|
|
28
|
+
const path = { type: 'string', minLength: 1, maxLength: 500 } as const
|
|
29
|
+
const snapshot = { type: 'string', pattern: '^[a-f0-9]{64}$' } as const
|
|
30
|
+
const step = { type: 'string', minLength: 1, maxLength: 100 } as const
|
|
31
|
+
const paths = { type: 'array', minItems: 1, maxItems: 200, uniqueItems: true, items: path } as const
|
|
32
|
+
export const WORKSPACE_REVIEW_QUERY_SCHEMA = { type: 'object', additionalProperties: false, properties: {
|
|
33
|
+
part: { enum: ['summary', 'files', 'steps', 'diff'] }, path, step, offset: { type: 'integer', minimum: 0 }, snapshot,
|
|
34
|
+
} } as const
|
|
35
|
+
export const WORKSPACE_REVIEW_CHANGE_SCHEMA = { oneOf: [
|
|
36
|
+
{ type: 'object', additionalProperties: false, required: ['action', 'snapshot'], properties: { action: { const: 'accept' }, snapshot, reject: paths, message: { type: 'string', minLength: 1, maxLength: 4000 } } },
|
|
37
|
+
{ type: 'object', additionalProperties: false, required: ['action', 'snapshot', 'confirm'], properties: { action: { const: 'reject' }, snapshot, paths, confirm: { const: true } } },
|
|
38
|
+
{ type: 'object', additionalProperties: false, required: ['action', 'snapshot', 'step', 'confirm'], properties: { action: { const: 'restore' }, snapshot, step, confirm: { const: true } } },
|
|
39
|
+
] } as const
|
package/src/contracts.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './contracts/server.ts'
|
|
|
23
23
|
export * from './contracts/service.ts'
|
|
24
24
|
export * from './contracts/speech.ts'
|
|
25
25
|
export * from './contracts/speech-settings.ts'
|
|
26
|
+
export * from './contracts/workspace-review.ts'
|
|
26
27
|
export * from './contracts/transcription.ts'
|
|
27
28
|
export * from './contracts/transcription-adoption.ts'
|
|
28
29
|
export * from './contracts/voice.ts'
|
package/src/node/index.ts
CHANGED
|
@@ -29,3 +29,4 @@ export { systemLocale } from './locale.ts'
|
|
|
29
29
|
export { OperatorSpeechSettings, operatorSpeechSecrets, SpeechSettingsError, validateSpeechSettingsChange } from './operator-speech.ts'
|
|
30
30
|
export { devStateFile, readServiceState, removeServiceState, serveStateDir } from './service-state.ts'
|
|
31
31
|
export type { ServiceState } from './service-state.ts'
|
|
32
|
+
export { validateWorkspaceReviewQuery, validateWorkspaceReviewChange } from './workspace-review.ts'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Validator } from '@cfworker/json-schema'
|
|
2
|
+
import type { Schema } from '@cfworker/json-schema'
|
|
3
|
+
import { WORKSPACE_REVIEW_CHANGE_SCHEMA, WORKSPACE_REVIEW_QUERY_SCHEMA } from '../contracts/workspace-review.ts'
|
|
4
|
+
import type { WorkspaceReviewChange, WorkspaceReviewQuery } from '../contracts/workspace-review.ts'
|
|
5
|
+
|
|
6
|
+
const query = new Validator(WORKSPACE_REVIEW_QUERY_SCHEMA as unknown as Schema)
|
|
7
|
+
const change = new Validator(WORKSPACE_REVIEW_CHANGE_SCHEMA as unknown as Schema)
|
|
8
|
+
export const validateWorkspaceReviewQuery = (value: unknown): value is WorkspaceReviewQuery => query.validate(value).valid
|
|
9
|
+
export const validateWorkspaceReviewChange = (value: unknown): value is WorkspaceReviewChange => change.validate(value).valid
|