@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.
Files changed (49) hide show
  1. package/README.md +15 -15
  2. package/dist/bridge/bridge-service.d.ts +1 -1
  3. package/dist/bridge/bridge-service.js +7 -7
  4. package/dist/bridge/control.js +1 -1
  5. package/dist/bridge/export-store.d.ts +35 -0
  6. package/dist/bridge/export-store.js +195 -0
  7. package/dist/bridge/extension-session.d.ts +9 -2
  8. package/dist/bridge/extension-session.js +56 -8
  9. package/dist/cli.js +563 -148
  10. package/dist/commands.d.ts +8 -0
  11. package/dist/commands.js +276 -40
  12. package/dist/constants.d.ts +2 -2
  13. package/dist/constants.js +4 -2
  14. package/dist/http-client.d.ts +24 -0
  15. package/dist/http-client.js +101 -0
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +2 -2
  18. package/dist/mcp.d.ts +4 -3
  19. package/dist/mcp.js +221 -134
  20. package/dist/protocol/schema.d.ts +503 -34
  21. package/dist/protocol/schema.js +396 -15
  22. package/dist/server.d.ts +7 -4
  23. package/dist/server.js +70 -26
  24. package/dist/update-notifier-worker.d.ts +2 -0
  25. package/dist/update-notifier-worker.js +3 -0
  26. package/dist/update-notifier.d.ts +9 -0
  27. package/dist/update-notifier.js +178 -0
  28. package/dist/workflow-watch.d.ts +8 -7
  29. package/dist/workflow-watch.js +39 -29
  30. package/package.json +16 -6
  31. package/docs/cli.md +0 -112
  32. package/docs/http-api.md +0 -149
  33. package/docs/mcp.md +0 -90
  34. package/docs/operations.md +0 -85
  35. package/docs/workflow-watch.md +0 -86
  36. package/src/bridge/bridge-service.ts +0 -291
  37. package/src/bridge/control.ts +0 -281
  38. package/src/bridge/daemon.ts +0 -102
  39. package/src/bridge/extension-session.ts +0 -286
  40. package/src/bridge/pairing-state.ts +0 -92
  41. package/src/cli.ts +0 -1019
  42. package/src/commands.ts +0 -158
  43. package/src/constants.ts +0 -10
  44. package/src/errors.ts +0 -72
  45. package/src/index.ts +0 -35
  46. package/src/mcp.ts +0 -386
  47. package/src/protocol/schema.ts +0 -202
  48. package/src/server.ts +0 -623
  49. 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
- }