@relayhistory/provider-sources 0.18.2 → 0.18.8

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.
@@ -0,0 +1,12 @@
1
+ import { type ChildProcess } from 'node:child_process';
2
+ export interface HelperOptions {
3
+ binaryPath?: string;
4
+ signal?: AbortSignal;
5
+ timeoutMs?: number;
6
+ }
7
+ /** Only terminate the process tree rooted at the helper we created. POSIX
8
+ * helpers lead a fresh process group; Windows uses taskkill's PID-scoped tree.
9
+ * Cancellation is not complete until the helper's stdio/process is reaped. */
10
+ export declare function terminateHelperTree(child: ChildProcess, closed: Promise<void>, isClosed: () => boolean): Promise<void>;
11
+ export declare function helperRequest<T>(operation: string, args?: Record<string, unknown>, options?: HelperOptions): Promise<T>;
12
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAK9D,MAAM,WAAW,aAAa;IAAG,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;AAMhG;;8EAE8E;AAC9E,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgC5H;AACD,wBAAsB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,CAkDrI"}
package/dist/helper.js ADDED
@@ -0,0 +1,143 @@
1
+ /** Bounded, cancellable bridge to the optional provider-source Rust executable. */
2
+ import { StringDecoder } from 'node:string_decoder';
3
+ import { spawn } from 'node:child_process';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { createRequire } from 'node:module';
6
+ import { dirname, join } from 'node:path';
7
+ import { RelayHistoryError, InvalidArgumentError, UnsupportedOperationError, AuthenticationExpiredError, ConnectorFailureError, runtimePlatform } from 'ai-hist';
8
+ function packagedBinary() {
9
+ const binary = 'history-provider-sources' + (process.platform === 'win32' ? '.exe' : '');
10
+ try {
11
+ return join(dirname(createRequire(import.meta.url).resolve('@relayhistory/provider-sources-' + runtimePlatform() + '/package.json')), binary);
12
+ }
13
+ catch {
14
+ return fileURLToPath(new URL('../bin/' + runtimePlatform() + '/' + binary, import.meta.url));
15
+ }
16
+ }
17
+ /** Only terminate the process tree rooted at the helper we created. POSIX
18
+ * helpers lead a fresh process group; Windows uses taskkill's PID-scoped tree.
19
+ * Cancellation is not complete until the helper's stdio/process is reaped. */
20
+ export async function terminateHelperTree(child, closed, isClosed) {
21
+ if (isClosed())
22
+ return;
23
+ let deadline;
24
+ try {
25
+ await Promise.race([
26
+ (async () => {
27
+ if (child.pid !== undefined) {
28
+ if (process.platform === 'win32') {
29
+ // Do not target a potentially reused PID after observing its exit.
30
+ if (child.exitCode !== null || child.signalCode !== null)
31
+ throw new Error('Helper exited before tree cleanup');
32
+ await new Promise((resolve, reject) => {
33
+ const killer = spawn(join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'taskkill.exe'), ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' });
34
+ const limit = setTimeout(() => { killer.kill(); reject(new Error('Tree cleanup timed out')); }, 2000);
35
+ killer.once('error', () => { clearTimeout(limit); reject(new Error('Tree cleanup unavailable')); });
36
+ killer.once('close', code => { clearTimeout(limit); if (code === 0)
37
+ resolve();
38
+ else
39
+ reject(new Error('Tree cleanup failed')); });
40
+ });
41
+ }
42
+ else {
43
+ try {
44
+ process.kill(-child.pid, 'SIGKILL');
45
+ }
46
+ catch (error) {
47
+ if (error.code !== 'ESRCH')
48
+ throw error;
49
+ }
50
+ }
51
+ }
52
+ await closed;
53
+ })(),
54
+ new Promise((_resolve, reject) => { deadline = setTimeout(() => reject(new Error('Helper cleanup timed out')), 3000); }),
55
+ ]);
56
+ }
57
+ catch {
58
+ // Release our handles even if a broken/escaping subprocess does not close
59
+ // inherited pipes. Report failed cleanup instead of promising cancellation.
60
+ if (child.exitCode === null && child.signalCode === null)
61
+ child.kill('SIGKILL');
62
+ child.stdin?.destroy();
63
+ child.stdout?.destroy();
64
+ child.stderr?.destroy();
65
+ child.unref();
66
+ throw new RelayHistoryError('Helper process tree cleanup failed', 'HISTORY_PLUGIN_CLEANUP_FAILED');
67
+ }
68
+ finally {
69
+ if (deadline !== undefined)
70
+ clearTimeout(deadline);
71
+ }
72
+ }
73
+ export async function helperRequest(operation, args = {}, options = {}) {
74
+ options.signal?.throwIfAborted();
75
+ const body = JSON.stringify({ version: 1, operation, args });
76
+ if (Buffer.byteLength(body) > 16 * 1_048_576)
77
+ throw new InvalidArgumentError('Provider source helper request exceeds 16 MiB', 'INVALID_ARGUMENT');
78
+ const executable = options.binaryPath ?? process.env.HISTORY_PROVIDER_SOURCES_BIN
79
+ ?? packagedBinary();
80
+ return new Promise((resolve, reject) => {
81
+ const child = spawn(executable, [], { stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true, detached: process.platform !== 'win32' });
82
+ const decoder = new StringDecoder('utf8');
83
+ let output = '';
84
+ let bytes = 0;
85
+ let settled = false;
86
+ let closed = false;
87
+ const childClosed = new Promise(resolve => child.once('close', () => { closed = true; resolve(); }));
88
+ const finish = (error, value) => {
89
+ if (settled)
90
+ return;
91
+ settled = true;
92
+ clearTimeout(timer);
93
+ options.signal?.removeEventListener('abort', abort);
94
+ if (error) {
95
+ void terminateHelperTree(child, childClosed, () => closed).then(() => reject(error), reject);
96
+ }
97
+ else
98
+ resolve(value);
99
+ };
100
+ const abort = () => finish(new RelayHistoryError('Provider source helper operation cancelled', 'HISTORY_PLUGIN_CANCELLED'));
101
+ const timer = setTimeout(() => finish(new RelayHistoryError('Provider source helper operation timed out', 'HISTORY_PLUGIN_TIMEOUT')), options.timeoutMs ?? 60_000);
102
+ options.signal?.addEventListener('abort', abort, { once: true });
103
+ child.on('error', () => finish(new RelayHistoryError('Provider source helper is unavailable; install its matching platform artifact', 'HISTORY_PLUGIN_BINARY_MISSING')));
104
+ child.stdin.on('error', () => finish(new RelayHistoryError('Provider source helper input failed', 'HISTORY_PLUGIN_PROTOCOL_FAILED')));
105
+ // Never forward arbitrary stderr, which could contain auth or history.
106
+ child.stderr.resume();
107
+ child.stdout.on('data', (chunk) => {
108
+ bytes += chunk.length;
109
+ if (bytes > 32 * 1_048_576)
110
+ return finish(new RelayHistoryError('Provider source helper response exceeds 32 MiB', 'HISTORY_PLUGIN_PROTOCOL_FAILED'));
111
+ output += decoder.write(chunk);
112
+ });
113
+ child.on('close', code => {
114
+ if (settled)
115
+ return;
116
+ try {
117
+ if (code !== 0)
118
+ throw new Error();
119
+ const envelope = JSON.parse(output + decoder.end());
120
+ if (envelope.version !== 1 || typeof envelope.ok !== 'boolean')
121
+ throw new Error();
122
+ if (!envelope.ok) {
123
+ const code = envelope.error?.code;
124
+ if (typeof code !== 'string' || !/^[A-Z_]{1,100}$/.test(code))
125
+ throw new Error();
126
+ // Stable public classes come from the installed local SDK instance.
127
+ const ErrorType = code === 'INVALID_ARGUMENT' ? InvalidArgumentError
128
+ : code === 'UNSUPPORTED_OPERATION' ? UnsupportedOperationError
129
+ : code === 'AUTHENTICATION_EXPIRED' ? AuthenticationExpiredError
130
+ : code === 'CONNECTOR_FAILURE' ? ConnectorFailureError : RelayHistoryError;
131
+ finish(new ErrorType(`Provider source operation failed (${code})`, code));
132
+ }
133
+ else
134
+ finish(undefined, envelope.value);
135
+ }
136
+ catch {
137
+ finish(new RelayHistoryError('Provider source helper returned an invalid response', 'HISTORY_PLUGIN_PROTOCOL_FAILED'));
138
+ }
139
+ });
140
+ child.st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,MAAM,CAAC,IAAI,SAAS,CAAC,qCAAqC,IAAI,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC5E,CAAC;;oBAAM,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC3C,CAAC;YAAC,MAAM,CAAC;gBAAC,MAAM,CAAC,IAAI,iBAAiB,CAAC,qDAAqD,EAAE,gCAAgC,CAAC,CAAC,CAAC;YAAC,CAAC;QACrI,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type HistoryPlugin } from 'ai-hist';
2
+ import { type HelperOptions } from './helper.js';
3
+ export interface ProviderSourceOptions extends HelperOptions {
4
+ connectors?: Array<'claude-web' | 'codex-cloud'>;
5
+ instanceId?: string;
6
+ }
7
+ /** Registration is inert; provider credentials are read only by selected acquisitions. */
8
+ export declare function createHistoryPlugin(options?: ProviderSourceOptions): HistoryPlugin;
9
+ export type { HistorySource } from 'ai-hist';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAInB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,UAAU,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,aAAa,CAAC,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AACD,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,qBAA0B,GAAG,aAAa,CAkCtF;AACD,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ import { InvalidArgumentError, } from 'ai-hist';
2
+ import { helperRequest } from './helper.js';
3
+ /** Registration is inert; provider credentials are read only by selected acquisitions. */
4
+ export function createHistoryPlugin(options = {}) {
5
+ const connectors = options.connectors ?? ['claude-web', 'codex-cloud'];
6
+ if (!Array.isArray(connectors) ||
7
+ connectors.some((id) => id !== 'claude-web' && id !== 'codex-cloud') ||
8
+ new Set(connectors).size !== connectors.length)
9
+ throw new InvalidArgumentError('Provider connectors must be unique claude-web or codex-cloud IDs', 'INVALID_ARGUMENT');
10
+ const sources = connectors.map((connectorId) => {
11
+ const source = connectorId === 'claude-web' ? 'claude' : 'codex';
12
+ const connectorInstance = options.instanceId ?? 'default';
13
+ return {
14
+ id: connectorId,
15
+ instanceId: connectorInstance,
16
+ location: 'remote',
17
+ supportedSources: [source],
18
+ discover: async (query) => helperRequest('discover', { connectorId, connectorInstance, source, limit: query.limit }, { ...options, signal: query.signal, timeoutMs: query.acquisitionTimeoutMs ?? options.timeoutMs }),
19
+ hydrate: async (observation, context) => helperRequest('hydrate', { connectorId, connectorInstance, observation }, { ...options, signal: context.signal, timeoutMs: context.acquisitionTimeoutMs ?? options.timeoutMs }),
20
+ };
21
+ });
22
+ return { sources };
23
+ }
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAMrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAC;AAKhE,0FAA0F;AAC1F,MAAM,UAAU,mBAAmB,CAAC,UAAiC,EAAE;IACrE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IACvE,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAC1B,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KA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MappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import { HistoryPluginRegistry, InvalidArgumentError } from 'ai-hist';
4
+ import { createHistoryPlugin } from './index.js';
5
+ import { helperRequest } from './helper.js';
6
+ test('provider package registration is inert and connector IDs are selected explicitly', () => {
7
+ const registry = new HistoryPluginRegistry();
8
+ registry.register(createHistoryPlugin({ binaryPath: '/fixture/must-not-run' }));
9
+ assert.deepEqual(registry.sourceConnectors(['claude-web']).map((source) => source.id), ['claude-web']);
10
+ assert.deepEqual(registry.sourceConnectors([]), []);
11
+ assert.throws(() => createHistoryPlugin({ connectors: ['claude-web', 'claude-web'] }), InvalidArgumentError);
12
+ });
13
+ test('actual provider helper rejects invalid selector before provider credential access', async () => {
14
+ await assert.rejects(helperRequest('discover', { connectorId: 'fixture-not-a-provider' }), (error) => error instanceof InvalidArgumentError);
15
+ });
16
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,IAAI,CAAC,kFAAkF,EAAE,GAAG,EAAE;IAC5F,MAAM,QAAQ,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,UAAU,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC;IAChF,MAAM,CAAC,SAAS,CACd,QAAQ,CAAC,gBAAgB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EACpE,CAAC,YAAY,CAAC,CACf,CAAC;IACF,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,mBAAmB,CAAC,EAAE,UAAU,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC,EAAE,CAAC,EACvE,oBAAoB,CACrB,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,mFAAmF,EAAE,KAAK,IAAI,EAAE;IACnG,MAAM,MAAM,CAAC,OAAO,CAClB,aAAa,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC,EACpE,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,YAAY,oBAAoB,CAC1D,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@relayhistory/provider-sources",
3
- "version": "0.18.2",
3
+ "version": "0.18.8",
4
4
  "description": "Optional Claude web and Codex cloud source adapters for local ai-hist.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/AgentWorkforce/relayhistory",
8
+ "directory": "plugins/provider-sources/sdk"
9
+ },
5
10
  "license": "MIT",
6
11
  "type": "module",
7
12
  "main": "dist/index.js",
@@ -24,7 +29,7 @@
24
29
  "test": "npm run build && node --test dist/*.test.js"
25
30
  },
26
31
  "peerDependencies": {
27
- "ai-hist": "^0.18.2"
32
+ "ai-hist": "^0.18.8"
28
33
  },
29
34
  "devDependencies": {
30
35
  "ai-hist": "file:../../../sdk-ts",
@@ -35,13 +40,13 @@
35
40
  "node": ">=20"
36
41
  },
37
42
  "optionalDependencies": {
38
- "@relayhistory/provider-sources-darwin-arm64": "0.18.2",
39
- "@relayhistory/provider-sources-darwin-x64": "0.18.2",
40
- "@relayhistory/provider-sources-linux-x64-gnu": "0.18.2",
41
- "@relayhistory/provider-sources-linux-arm64-gnu": "0.18.2",
42
- "@relayhistory/provider-sources-linux-x64-musl": "0.18.2",
43
- "@relayhistory/provider-sources-linux-arm64-musl": "0.18.2",
44
- "@relayhistory/provider-sources-win32-x64-msvc": "0.18.2"
43
+ "@relayhistory/provider-sources-darwin-arm64": "0.18.8",
44
+ "@relayhistory/provider-sources-darwin-x64": "0.18.8",
45
+ "@relayhistory/provider-sources-linux-x64-gnu": "0.18.8",
46
+ "@relayhistory/provider-sources-linux-arm64-gnu": "0.18.8",
47
+ "@relayhistory/provider-sources-linux-x64-musl": "0.18.8",
48
+ "@relayhistory/provider-sources-linux-arm64-musl": "0.18.8",
49
+ "@relayhistory/provider-sources-win32-x64-msvc": "0.18.8"
45
50
  },
46
51
  "publishConfig": {
47
52
  "access": "public"