@puredesktop/puredesktop-ui-bridge 2.1.7 → 2.1.9
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 +89 -5
- package/src/agents/mcpServerPresets.test.ts +105 -0
- package/src/agents/mcpServerPresets.ts +380 -0
- package/src/agents/runtime/index.ts +7 -0
- package/src/agents/runtime/mapAgentSnapshot.ts +11 -8
- package/src/agents/runtime/pendingAsks.test.ts +117 -0
- package/src/agents/runtime/pendingAsks.ts +110 -0
- package/src/bridge/agentScopeDefaults.ts +65 -0
- package/src/bridge/agentTypes.ts +57 -3
- package/src/bridge/agents.d.mts +6 -0
- package/src/bridge/agents.mjs +10 -0
- package/src/bridge/agents.ts +4 -0
- package/src/bridge/collectionImagePaste.ts +19 -1
- package/src/bridge/context.mjs +32 -0
- package/src/bridge/credentials.d.mts +62 -0
- package/src/bridge/credentials.mjs +53 -0
- package/src/bridge/documents.d.mts +76 -0
- package/src/bridge/documents.mjs +40 -0
- package/src/bridge/events.d.mts +1 -0
- package/src/bridge/events.mjs +1 -0
- package/src/bridge/googleAuth.ts +7 -152
- package/src/bridge/mcpClient.d.mts +74 -0
- package/src/bridge/mcpClient.mjs +79 -0
- package/src/bridge/methods.d.mts +45 -0
- package/src/bridge/methods.mjs +46 -0
- package/src/bridge/notifications.d.mts +12 -0
- package/src/bridge/notifications.mjs +36 -0
- package/src/bridge/operations.d.mts +44 -0
- package/src/bridge/operations.mjs +40 -0
- package/src/bridge/pureRender/base.css +44 -0
- package/src/bridge/pureRender/document.ts +29 -2
- package/src/bridge/pureRender/index.ts +3 -0
- package/src/bridge/pureRender/normalize.ts +167 -0
- package/src/bridge/pureRender/sanitizeExportBody.test.ts +51 -0
- package/src/bridge/pureRender/sanitizeExportBody.ts +61 -0
- package/src/bridge/pureRender/styles.ts +125 -5
- package/src/bridge/pureRender/theme.test.ts +259 -0
- package/src/bridge/pureRender/theme.ts +19 -1
- package/src/bridge/pureRender/types.ts +33 -0
- package/src/bridge/pureRender/visualLayoutInspection.test.ts +26 -0
- package/src/bridge/pureRender/visualLayoutInspection.ts +75 -0
- package/src/bridge/react/useDocumentHotkeys.ts +41 -0
- package/src/bridge/react/useDocumentLifecycle.tsx +359 -0
- package/src/bridge/react/usePlatformAgentSessionDrive.test.tsx +29 -10
- package/src/bridge/react/usePlatformAgentSessionDrive.tsx +10 -81
- package/src/bridge/react/usePlatformAppSettings.test.tsx +105 -0
- package/src/bridge/react/usePlatformAppSettings.tsx +104 -0
- package/src/bridge/react/usePlatformJsonStore.test.tsx +152 -0
- package/src/bridge/react/usePlatformJsonStore.tsx +149 -0
- package/src/bridge/react/usePlatformOperations.tsx +75 -0
- package/src/bridge/storage.d.mts +23 -10
- package/src/bridge/storage.mjs +6 -3
- package/src/bridge/storage.test.ts +6 -6
- package/src/bridge/types.ts +7 -0
- package/src/components/agents/AgentComposer.tsx +10 -6
- package/src/components/agents/AgentDrawerPanel.test.tsx +2 -205
- package/src/components/agents/AgentDrawerPanel.tsx +23 -62
- package/src/components/agents/AgentMessageBubble.tsx +59 -33
- package/src/components/agents/AgentMessageList.tsx +4 -4
- package/src/components/agents/AgentQuestionPromptList.tsx +34 -212
- package/src/components/agents/AgentToolApprovalActions.tsx +13 -11
- package/src/components/agents/AgentToolCallCard.tsx +20 -20
- package/src/components/agents/AgentToolPendingList.tsx +6 -6
- package/src/components/agents/AgentToolPendingReview.tsx +6 -6
- package/src/components/agents/ContextPicker.tsx +239 -0
- package/src/components/agents/QuestionRequestList.tsx +278 -0
- package/src/components/agents/agentPanelStyles.ts +8 -31
- package/src/components/agents/agentTypes.ts +25 -41
- package/src/components/agents/index.ts +4 -0
- package/src/components/assets/asset-library/sidebar/AssetLibraryList.tsx +10 -4
- package/src/components/chrome/WorkspaceTabStrip.tsx +22 -4
- package/src/components/chrome/workspaceTabTypes.ts +2 -0
- package/src/components/common/chat/ChatBox.tsx +9 -9
- package/src/components/common/chat/ChatModelMenu.tsx +34 -4
- package/src/components/common/chat/ChatThread.tsx +23 -7
- package/src/components/common/connections/ProviderConnection.test.tsx +208 -0
- package/src/components/common/connections/ProviderConnection.tsx +277 -0
- package/src/components/common/connections/index.ts +5 -0
- package/src/components/common/containers/AppFrame.test.tsx +4 -4
- package/src/components/common/containers/AppFrame.tsx +26 -10
- package/src/components/common/containers/AppHeader.tsx +37 -15
- package/src/components/common/documents/DocumentHeaderActions.tsx +206 -0
- package/src/components/common/documents/DocumentSwitcher.tsx +1181 -0
- package/src/components/common/documents/index.ts +8 -0
- package/src/components/common/dropdown/MenuDropdownItem.tsx +14 -2
- package/src/components/common/dropdown/MenuPortal.tsx +3 -1
- package/src/components/common/dropdown/menuViewportPosition.test.ts +20 -10
- package/src/components/common/dropdown/menuViewportPosition.ts +35 -27
- package/src/components/common/overlays/Modal.tsx +13 -2
- package/src/components/common/research/EvidenceDossier.tsx +1232 -150
- package/src/components/common/research/index.ts +2 -0
- package/src/components/editor/EditorLinkPromptDialog.tsx +1 -1
- package/src/components/print-design/PrintDesignPanel.test.tsx +430 -40
- package/src/components/print-design/PrintDesignPanel.tsx +1770 -207
- package/src/components/print-design/index.ts +2 -0
- package/src/components/print-design/previewContent.test.ts +32 -0
- package/src/components/print-design/previewContent.ts +31 -0
- package/src/context/buildContextDocument.test.ts +240 -0
- package/src/context/buildContextDocument.ts +309 -0
- package/src/context/contextAccess.ts +66 -0
- package/src/context/contextConfig.ts +72 -0
- package/src/context/contextDocument.test.ts +155 -0
- package/src/context/contextDocument.ts +300 -0
- package/src/context/contextSections.test.ts +88 -0
- package/src/context/contextSections.ts +84 -0
- package/src/context/htmlToContextMarkdown.test.ts +134 -0
- package/src/context/htmlToContextMarkdown.ts +369 -0
- package/src/ics/generateIcs.test.ts +153 -0
- package/src/ics/generateIcs.ts +197 -0
- package/src/index.ts +3 -0
- package/src/net/httpRetry.test.ts +117 -0
- package/src/net/httpRetry.ts +111 -0
- package/src/theme/appAccents.test.ts +36 -35
- package/src/theme/appAccents.ts +93 -104
- package/src/theme/appIdentityCss.mjs +178 -229
- package/src/theme/appIdentityCss.ts +222 -231
- package/src/theme/themes/dark.ts +3 -1
- package/src/theme/themes/light.ts +3 -1
- package/src/bridge/googleProviderConfig.ts +0 -73
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PlatformAgentSessionConfigPatch,
|
|
3
|
+
PlatformAgentSessionScope,
|
|
4
|
+
} from './agentTypes.js'
|
|
5
|
+
import {
|
|
6
|
+
getPlatformPreferences,
|
|
7
|
+
patchPlatformPreferences,
|
|
8
|
+
} from './preferences.mjs'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Persist session-config changes as scope defaults in shell preferences
|
|
12
|
+
* (`agentSessionDefaults.global` / `.apps[slug]`) — layer 3 of the approval
|
|
13
|
+
* ladder (docs/08-agent-orchestration.md). Every NEW session in the scope
|
|
14
|
+
* inherits these, mission runs and delegated children included; this is what
|
|
15
|
+
* makes "always allow" stick beyond one conversation.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
interface StoredScopeDefaults {
|
|
19
|
+
global?: PlatformAgentSessionConfigPatch
|
|
20
|
+
apps?: Record<string, PlatformAgentSessionConfigPatch>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function mergeScopeDefaultPatch(
|
|
24
|
+
base: PlatformAgentSessionConfigPatch | undefined,
|
|
25
|
+
patch: PlatformAgentSessionConfigPatch,
|
|
26
|
+
): PlatformAgentSessionConfigPatch {
|
|
27
|
+
const toolPolicy =
|
|
28
|
+
patch.toolPolicy || base?.toolPolicy
|
|
29
|
+
? {
|
|
30
|
+
...base?.toolPolicy,
|
|
31
|
+
...patch.toolPolicy,
|
|
32
|
+
approvalOverrides: {
|
|
33
|
+
...base?.toolPolicy?.approvalOverrides,
|
|
34
|
+
...patch.toolPolicy?.approvalOverrides,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
: undefined
|
|
38
|
+
return { ...base, ...patch, ...(toolPolicy ? { toolPolicy } : {}) }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function patchAgentSessionScopeDefaults(
|
|
42
|
+
scope: PlatformAgentSessionScope,
|
|
43
|
+
appSlug: string | undefined,
|
|
44
|
+
patch: PlatformAgentSessionConfigPatch,
|
|
45
|
+
): Promise<void> {
|
|
46
|
+
const prefs = (await getPlatformPreferences()) as {
|
|
47
|
+
agentSessionDefaults?: StoredScopeDefaults
|
|
48
|
+
}
|
|
49
|
+
const stored = prefs.agentSessionDefaults ?? {}
|
|
50
|
+
if (scope === 'global') {
|
|
51
|
+
await patchPlatformPreferences({
|
|
52
|
+
agentSessionDefaults: {
|
|
53
|
+
...stored,
|
|
54
|
+
global: mergeScopeDefaultPatch(stored.global, patch),
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
if (!appSlug) return
|
|
60
|
+
const apps = { ...(stored.apps ?? {}) }
|
|
61
|
+
apps[appSlug] = mergeScopeDefaultPatch(apps[appSlug], patch)
|
|
62
|
+
await patchPlatformPreferences({
|
|
63
|
+
agentSessionDefaults: { ...stored, apps },
|
|
64
|
+
})
|
|
65
|
+
}
|
package/src/bridge/agentTypes.ts
CHANGED
|
@@ -24,7 +24,27 @@ export interface PlatformAgentImageAttachment {
|
|
|
24
24
|
name?: string
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* An object's markdown context document attached to a user message —
|
|
29
|
+
* output of the context picker (`context.read`). Mirrors the shell's
|
|
30
|
+
* `AgentContextAttachment`.
|
|
31
|
+
*/
|
|
32
|
+
export interface PlatformAgentContextAttachment {
|
|
33
|
+
type: 'context'
|
|
34
|
+
/** Object kind, e.g. 'manuscript' | 'book'. */
|
|
35
|
+
kind: string
|
|
36
|
+
appSlug: string
|
|
37
|
+
objectId: string
|
|
38
|
+
title: string
|
|
39
|
+
/** Full or section markdown from the object's context document. */
|
|
40
|
+
markdown: string
|
|
41
|
+
/** Durable section id when a segmented read was attached. */
|
|
42
|
+
section?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type PlatformAgentMessageAttachment =
|
|
46
|
+
| PlatformAgentImageAttachment
|
|
47
|
+
| PlatformAgentContextAttachment
|
|
28
48
|
|
|
29
49
|
export interface PlatformAgentUiToolCall {
|
|
30
50
|
id: string
|
|
@@ -69,12 +89,12 @@ export interface PlatformAgentSessionToolPolicy {
|
|
|
69
89
|
}
|
|
70
90
|
|
|
71
91
|
export interface PlatformAgentSessionConfig {
|
|
72
|
-
modelId
|
|
92
|
+
modelId?: string
|
|
73
93
|
/** Appended after the app's agents.md base prompt. */
|
|
74
94
|
sessionPrompt?: string
|
|
75
95
|
/** Full system prompt override. When set, replaces agents.md and sessionPrompt. */
|
|
76
96
|
systemPrompt?: string
|
|
77
|
-
toolPolicy?: PlatformAgentSessionToolPolicy
|
|
97
|
+
toolPolicy?: Partial<PlatformAgentSessionToolPolicy>
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
export interface PlatformAgentSessionMetadata {
|
|
@@ -179,6 +199,40 @@ export interface PlatformReadAgentJobRequest {
|
|
|
179
199
|
jobId: string
|
|
180
200
|
}
|
|
181
201
|
|
|
202
|
+
export type PlatformAgentDelegationStatus =
|
|
203
|
+
| 'pending'
|
|
204
|
+
| 'running'
|
|
205
|
+
| 'completed'
|
|
206
|
+
| 'failed'
|
|
207
|
+
| 'cancelled'
|
|
208
|
+
|
|
209
|
+
export interface PlatformAgentDelegationRecord {
|
|
210
|
+
version: 1
|
|
211
|
+
delegationId: string
|
|
212
|
+
parentJobId?: string
|
|
213
|
+
parentScope?: PlatformAgentSessionScope
|
|
214
|
+
parentAppSlug?: string
|
|
215
|
+
parentSessionId: string
|
|
216
|
+
parentRunId: string
|
|
217
|
+
parentToolCallId: string
|
|
218
|
+
childSessionId: string
|
|
219
|
+
childAppSlug: string
|
|
220
|
+
childJobId?: string
|
|
221
|
+
status: PlatformAgentDelegationStatus
|
|
222
|
+
resultJson?: unknown
|
|
223
|
+
error?: string
|
|
224
|
+
createdAt: string
|
|
225
|
+
updatedAt: string
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface PlatformListAgentDelegationsRequest {
|
|
229
|
+
parentJobId?: string
|
|
230
|
+
childJobId?: string
|
|
231
|
+
parentSessionId?: string
|
|
232
|
+
childSessionId?: string
|
|
233
|
+
status?: PlatformAgentDelegationStatus
|
|
234
|
+
}
|
|
235
|
+
|
|
182
236
|
export interface PlatformCancelAgentJobRequest
|
|
183
237
|
extends PlatformReadAgentJobRequest {
|
|
184
238
|
reason?: string
|
package/src/bridge/agents.d.mts
CHANGED
|
@@ -23,8 +23,10 @@ import type {
|
|
|
23
23
|
PlatformCreateAgentSessionRequest,
|
|
24
24
|
PlatformCreateAgentJobRequest,
|
|
25
25
|
PlatformCancelAgentJobRequest,
|
|
26
|
+
PlatformAgentDelegationRecord,
|
|
26
27
|
PlatformAgentJobRecord,
|
|
27
28
|
PlatformListAgentSessionsRequest,
|
|
29
|
+
PlatformListAgentDelegationsRequest,
|
|
28
30
|
PlatformListAgentJobsRequest,
|
|
29
31
|
PlatformReadAgentSessionRequest,
|
|
30
32
|
PlatformReadAgentJobRequest,
|
|
@@ -71,6 +73,10 @@ export function runAgentJobNow(
|
|
|
71
73
|
request: PlatformReadAgentJobRequest,
|
|
72
74
|
): Promise<PlatformAgentJobRecord>
|
|
73
75
|
|
|
76
|
+
export function listAgentDelegations(
|
|
77
|
+
request?: PlatformListAgentDelegationsRequest,
|
|
78
|
+
): Promise<PlatformAgentDelegationRecord[]>
|
|
79
|
+
|
|
74
80
|
export function sendAgentSessionMessage(
|
|
75
81
|
request: PlatformSendAgentSessionMessageRequest,
|
|
76
82
|
): Promise<PlatformAgentSessionDriveResult>
|
package/src/bridge/agents.mjs
CHANGED
|
@@ -78,6 +78,16 @@ export async function runAgentJobNow(request) {
|
|
|
78
78
|
return bridge.call(PLATFORM_BRIDGE_METHODS.AGENTS_JOBS_RUN_NOW, [request])
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @param {import('./agentTypes.js').PlatformListAgentDelegationsRequest} [request]
|
|
83
|
+
* @returns {Promise<import('./agentTypes.js').PlatformAgentDelegationRecord[]>}
|
|
84
|
+
*/
|
|
85
|
+
export async function listAgentDelegations(request = {}) {
|
|
86
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.AGENTS_DELEGATIONS_LIST, [
|
|
87
|
+
request,
|
|
88
|
+
])
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
/**
|
|
82
92
|
* Send a user message on a session; shell drives the run until awaiting user,
|
|
83
93
|
* manual pending tools, or terminal state.
|
package/src/bridge/agents.ts
CHANGED
|
@@ -8,6 +8,7 @@ export {
|
|
|
8
8
|
createAgentSession,
|
|
9
9
|
deleteAgentSession,
|
|
10
10
|
interruptAgentSession,
|
|
11
|
+
listAgentDelegations,
|
|
11
12
|
listAgentJobs,
|
|
12
13
|
listAgentSessions,
|
|
13
14
|
onAgentRunEvent,
|
|
@@ -29,6 +30,8 @@ export {
|
|
|
29
30
|
export type {
|
|
30
31
|
PlatformAgentMessage,
|
|
31
32
|
PlatformAgentMessageAttachment,
|
|
33
|
+
PlatformAgentDelegationRecord,
|
|
34
|
+
PlatformAgentDelegationStatus,
|
|
32
35
|
PlatformAgentJobRecord,
|
|
33
36
|
PlatformAgentJobSchedule,
|
|
34
37
|
PlatformAgentJobStatus,
|
|
@@ -47,6 +50,7 @@ export type {
|
|
|
47
50
|
PlatformCreateAgentSessionRequest,
|
|
48
51
|
PlatformCreateAgentJobRequest,
|
|
49
52
|
PlatformListAgentSessionsRequest,
|
|
53
|
+
PlatformListAgentDelegationsRequest,
|
|
50
54
|
PlatformListAgentJobsRequest,
|
|
51
55
|
PlatformReadAgentJobRequest,
|
|
52
56
|
PlatformReadAgentSessionRequest,
|
|
@@ -25,12 +25,29 @@ export interface CollectionImagePastePayload {
|
|
|
25
25
|
mimeType: string
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export interface CollectionImageInsertPayload {
|
|
29
|
+
relativePath: string
|
|
30
|
+
alt: string
|
|
31
|
+
bytes: Uint8Array
|
|
32
|
+
mimeType: string
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
export interface CollectionImagePasteHandlerOptions {
|
|
29
36
|
collectionPath?: string
|
|
30
37
|
subdir?: string
|
|
31
38
|
onError?: (message: string) => void
|
|
32
39
|
getEditor: () => Editor | null | undefined
|
|
33
40
|
writeBinary: (absolutePath: string, bytes: Uint8Array) => Promise<void>
|
|
41
|
+
/**
|
|
42
|
+
* Override how the persisted image is placed into the document. Defaults to a
|
|
43
|
+
* bare image node; callers (e.g. the manuscript editor) can supply a handler
|
|
44
|
+
* that wraps it in a captioned `<figure>` so it is numbered and
|
|
45
|
+
* cross-referenceable. Returns `false` if the editor cannot accept the node.
|
|
46
|
+
*/
|
|
47
|
+
insertImage?: (
|
|
48
|
+
editor: Editor | null | undefined,
|
|
49
|
+
image: CollectionImageInsertPayload,
|
|
50
|
+
) => boolean
|
|
34
51
|
}
|
|
35
52
|
|
|
36
53
|
export function normalizeCollectionImageMimeType(
|
|
@@ -93,6 +110,7 @@ export function createCollectionImagePasteHandler(
|
|
|
93
110
|
onError,
|
|
94
111
|
getEditor,
|
|
95
112
|
writeBinary,
|
|
113
|
+
insertImage = insertCollectionImage,
|
|
96
114
|
} = options
|
|
97
115
|
|
|
98
116
|
return async ({ name, bytes, mimeType }) => {
|
|
@@ -117,7 +135,7 @@ export function createCollectionImagePasteHandler(
|
|
|
117
135
|
const stem = stemFromImageFileName(name)
|
|
118
136
|
const editor = getEditor()
|
|
119
137
|
if (
|
|
120
|
-
!
|
|
138
|
+
!insertImage(editor, {
|
|
121
139
|
relativePath,
|
|
122
140
|
alt: stem,
|
|
123
141
|
bytes,
|
package/src/bridge/context.mjs
CHANGED
|
@@ -10,3 +10,35 @@ import { PLATFORM_BRIDGE_METHODS } from './methods.mjs'
|
|
|
10
10
|
export async function publishContext(request) {
|
|
11
11
|
return bridge.call(PLATFORM_BRIDGE_METHODS.CONTEXT_PUBLISH, [request])
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resolve one object's context document — generates or refreshes the
|
|
16
|
+
* `<name>.<kind>.md` file when missing or stale. Requires `filesystem`.
|
|
17
|
+
*
|
|
18
|
+
* @param {{ path?: string, appSlug?: string, objectId?: string }} ref
|
|
19
|
+
* @returns {Promise<import('../context/contextAccess.js').PlatformContextResolveResult>}
|
|
20
|
+
*/
|
|
21
|
+
export async function resolveContextDocument(ref) {
|
|
22
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.CONTEXT_RESOLVE, [ref])
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Read one object's context markdown — the whole document or one section by
|
|
27
|
+
* durable section id. Requires `filesystem`.
|
|
28
|
+
*
|
|
29
|
+
* @param {{ path?: string, appSlug?: string, objectId?: string, section?: string }} request
|
|
30
|
+
* @returns {Promise<import('../context/contextAccess.js').PlatformContextReadResult>}
|
|
31
|
+
*/
|
|
32
|
+
export async function readContextDocument(request) {
|
|
33
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.CONTEXT_READ, [request])
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Search context-enabled objects across apps. Requires `filesystem`.
|
|
38
|
+
*
|
|
39
|
+
* @param {{ query: string, kinds?: string[], appSlug?: string, limit?: number }} request
|
|
40
|
+
* @returns {Promise<import('../context/contextAccess.js').PlatformContextSearchHit[]>}
|
|
41
|
+
*/
|
|
42
|
+
export async function searchContextObjects(request) {
|
|
43
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.CONTEXT_SEARCH, [request])
|
|
44
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface CredentialStorageStatus {
|
|
2
|
+
encryptionAvailable: boolean
|
|
3
|
+
backend: string | null
|
|
4
|
+
secure: boolean
|
|
5
|
+
warning?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface CredentialEntryStatus {
|
|
9
|
+
id: string
|
|
10
|
+
label: string
|
|
11
|
+
description?: string
|
|
12
|
+
configured: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Redacted OAuth connection state — never contains secret material. */
|
|
16
|
+
export interface OAuthCredentialStatus {
|
|
17
|
+
id: string
|
|
18
|
+
kind: 'oauth'
|
|
19
|
+
provider: 'google'
|
|
20
|
+
configured: boolean
|
|
21
|
+
connected: boolean
|
|
22
|
+
email?: string
|
|
23
|
+
scopes: string[]
|
|
24
|
+
needsReconnect: boolean
|
|
25
|
+
updatedAt?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function readCredentialStorageStatus(): Promise<CredentialStorageStatus>
|
|
29
|
+
|
|
30
|
+
export function listCredentials(): Promise<CredentialEntryStatus[]>
|
|
31
|
+
|
|
32
|
+
export function setCredential(request: {
|
|
33
|
+
id: string
|
|
34
|
+
value: string
|
|
35
|
+
}): Promise<{ ok: true }>
|
|
36
|
+
|
|
37
|
+
export function deleteCredential(request: { id: string }): Promise<{ ok: true }>
|
|
38
|
+
|
|
39
|
+
export function readCredentialStatus(request: {
|
|
40
|
+
id: string
|
|
41
|
+
}): Promise<OAuthCredentialStatus>
|
|
42
|
+
|
|
43
|
+
export function setCredentialOAuthConfig(request: {
|
|
44
|
+
id: string
|
|
45
|
+
clientId: string
|
|
46
|
+
clientSecret: string
|
|
47
|
+
scopes?: string[]
|
|
48
|
+
}): Promise<{ ok: true }>
|
|
49
|
+
|
|
50
|
+
export function connectCredentialOAuth(request: {
|
|
51
|
+
id: string
|
|
52
|
+
scopes?: string[]
|
|
53
|
+
}): Promise<{ email?: string }>
|
|
54
|
+
|
|
55
|
+
export function disconnectCredential(request: {
|
|
56
|
+
id: string
|
|
57
|
+
forget?: boolean
|
|
58
|
+
}): Promise<{ ok: true }>
|
|
59
|
+
|
|
60
|
+
export function readCredentialOAuthAccessToken(request: {
|
|
61
|
+
id: string
|
|
62
|
+
}): Promise<{ accessToken: string; expiresAt: number }>
|
|
@@ -20,3 +20,56 @@ export async function setCredential(request) {
|
|
|
20
20
|
export async function deleteCredential(request) {
|
|
21
21
|
return bridge.call(PLATFORM_BRIDGE_METHODS.CREDENTIALS_DELETE, [request])
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Redacted OAuth connection state — the only credential state apps may read.
|
|
26
|
+
* @param {{ id: string }} request
|
|
27
|
+
* @returns {Promise<{ id: string, configured: boolean, connected: boolean, email?: string, scopes: string[], needsReconnect: boolean, updatedAt?: string }>}
|
|
28
|
+
*/
|
|
29
|
+
export async function readCredentialStatus(request) {
|
|
30
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.CREDENTIALS_STATUS, [request])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Write-only OAuth client config; the secret is never echoed back.
|
|
35
|
+
* @param {{ id: string, clientId: string, clientSecret: string, scopes?: string[] }} request
|
|
36
|
+
* @returns {Promise<{ ok: true }>}
|
|
37
|
+
*/
|
|
38
|
+
export async function setCredentialOAuthConfig(request) {
|
|
39
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.CREDENTIALS_SET_OAUTH_CONFIG, [
|
|
40
|
+
request,
|
|
41
|
+
])
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Runs the full OAuth flow in the shell (browser + loopback + token
|
|
46
|
+
* exchange); no token or secret ever reaches the caller.
|
|
47
|
+
* @param {{ id: string, scopes?: string[] }} request
|
|
48
|
+
* @returns {Promise<{ email?: string }>}
|
|
49
|
+
*/
|
|
50
|
+
export async function connectCredentialOAuth(request) {
|
|
51
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.CREDENTIALS_CONNECT_OAUTH, [
|
|
52
|
+
request,
|
|
53
|
+
])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Clears tokens + identity; pass `forget: true` to also drop the client config.
|
|
58
|
+
* @param {{ id: string, forget?: boolean }} request
|
|
59
|
+
* @returns {Promise<{ ok: true }>}
|
|
60
|
+
*/
|
|
61
|
+
export async function disconnectCredential(request) {
|
|
62
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.CREDENTIALS_DISCONNECT, [request])
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Short-lived access token for providers that call the API directly.
|
|
67
|
+
* Refreshed transparently in the shell; refresh tokens never cross the bridge.
|
|
68
|
+
* @param {{ id: string }} request
|
|
69
|
+
* @returns {Promise<{ accessToken: string, expiresAt: number }>}
|
|
70
|
+
*/
|
|
71
|
+
export async function readCredentialOAuthAccessToken(request) {
|
|
72
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.CREDENTIALS_OAUTH_ACCESS_TOKEN, [
|
|
73
|
+
request,
|
|
74
|
+
])
|
|
75
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** One file inside a document. `name: null` addresses a single-file document
|
|
2
|
+
* itself; a string is a path relative to a package directory. */
|
|
3
|
+
export interface PlatformDocumentFilePayload {
|
|
4
|
+
name: string | null
|
|
5
|
+
content: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface PlatformDocumentCreateDraftRequest {
|
|
9
|
+
appSlug: string
|
|
10
|
+
suffix: string
|
|
11
|
+
kind: 'package' | 'file'
|
|
12
|
+
title?: string
|
|
13
|
+
files: PlatformDocumentFilePayload[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PlatformDocumentListEntry {
|
|
17
|
+
path: string
|
|
18
|
+
name: string
|
|
19
|
+
mtimeMs: number
|
|
20
|
+
isDraft: boolean
|
|
21
|
+
kind: 'package' | 'file'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PlatformRecentDocumentEntry {
|
|
25
|
+
path: string
|
|
26
|
+
title: string
|
|
27
|
+
touchedAt: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createPlatformDraft(
|
|
31
|
+
request: PlatformDocumentCreateDraftRequest,
|
|
32
|
+
): Promise<{ path: string }>
|
|
33
|
+
|
|
34
|
+
export function autosavePlatformDocument(request: {
|
|
35
|
+
path: string
|
|
36
|
+
files: PlatformDocumentFilePayload[]
|
|
37
|
+
}): Promise<{ savedAt: string }>
|
|
38
|
+
|
|
39
|
+
export function promotePlatformDocument(request: {
|
|
40
|
+
path: string
|
|
41
|
+
title: string
|
|
42
|
+
targetDir?: string
|
|
43
|
+
/** The document type's real suffix (e.g. `.chart.json`) — required for
|
|
44
|
+
* compound suffixes, which cannot be recovered from the path. */
|
|
45
|
+
suffix?: string
|
|
46
|
+
appSlug?: string
|
|
47
|
+
}): Promise<{ path: string }>
|
|
48
|
+
|
|
49
|
+
export function renamePlatformDocument(request: {
|
|
50
|
+
path: string
|
|
51
|
+
title: string
|
|
52
|
+
suffix?: string
|
|
53
|
+
appSlug?: string
|
|
54
|
+
}): Promise<{ path: string }>
|
|
55
|
+
|
|
56
|
+
export function duplicatePlatformDocument(request: {
|
|
57
|
+
path: string
|
|
58
|
+
suffix?: string
|
|
59
|
+
}): Promise<{ path: string }>
|
|
60
|
+
|
|
61
|
+
export function listPlatformDocumentsByType(request: {
|
|
62
|
+
suffixes: string[]
|
|
63
|
+
}): Promise<PlatformDocumentListEntry[]>
|
|
64
|
+
|
|
65
|
+
export function listPlatformRecentDocuments(request: {
|
|
66
|
+
appSlug: string
|
|
67
|
+
limit?: number
|
|
68
|
+
}): Promise<PlatformRecentDocumentEntry[]>
|
|
69
|
+
|
|
70
|
+
export function touchPlatformRecentDocument(request: {
|
|
71
|
+
appSlug: string
|
|
72
|
+
path: string
|
|
73
|
+
title: string
|
|
74
|
+
}): Promise<void>
|
|
75
|
+
|
|
76
|
+
export function suggestPlatformDocumentLocation(): Promise<{ dir: string }>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { bridge } from './client.mjs'
|
|
2
|
+
import { PLATFORM_BRIDGE_METHODS } from './methods.mjs'
|
|
3
|
+
|
|
4
|
+
/** Unified document lifecycle bridge: drafts, autosave, filing, recents. */
|
|
5
|
+
|
|
6
|
+
export async function createPlatformDraft(request) {
|
|
7
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_CREATE_DRAFT, [request])
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function autosavePlatformDocument(request) {
|
|
11
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_AUTOSAVE, [request])
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function promotePlatformDocument(request) {
|
|
15
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_PROMOTE, [request])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function renamePlatformDocument(request) {
|
|
19
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_RENAME, [request])
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function duplicatePlatformDocument(request) {
|
|
23
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_DUPLICATE, [request])
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function listPlatformDocumentsByType(request) {
|
|
27
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_LIST_BY_TYPE, [request])
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function listPlatformRecentDocuments(request) {
|
|
31
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_RECENTS_LIST, [request])
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function touchPlatformRecentDocument(request) {
|
|
35
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_RECENTS_TOUCH, [request])
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function suggestPlatformDocumentLocation() {
|
|
39
|
+
return bridge.call(PLATFORM_BRIDGE_METHODS.DOCUMENTS_SUGGEST_LOCATION, [])
|
|
40
|
+
}
|
package/src/bridge/events.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const PLATFORM_BRIDGE_EVENTS: {
|
|
|
8
8
|
readonly DEBUG_TEST: 'debug.test'
|
|
9
9
|
readonly SCHEDULE_FIRE: 'schedule.fire'
|
|
10
10
|
readonly WINDOW_CAMERA_SHORTCUT: 'window.cameraShortcut'
|
|
11
|
+
readonly OPERATIONS_CHANGED: 'operations.changed'
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export type PlatformBridgeEventName =
|