ticlawk 0.1.12 → 0.1.14
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 +4 -4
- package/bin/ticlawk.mjs +3 -4
- package/package.json +1 -1
- package/scripts/postinstall.mjs +10 -5
- package/src/adapters/ticlawk/credentials.mjs +2 -5
- package/src/adapters/ticlawk/index.mjs +3 -3
- package/src/core/bindings/store.mjs +2 -2
- package/src/core/config.mjs +2 -34
- package/src/core/uninstall.mjs +5 -5
package/README.md
CHANGED
|
@@ -253,7 +253,7 @@ ticlawk connect
|
|
|
253
253
|
systemd linger is off, it prints the same `Action required` message shown by
|
|
254
254
|
the installer.
|
|
255
255
|
|
|
256
|
-
Update with `ticlawk update`. To remove the service and
|
|
256
|
+
Update with `ticlawk update`. To remove the service and managed
|
|
257
257
|
install files while keeping `~/.ticlawk` config, bindings, profiles, and
|
|
258
258
|
logs:
|
|
259
259
|
|
|
@@ -263,8 +263,8 @@ ticlawk uninstall
|
|
|
263
263
|
|
|
264
264
|
That removes:
|
|
265
265
|
|
|
266
|
-
-
|
|
267
|
-
-
|
|
266
|
+
- `~/.local/share/ticlawk`
|
|
267
|
+
- `~/.local/bin/ticlawk`
|
|
268
268
|
- `~/.config/systemd/user/ticlawk.service` (Linux)
|
|
269
269
|
- `~/Library/LaunchAgents/ticlawk.plist` (macOS)
|
|
270
270
|
|
|
@@ -340,7 +340,7 @@ Commands:
|
|
|
340
340
|
profile list or switch saved local identities
|
|
341
341
|
install-daemon install or refresh the background daemon
|
|
342
342
|
update update the npm package and refresh the daemon
|
|
343
|
-
uninstall remove service and
|
|
343
|
+
uninstall remove service and managed install files, preserving ~/.ticlawk
|
|
344
344
|
|
|
345
345
|
Config examples:
|
|
346
346
|
ticlawk config get adapter
|
package/bin/ticlawk.mjs
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
getConfiguredAdapter,
|
|
9
9
|
loadPersistentConfig,
|
|
10
10
|
getStreamingConfigView,
|
|
11
|
-
LEGACY_TICLAWK_API_KEY,
|
|
12
11
|
normalizeAdapterConfigTarget,
|
|
13
12
|
normalizeAdapterName,
|
|
14
13
|
normalizeRuntimeConfigTarget,
|
|
@@ -109,7 +108,7 @@ Commands:
|
|
|
109
108
|
profile list or switch saved local identities
|
|
110
109
|
install-daemon install or refresh the background daemon
|
|
111
110
|
update update the npm package and refresh the daemon
|
|
112
|
-
uninstall remove service and
|
|
111
|
+
uninstall remove service and managed install files, preserving ~/.ticlawk
|
|
113
112
|
|
|
114
113
|
Config examples:
|
|
115
114
|
ticlawk config get adapter
|
|
@@ -227,7 +226,7 @@ function printConfigView(config = loadPersistentConfig()) {
|
|
|
227
226
|
console.log(`${runtime.executableCliKey}=${config[runtime.executableConfigKey] || ''}`);
|
|
228
227
|
}
|
|
229
228
|
console.log(`telegram.bot-token=${config.TELEGRAM_BOT_TOKEN ? 'set' : 'unset'}`);
|
|
230
|
-
console.log(`ticlawk.connector-api-key=${config[TICLAWK_CONNECTOR_API_KEY]
|
|
229
|
+
console.log(`ticlawk.connector-api-key=${config[TICLAWK_CONNECTOR_API_KEY] ? 'set' : 'unset'}`);
|
|
231
230
|
console.log(`ticlawk.api-url=${config.TICLAWK_API_URL || ''}`);
|
|
232
231
|
console.log(`ticlawk.connector-ws-url=${config[TICLAWK_CONNECTOR_WS_URL] || ''}`);
|
|
233
232
|
}
|
|
@@ -257,7 +256,7 @@ function getLocal(path) {
|
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
function formatSecretConfigValue(configKey, value) {
|
|
260
|
-
if (configKey === 'TELEGRAM_BOT_TOKEN' || configKey === TICLAWK_CONNECTOR_API_KEY
|
|
259
|
+
if (configKey === 'TELEGRAM_BOT_TOKEN' || configKey === TICLAWK_CONNECTOR_API_KEY) {
|
|
261
260
|
return value ? 'set' : 'unset';
|
|
262
261
|
}
|
|
263
262
|
return value || '';
|
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -22,11 +22,16 @@ function runSetupReadiness(cliScript) {
|
|
|
22
22
|
if (process.env.npm_config_global === 'true') {
|
|
23
23
|
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
24
24
|
const cliScript = join(packageRoot, 'bin', 'ticlawk.mjs');
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const oldDataHome = join(homedir(), '.agent-freeway');
|
|
26
|
+
const newDataHome = join(homedir(), '.ticlawk');
|
|
27
|
+
const oldConfigPath = join(oldDataHome, '.config');
|
|
28
|
+
const newConfigPath = join(newDataHome, '.config');
|
|
29
|
+
if (existsSync(oldConfigPath) && !existsSync(newConfigPath)) {
|
|
30
|
+
if (existsSync(newDataHome)) {
|
|
31
|
+
renameSync(newDataHome, `${newDataHome}.pre-migration.${Date.now()}`);
|
|
32
|
+
}
|
|
33
|
+
renameSync(oldDataHome, newDataHome);
|
|
34
|
+
console.log(`ticlawk: migrated ${oldDataHome} to ${newDataHome}`);
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
runSetupReadiness(cliScript);
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The ticlawk connect flow returns a `tk_...` bearer key in response to
|
|
5
5
|
* a local adapter connect call. We persist it to `~/.ticlawk/.config`
|
|
6
|
-
* using the connector-specific env name
|
|
7
|
-
* `TICLAWK_API_KEY` without being polluted by ticlawk.
|
|
6
|
+
* using the connector-specific env name.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
|
-
import { AF_ADAPTER_KEY, AF_CONFIG_PATH,
|
|
9
|
+
import { AF_ADAPTER_KEY, AF_CONFIG_PATH, persistConfig, TICLAWK_CONNECTOR_API_KEY } from '../../core/config.mjs';
|
|
11
10
|
|
|
12
11
|
export function persistApiCredential(apiKey) {
|
|
13
12
|
if (!apiKey || !apiKey.startsWith('tk_')) return;
|
|
@@ -15,11 +14,9 @@ export function persistApiCredential(apiKey) {
|
|
|
15
14
|
persistConfig({
|
|
16
15
|
[AF_ADAPTER_KEY]: 'ticlawk',
|
|
17
16
|
[TICLAWK_CONNECTOR_API_KEY]: apiKey,
|
|
18
|
-
[LEGACY_TICLAWK_API_KEY]: '',
|
|
19
17
|
TICLAWK_SETUP_CODE: '',
|
|
20
18
|
});
|
|
21
19
|
process.env[TICLAWK_CONNECTOR_API_KEY] = apiKey;
|
|
22
|
-
delete process.env[LEGACY_TICLAWK_API_KEY];
|
|
23
20
|
delete process.env.TICLAWK_SETUP_CODE;
|
|
24
21
|
console.log(`[connect] saved ${TICLAWK_CONNECTOR_API_KEY} to ${AF_CONFIG_PATH}`);
|
|
25
22
|
}
|
|
@@ -2,7 +2,7 @@ import { parseOptionArgs } from '../../core/argv.mjs';
|
|
|
2
2
|
import { createHash, randomBytes } from 'node:crypto';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
|
-
import { AF_ADAPTER_KEY,
|
|
5
|
+
import { AF_ADAPTER_KEY, loadPersistentConfig, persistConfig, TICLAWK_CONNECTOR_API_KEY, TICLAWK_CONNECTOR_WS_URL } from '../../core/config.mjs';
|
|
6
6
|
import { belongsToRuntimeHost, getBindingRuntimeHostId, getHostId, getHostLabel } from '../../core/host-id.mjs';
|
|
7
7
|
import { debugError, debugLog } from '../../core/logger.mjs';
|
|
8
8
|
import { getActiveProfile, ensureLegacyProfile, readProfileMeta, saveAndActivateProfile } from '../../core/profiles.mjs';
|
|
@@ -974,7 +974,7 @@ export function createTiclawkAdapter(ctx) {
|
|
|
974
974
|
const runtimesHealth = Object.fromEntries(runtimeHealthEntries);
|
|
975
975
|
const codexHealth = runtimesHealth.codex || {};
|
|
976
976
|
return {
|
|
977
|
-
apiKey: Boolean(process.env[TICLAWK_CONNECTOR_API_KEY] || config[TICLAWK_CONNECTOR_API_KEY]
|
|
977
|
+
apiKey: Boolean(process.env[TICLAWK_CONNECTOR_API_KEY] || config[TICLAWK_CONNECTOR_API_KEY]),
|
|
978
978
|
wakeUrl: api.getConnectorWsUrl(),
|
|
979
979
|
wakeConnected: Boolean(connectorSocket?.isConnected()),
|
|
980
980
|
wakeLastStatus: wakeState.lastStatus,
|
|
@@ -1014,7 +1014,7 @@ export function createTiclawkAdapter(ctx) {
|
|
|
1014
1014
|
currentIdentity = readProfileMeta(activeProfile.adapter, activeProfile.userId) || {
|
|
1015
1015
|
userId: activeProfile.userId,
|
|
1016
1016
|
};
|
|
1017
|
-
} else if (config[TICLAWK_CONNECTOR_API_KEY]
|
|
1017
|
+
} else if (config[TICLAWK_CONNECTOR_API_KEY]) {
|
|
1018
1018
|
try {
|
|
1019
1019
|
const me = await api.getMe();
|
|
1020
1020
|
if (me?.userId || me?.user_id) {
|
|
@@ -3,11 +3,11 @@ import { AF_HOME } from '../config.mjs';
|
|
|
3
3
|
import { JsonFileStore } from '../store/json-file-store.mjs';
|
|
4
4
|
import { getActiveBindingsPath } from '../profiles.mjs';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const ROOT_BINDINGS_PATH = join(AF_HOME, 'bindings.json');
|
|
7
7
|
const stores = new Map();
|
|
8
8
|
|
|
9
9
|
function getStore() {
|
|
10
|
-
const filePath = getActiveBindingsPath(
|
|
10
|
+
const filePath = getActiveBindingsPath(ROOT_BINDINGS_PATH);
|
|
11
11
|
let store = stores.get(filePath);
|
|
12
12
|
if (!store) {
|
|
13
13
|
store = new JsonFileStore(filePath, []);
|
package/src/core/config.mjs
CHANGED
|
@@ -8,24 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import dotenv from 'dotenv';
|
|
11
|
-
import { existsSync, mkdirSync, readFileSync,
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import { homedir } from 'node:os';
|
|
13
13
|
import { dirname, join } from 'node:path';
|
|
14
14
|
import { RUNTIME_DEFINITIONS, normalizeServiceType } from './runtime-registry.mjs';
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
const LEGACY_AGENT_FREEWAY_HOME = join(homedir(), '.agent-freeway');
|
|
18
|
-
|
|
19
|
-
function resolveTiclawkHome() {
|
|
20
|
-
if (process.env.TICLAWK_HOME) return process.env.TICLAWK_HOME;
|
|
21
|
-
if (!existsSync(DEFAULT_TICLAWK_HOME) && existsSync(LEGACY_AGENT_FREEWAY_HOME)) {
|
|
22
|
-
renameSync(LEGACY_AGENT_FREEWAY_HOME, DEFAULT_TICLAWK_HOME);
|
|
23
|
-
}
|
|
24
|
-
if (existsSync(DEFAULT_TICLAWK_HOME)) return DEFAULT_TICLAWK_HOME;
|
|
25
|
-
return DEFAULT_TICLAWK_HOME;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const AF_HOME = resolveTiclawkHome();
|
|
16
|
+
export const AF_HOME = process.env.TICLAWK_HOME || join(homedir(), '.ticlawk');
|
|
29
17
|
export const AF_CONFIG_PATH = join(AF_HOME, '.config');
|
|
30
18
|
export const AF_LOG_PATH = join(AF_HOME, 'ticlawk.log');
|
|
31
19
|
export const AF_CRASH_LOG_PATH = join(AF_HOME, 'ticlawk-crash.log');
|
|
@@ -38,7 +26,6 @@ export const AF_STREAMING_RUNTIME_KEYS = Object.fromEntries(
|
|
|
38
26
|
);
|
|
39
27
|
export const TICLAWK_CONNECTOR_API_KEY = 'TICLAWK_CONNECTOR_API_KEY';
|
|
40
28
|
export const TICLAWK_CONNECTOR_WS_URL = 'TICLAWK_CONNECTOR_WS_URL';
|
|
41
|
-
export const LEGACY_TICLAWK_API_KEY = 'TICLAWK_API_KEY';
|
|
42
29
|
export const RUNTIME_EXECUTABLE_CONFIG_KEYS = Object.fromEntries(
|
|
43
30
|
RUNTIME_DEFINITIONS
|
|
44
31
|
.filter((runtime) => runtime.executableConfigKey)
|
|
@@ -129,25 +116,6 @@ export function persistConfig(updates) {
|
|
|
129
116
|
}
|
|
130
117
|
}
|
|
131
118
|
|
|
132
|
-
export function migrateLegacyTiclawkConnectorKey() {
|
|
133
|
-
const current = loadPersistentConfig();
|
|
134
|
-
const legacyKey = current[LEGACY_TICLAWK_API_KEY];
|
|
135
|
-
if (!legacyKey) return false;
|
|
136
|
-
|
|
137
|
-
const updates = {
|
|
138
|
-
[LEGACY_TICLAWK_API_KEY]: '',
|
|
139
|
-
};
|
|
140
|
-
if (!current[TICLAWK_CONNECTOR_API_KEY]) {
|
|
141
|
-
updates[TICLAWK_CONNECTOR_API_KEY] = legacyKey;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
persistConfig(updates);
|
|
145
|
-
delete process.env[LEGACY_TICLAWK_API_KEY];
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
migrateLegacyTiclawkConnectorKey();
|
|
150
|
-
|
|
151
119
|
function parseBooleanish(value) {
|
|
152
120
|
if (value === undefined || value === null || value === '') return null;
|
|
153
121
|
const normalized = String(value).trim().toLowerCase();
|
package/src/core/uninstall.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Service and
|
|
2
|
+
* Service and managed install cleanup.
|
|
3
3
|
*
|
|
4
|
-
* Removes the user service and
|
|
4
|
+
* Removes the user service and managed-install files while preserving
|
|
5
5
|
* ~/.ticlawk by default. The npm package is owned by npm.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -82,12 +82,12 @@ function uninstallLaunchd() {
|
|
|
82
82
|
export function getUninstallHelp() {
|
|
83
83
|
return `ticlawk uninstall
|
|
84
84
|
|
|
85
|
-
Remove the ticlawk service and
|
|
85
|
+
Remove the ticlawk service and managed install files while preserving local data.
|
|
86
86
|
|
|
87
87
|
Removes:
|
|
88
88
|
- user service: systemd on Linux, launchd on macOS
|
|
89
89
|
- CLI wrapper: ~/.local/bin/ticlawk
|
|
90
|
-
-
|
|
90
|
+
- managed install files: ~/.local/share/ticlawk
|
|
91
91
|
|
|
92
92
|
Preserves:
|
|
93
93
|
- ~/.ticlawk
|
|
@@ -107,7 +107,7 @@ export async function runSelfUninstall(skipPrompt) {
|
|
|
107
107
|
|
|
108
108
|
console.log('ticlawk uninstall');
|
|
109
109
|
console.log('will remove the user service');
|
|
110
|
-
console.log(`will remove
|
|
110
|
+
console.log(`will remove managed install files under: ${installRoot}`);
|
|
111
111
|
console.log(`will remove CLI wrapper: ${wrapperPath}`);
|
|
112
112
|
console.log(`will preserve data directory: ${AF_HOME}`);
|
|
113
113
|
|