gipity 1.1.7 → 1.1.9
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/dist/agents/agy.js +31 -0
- package/dist/agents/claude-code.js +21 -0
- package/dist/agents/codex.js +21 -0
- package/dist/agents/grok.js +38 -0
- package/dist/agents/types.js +6 -17
- package/dist/capture/sources/agy.js +77 -13
- package/dist/client-context.js +17 -21
- package/dist/commands/add.js +49 -8
- package/dist/commands/brand.js +5 -1
- package/dist/commands/build.js +26 -12
- package/dist/commands/db.js +6 -1
- package/dist/commands/email.js +12 -8
- package/dist/commands/file.js +5 -1
- package/dist/commands/generate.js +25 -30
- package/dist/commands/init.js +3 -2
- package/dist/commands/page-eval.js +11 -3
- package/dist/commands/skill.js +158 -24
- package/dist/commands/uninstall.js +14 -72
- package/dist/commands/upload.js +8 -11
- package/dist/hooks/capture-runner.js +35 -50
- package/dist/index.js +2854 -2002
- package/dist/provider-docs.js +1 -1
- package/dist/relay/diagnostics.js +13 -11
- package/dist/setup.js +83 -2
- package/dist/utils.js +20 -7
- package/package.json +2 -2
|
@@ -48,45 +48,17 @@ import { getDevice } from '../relay/state.js';
|
|
|
48
48
|
import { deviceFetch } from '../relay/device-http.js';
|
|
49
49
|
import { ImageBlockRewriter } from '../relay/media-upload.js';
|
|
50
50
|
import { getConfig } from '../config.js';
|
|
51
|
-
import {
|
|
52
|
-
import { parseTranscript as parseCodexTranscript } from '../capture/sources/codex.js';
|
|
53
|
-
import { parseTranscript as parseGrokTranscript } from '../capture/sources/grok.js';
|
|
54
|
-
import { parseTranscript as parseAgyTranscript } from '../capture/sources/agy.js';
|
|
51
|
+
import { AGENT_ADAPTERS } from '../agents/index.js';
|
|
55
52
|
const CAPTURE_DIR = join(homedir(), '.gipity', 'capture-state');
|
|
56
53
|
const INGEST_BATCH_MAX = 100; // server caps at 200; stay comfortably under
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
displayName: 'Codex',
|
|
66
|
-
// Codex hook payloads always carry transcript_path (the rollout file).
|
|
67
|
-
parse: (content, afterUuid) => parseCodexTranscript(content, afterUuid),
|
|
68
|
-
},
|
|
69
|
-
grok: {
|
|
70
|
-
serverSource: 'grok',
|
|
71
|
-
displayName: 'Grok',
|
|
72
|
-
parse: (content, afterUuid, hook) => parseGrokTranscript(content, afterUuid, { sessionId: hook.session_id }),
|
|
73
|
-
// Grok's session dir is derivable: ~/.grok/sessions/<urlencoded-cwd>/<sid>/
|
|
74
|
-
resolveTranscriptPath: (hook) => {
|
|
75
|
-
if (!hook.session_id)
|
|
76
|
-
return null;
|
|
77
|
-
const cwd = hook.cwd ?? process.cwd();
|
|
78
|
-
return join(homedir(), '.grok', 'sessions', encodeURIComponent(cwd), hook.session_id, 'chat_history.jsonl');
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
agy: {
|
|
82
|
-
serverSource: 'agy',
|
|
83
|
-
displayName: 'Antigravity',
|
|
84
|
-
// agy hook payloads always carry transcriptPath directly (no derivation
|
|
85
|
-
// needed, unlike Grok) - the agy-specific hook wrapper normalizes it into
|
|
86
|
-
// this HookInput's transcript_path before invoking this runner.
|
|
87
|
-
parse: (content, afterUuid, hook) => parseAgyTranscript(content, afterUuid, { conversationId: hook.session_id }),
|
|
88
|
-
},
|
|
89
|
-
};
|
|
54
|
+
/** Find the agent adapter whose capture wiring owns this hook-argv source
|
|
55
|
+
* spelling (what the hook scripts pass - NOT the server's `source` value;
|
|
56
|
+
* those differ for Claude: 'claude-code' vs 'claude_code'). Adding an agent
|
|
57
|
+
* = one file under cli/src/agents/ with a `capture` field; no separate
|
|
58
|
+
* registry to keep in sync. */
|
|
59
|
+
function findCaptureAdapter(hookKey) {
|
|
60
|
+
return AGENT_ADAPTERS.find((a) => a.capture.hookKey === hookKey);
|
|
61
|
+
}
|
|
90
62
|
// PostToolUse fires after every tool call. We flush on it so a session that is
|
|
91
63
|
// killed/crashes mid-run (e.g. a long headless `gipity claude -p` build that
|
|
92
64
|
// hits a timeout) still has its transcript in the DB - Stop/SessionEnd only
|
|
@@ -110,6 +82,7 @@ function readState(convGuid) {
|
|
|
110
82
|
return {
|
|
111
83
|
last_uuid: typeof parsed.last_uuid === 'string' ? parsed.last_uuid : null,
|
|
112
84
|
last_flush_ms: typeof parsed.last_flush_ms === 'number' ? parsed.last_flush_ms : undefined,
|
|
85
|
+
attached: typeof parsed.attached === 'boolean' ? parsed.attached : undefined,
|
|
113
86
|
};
|
|
114
87
|
}
|
|
115
88
|
catch {
|
|
@@ -365,12 +338,22 @@ async function readWholeFile(path) {
|
|
|
365
338
|
s.on('error', (err) => reject(err));
|
|
366
339
|
});
|
|
367
340
|
}
|
|
368
|
-
|
|
341
|
+
/** Bind the session_id to this conversation server-side (remote_session_id -
|
|
342
|
+
* what makes resume work), once per conversation. Called for EVERY event,
|
|
343
|
+
* not just SessionStart: Claude/Codex fire a real SessionStart hook, but
|
|
344
|
+
* agy's event set has no equivalent (PreToolUse/PostToolUse/PreInvocation/
|
|
345
|
+
* PostInvocation/Stop only) - and the dispatch path (GIPITY_CONVERSATION_GUID
|
|
346
|
+
* env var) never touches resolveFromServer's own attach either, since it
|
|
347
|
+
* short-circuits before that call. Idempotent both here (the `attached`
|
|
348
|
+
* state flag) and server-side (attachRemoteSessionId only assigns when
|
|
349
|
+
* remote_session_id IS NULL), so calling it redundantly for agents that DO
|
|
350
|
+
* have a SessionStart event is harmless. */
|
|
351
|
+
async function ensureAttached(convGuid, hook) {
|
|
369
352
|
if (!hook.session_id)
|
|
370
353
|
return;
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
|
|
354
|
+
const state = readState(convGuid);
|
|
355
|
+
if (state?.attached)
|
|
356
|
+
return;
|
|
374
357
|
const entries = [{
|
|
375
358
|
kind: 'attach',
|
|
376
359
|
session_id: hook.session_id,
|
|
@@ -378,7 +361,9 @@ async function handleSessionStart(convGuid, hook) {
|
|
|
378
361
|
source: 'startup',
|
|
379
362
|
source_uuid: `${hook.session_id}-attach`,
|
|
380
363
|
}];
|
|
381
|
-
await postEntries(convGuid, entries);
|
|
364
|
+
const ok = await postEntries(convGuid, entries);
|
|
365
|
+
if (ok)
|
|
366
|
+
writeState(convGuid, { ...(state ?? { last_uuid: null }), attached: true });
|
|
382
367
|
}
|
|
383
368
|
async function handleStopFamily(convGuid, src, hook, isSubagent, minIntervalMs = 0) {
|
|
384
369
|
void isSubagent;
|
|
@@ -397,11 +382,11 @@ async function handleStopFamily(convGuid, src, hook, isSubagent, minIntervalMs =
|
|
|
397
382
|
try {
|
|
398
383
|
const state = readState(convGuid) ?? { last_uuid: null };
|
|
399
384
|
const content = await readWholeFile(hook.transcript_path);
|
|
400
|
-
let result = src.parse(content, state.last_uuid, hook);
|
|
385
|
+
let result = src.capture.parse(content, state.last_uuid, hook);
|
|
401
386
|
if (!result.foundWatermark && state.last_uuid !== null) {
|
|
402
387
|
// Transcript rotated (/clear or compact) - watermark isn't present.
|
|
403
388
|
// Replay from top; server dedupes via the source_uuid unique index.
|
|
404
|
-
result = src.parse(content, null, hook);
|
|
389
|
+
result = src.capture.parse(content, null, hook);
|
|
405
390
|
}
|
|
406
391
|
// Base64 image blocks (Read-of-image tool results) upload to VFS and
|
|
407
392
|
// become image_ref blocks — same no-inline-base64 chokepoint as the
|
|
@@ -503,7 +488,7 @@ async function main() {
|
|
|
503
488
|
const [source, event] = process.argv.slice(2);
|
|
504
489
|
if (!source || !event)
|
|
505
490
|
return;
|
|
506
|
-
const src =
|
|
491
|
+
const src = findCaptureAdapter(source);
|
|
507
492
|
if (!src)
|
|
508
493
|
return; // unknown agent - silent no-op
|
|
509
494
|
const stdin = await readStdin();
|
|
@@ -516,22 +501,22 @@ async function main() {
|
|
|
516
501
|
}
|
|
517
502
|
// Agents whose hook payloads omit the transcript path (Grok) get it
|
|
518
503
|
// derived from the session id + cwd.
|
|
519
|
-
if (!hook.transcript_path && src.resolveTranscriptPath) {
|
|
520
|
-
const derived = src.resolveTranscriptPath(hook);
|
|
504
|
+
if (!hook.transcript_path && src.capture.resolveTranscriptPath) {
|
|
505
|
+
const derived = src.capture.resolveTranscriptPath(hook);
|
|
521
506
|
if (derived)
|
|
522
507
|
hook.transcript_path = derived;
|
|
523
508
|
}
|
|
524
509
|
// Opportunistic hygiene: Codex and agy never fire session-end, so their
|
|
525
510
|
// state files are TTL-swept instead of deleted at end-of-session.
|
|
526
511
|
sweepStaleState();
|
|
527
|
-
const convGuid = await resolveConvGuid(hook, src.
|
|
512
|
+
const convGuid = await resolveConvGuid(hook, src.source);
|
|
528
513
|
if (!convGuid)
|
|
529
514
|
return; // not a Gipity-bound session - nothing to capture
|
|
515
|
+
await ensureAttached(convGuid, hook);
|
|
530
516
|
try {
|
|
531
517
|
switch (event) {
|
|
532
518
|
case 'session-start':
|
|
533
|
-
|
|
534
|
-
break;
|
|
519
|
+
break; // ensureAttached above already covers what this event used to do
|
|
535
520
|
case 'stop':
|
|
536
521
|
await handleStopFamily(convGuid, src, hook, false);
|
|
537
522
|
break;
|