@joshualelon/clawdbot-skill-flow 2.3.1 → 2.3.2
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 +1 -1
- package/package.json +1 -1
- package/src/hooks/google-sheets.ts +40 -7
package/README.md
CHANGED
|
@@ -437,7 +437,7 @@ export async function createWorkoutLog(session, api) {
|
|
|
437
437
|
worksheetName: 'Sessions',
|
|
438
438
|
headers: ['timestamp', 'userId', 'set1', 'set2', 'set3', 'set4', 'total'],
|
|
439
439
|
folderId: process.env.GOOGLE_DRIVE_FOLDER_ID, // Optional: move to specific folder
|
|
440
|
-
useGogOAuth: true // Use gog CLI OAuth to avoid service account quota issues (requires GOOGLE_CLIENT_ID
|
|
440
|
+
useGogOAuth: true // Use gog CLI OAuth to avoid service account quota issues (requires GOG_ACCOUNT, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET env vars)
|
|
441
441
|
});
|
|
442
442
|
|
|
443
443
|
return { spreadsheetId, spreadsheetUrl };
|
package/package.json
CHANGED
|
@@ -293,14 +293,20 @@ export async function querySheetHistory(
|
|
|
293
293
|
* Uses the gog tool's stored refresh token to get a fresh access token
|
|
294
294
|
*/
|
|
295
295
|
async function getGogAccessToken(): Promise<string> {
|
|
296
|
+
const { mkdtemp, rm, readFile } = await import('node:fs/promises');
|
|
297
|
+
const { tmpdir } = await import('node:os');
|
|
298
|
+
const { join } = await import('node:path');
|
|
299
|
+
|
|
300
|
+
let tmpDir: string | undefined;
|
|
301
|
+
|
|
296
302
|
try {
|
|
297
303
|
// Check if gog is installed
|
|
298
304
|
await execAsync('which gog');
|
|
299
305
|
|
|
300
|
-
//
|
|
301
|
-
const
|
|
302
|
-
if (!
|
|
303
|
-
throw new Error('
|
|
306
|
+
// Get gog account email from environment
|
|
307
|
+
const gogAccount = process.env.GOG_ACCOUNT;
|
|
308
|
+
if (!gogAccount) {
|
|
309
|
+
throw new Error('GOG_ACCOUNT environment variable must be set (e.g., your-email@example.com)');
|
|
304
310
|
}
|
|
305
311
|
|
|
306
312
|
// Get OAuth credentials from environment
|
|
@@ -313,6 +319,23 @@ async function getGogAccessToken(): Promise<string> {
|
|
|
313
319
|
);
|
|
314
320
|
}
|
|
315
321
|
|
|
322
|
+
// Create temp directory for token export
|
|
323
|
+
tmpDir = await mkdtemp(join(tmpdir(), 'gog-tokens-'));
|
|
324
|
+
const tokenFile = join(tmpDir, 'tokens.json');
|
|
325
|
+
|
|
326
|
+
// Export tokens from gog using proper syntax
|
|
327
|
+
await execAsync(`gog auth tokens export "${gogAccount}" --out "${tokenFile}"`);
|
|
328
|
+
|
|
329
|
+
// Read and parse the exported tokens
|
|
330
|
+
const tokenData = JSON.parse(await readFile(tokenFile, 'utf8')) as {
|
|
331
|
+
refresh_token?: string;
|
|
332
|
+
access_token?: string;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
if (!tokenData.refresh_token) {
|
|
336
|
+
throw new Error('No refresh token found in gog export');
|
|
337
|
+
}
|
|
338
|
+
|
|
316
339
|
// Exchange refresh token for access token
|
|
317
340
|
const tokenUrl = 'https://oauth2.googleapis.com/token';
|
|
318
341
|
const response = await fetch(tokenUrl, {
|
|
@@ -321,13 +344,14 @@ async function getGogAccessToken(): Promise<string> {
|
|
|
321
344
|
body: JSON.stringify({
|
|
322
345
|
client_id: clientId,
|
|
323
346
|
client_secret: clientSecret,
|
|
324
|
-
refresh_token:
|
|
347
|
+
refresh_token: tokenData.refresh_token,
|
|
325
348
|
grant_type: 'refresh_token',
|
|
326
349
|
}),
|
|
327
350
|
});
|
|
328
351
|
|
|
329
352
|
if (!response.ok) {
|
|
330
|
-
|
|
353
|
+
const errorText = await response.text();
|
|
354
|
+
throw new Error(`OAuth token exchange failed: ${response.statusText} - ${errorText}`);
|
|
331
355
|
}
|
|
332
356
|
|
|
333
357
|
const data = await response.json() as { access_token: string };
|
|
@@ -335,8 +359,17 @@ async function getGogAccessToken(): Promise<string> {
|
|
|
335
359
|
} catch (error) {
|
|
336
360
|
throw new Error(
|
|
337
361
|
`Failed to get OAuth access token from gog: ${error instanceof Error ? error.message : String(error)}. ` +
|
|
338
|
-
`Ensure gog CLI is installed and
|
|
362
|
+
`Ensure gog CLI is installed, authenticated, and GOG_ACCOUNT env var is set.`
|
|
339
363
|
);
|
|
364
|
+
} finally {
|
|
365
|
+
// Clean up temp directory
|
|
366
|
+
if (tmpDir) {
|
|
367
|
+
try {
|
|
368
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
369
|
+
} catch {
|
|
370
|
+
// Ignore cleanup errors
|
|
371
|
+
}
|
|
372
|
+
}
|
|
340
373
|
}
|
|
341
374
|
}
|
|
342
375
|
|