@tapicker/bridge 1.0.0 → 1.1.0
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/README.md +15 -15
- package/dist/bridge/bridge-service.d.ts +1 -1
- package/dist/bridge/bridge-service.js +7 -7
- package/dist/bridge/control.js +1 -1
- package/dist/bridge/export-store.d.ts +35 -0
- package/dist/bridge/export-store.js +195 -0
- package/dist/bridge/extension-session.d.ts +9 -2
- package/dist/bridge/extension-session.js +56 -8
- package/dist/cli.js +563 -148
- package/dist/commands.d.ts +8 -0
- package/dist/commands.js +276 -40
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +4 -2
- package/dist/http-client.d.ts +24 -0
- package/dist/http-client.js +101 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/mcp.d.ts +4 -3
- package/dist/mcp.js +221 -134
- package/dist/protocol/schema.d.ts +503 -34
- package/dist/protocol/schema.js +396 -15
- package/dist/server.d.ts +7 -4
- package/dist/server.js +70 -26
- package/dist/update-notifier-worker.d.ts +2 -0
- package/dist/update-notifier-worker.js +3 -0
- package/dist/update-notifier.d.ts +9 -0
- package/dist/update-notifier.js +178 -0
- package/dist/workflow-watch.d.ts +8 -7
- package/dist/workflow-watch.js +39 -29
- package/package.json +16 -6
- package/docs/cli.md +0 -112
- package/docs/http-api.md +0 -149
- package/docs/mcp.md +0 -90
- package/docs/operations.md +0 -85
- package/docs/workflow-watch.md +0 -86
- package/src/bridge/bridge-service.ts +0 -291
- package/src/bridge/control.ts +0 -281
- package/src/bridge/daemon.ts +0 -102
- package/src/bridge/extension-session.ts +0 -286
- package/src/bridge/pairing-state.ts +0 -92
- package/src/cli.ts +0 -1019
- package/src/commands.ts +0 -158
- package/src/constants.ts +0 -10
- package/src/errors.ts +0 -72
- package/src/index.ts +0 -35
- package/src/mcp.ts +0 -386
- package/src/protocol/schema.ts +0 -202
- package/src/server.ts +0 -623
- package/src/workflow-watch.ts +0 -364
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto'
|
|
2
|
-
import { mkdir, open, readFile, rename, unlink } from 'node:fs/promises'
|
|
3
|
-
import { homedir } from 'node:os'
|
|
4
|
-
import { dirname, join } from 'node:path'
|
|
5
|
-
import { z } from 'zod'
|
|
6
|
-
import { BridgeError } from '../errors.js'
|
|
7
|
-
|
|
8
|
-
const PairingStateSchema = z
|
|
9
|
-
.object({
|
|
10
|
-
version: z.literal(1),
|
|
11
|
-
clients: z
|
|
12
|
-
.array(
|
|
13
|
-
z
|
|
14
|
-
.object({
|
|
15
|
-
clientId: z.uuid(),
|
|
16
|
-
credential: z.uuid(),
|
|
17
|
-
})
|
|
18
|
-
.strict(),
|
|
19
|
-
)
|
|
20
|
-
.default([]),
|
|
21
|
-
})
|
|
22
|
-
.strict()
|
|
23
|
-
|
|
24
|
-
export type PairedExtensionIdentity = z.infer<typeof PairingStateSchema>['clients'][number]
|
|
25
|
-
|
|
26
|
-
export interface PairingStatePersistence {
|
|
27
|
-
load(): Promise<PairedExtensionIdentity[]>
|
|
28
|
-
save(identities: PairedExtensionIdentity[]): Promise<void>
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class PairingStateFile implements PairingStatePersistence {
|
|
32
|
-
constructor(private readonly filePath: string) {}
|
|
33
|
-
|
|
34
|
-
async load(): Promise<PairedExtensionIdentity[]> {
|
|
35
|
-
await mkdir(dirname(this.filePath), { recursive: true, mode: 0o700 })
|
|
36
|
-
|
|
37
|
-
let content: string
|
|
38
|
-
try {
|
|
39
|
-
content = await readFile(this.filePath, 'utf8')
|
|
40
|
-
} catch (error) {
|
|
41
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return []
|
|
42
|
-
throw error
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let value: unknown
|
|
46
|
-
try {
|
|
47
|
-
value = JSON.parse(content)
|
|
48
|
-
} catch (cause) {
|
|
49
|
-
throw new BridgeError('InvalidPairingState', 'Saved Bridge pairing state is not valid JSON', {
|
|
50
|
-
status: 500,
|
|
51
|
-
cause,
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const parsed = PairingStateSchema.safeParse(value)
|
|
56
|
-
if (!parsed.success) {
|
|
57
|
-
throw new BridgeError(
|
|
58
|
-
'InvalidPairingState',
|
|
59
|
-
`Saved Bridge pairing state at ${this.filePath} has an unsupported format. This pre-release version does not migrate old state automatically; update it to the version 1 clients-array format or remove it and pair Extensions again.`,
|
|
60
|
-
{ status: 500, details: parsed.error.issues },
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return parsed.data.clients
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async save(identities: PairedExtensionIdentity[]): Promise<void> {
|
|
68
|
-
const directory = dirname(this.filePath)
|
|
69
|
-
await mkdir(directory, { recursive: true, mode: 0o700 })
|
|
70
|
-
|
|
71
|
-
const temporaryPath = join(directory, `.paired-clients-${process.pid}-${randomUUID()}.tmp`)
|
|
72
|
-
const content = JSON.stringify({ version: 1, clients: identities }, null, 2)
|
|
73
|
-
let file: Awaited<ReturnType<typeof open>> | undefined
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
file = await open(temporaryPath, 'wx', 0o600)
|
|
77
|
-
await file.writeFile(content, 'utf8')
|
|
78
|
-
await file.sync()
|
|
79
|
-
await file.close()
|
|
80
|
-
file = undefined
|
|
81
|
-
await rename(temporaryPath, this.filePath)
|
|
82
|
-
} catch (error) {
|
|
83
|
-
await file?.close().catch(() => undefined)
|
|
84
|
-
await unlink(temporaryPath).catch(() => undefined)
|
|
85
|
-
throw error
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function getDefaultBridgeDataDir(home = homedir()) {
|
|
91
|
-
return join(home, '.tapicker')
|
|
92
|
-
}
|