gipity 1.0.409 → 1.0.410
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/claude-setup.js +3 -2
- package/dist/commands/add.js +10 -1
- package/dist/commands/bug.js +69 -0
- package/dist/commands/credits.js +242 -15
- package/dist/commands/job.js +3 -3
- package/dist/commands/push.js +7 -3
- package/dist/commands/relay.js +26 -2
- package/dist/commands/remove.js +9 -3
- package/dist/commands/storage.js +64 -0
- package/dist/commands/uninstall.js +2 -2
- package/dist/commands/upload.js +1 -2
- package/dist/index.js +5 -4
- package/dist/knowledge.js +22 -0
- package/dist/platform.js +9 -5
- package/dist/relay/daemon.js +112 -7
- package/dist/relay/installers.js +10 -2
- package/dist/relay/onboarding.js +5 -2
- package/dist/relay/redact.js +26 -3
- package/dist/relay/setup.js +4 -4
- package/dist/relay/state.js +6 -3
- package/dist/setup.js +2 -3
- package/dist/sync.js +227 -106
- package/dist/updater/shim.js +4 -4
- package/dist/upload.js +1 -1
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -25,8 +25,8 @@ import { projectCommand } from './commands/project.js';
|
|
|
25
25
|
import { agentCommand } from './commands/agent.js';
|
|
26
26
|
import { workflowCommand } from './commands/workflow.js';
|
|
27
27
|
import { creditsCommand } from './commands/credits.js';
|
|
28
|
-
import { planCommand } from './commands/plan.js';
|
|
29
28
|
import { fileCommand } from './commands/file.js';
|
|
29
|
+
import { storageCommand } from './commands/storage.js';
|
|
30
30
|
import { claudeCommand } from './commands/claude.js';
|
|
31
31
|
import { addCommand } from './commands/add.js';
|
|
32
32
|
import { removeCommand } from './commands/remove.js';
|
|
@@ -37,6 +37,7 @@ import { fnCommand } from './commands/fn.js';
|
|
|
37
37
|
import { serviceCommand } from './commands/service.js';
|
|
38
38
|
import { secretsCommand } from './commands/secrets.js';
|
|
39
39
|
import { notifyCommand } from './commands/notify.js';
|
|
40
|
+
import { bugCommand } from './commands/bug.js';
|
|
40
41
|
import { paymentsCommand } from './commands/payments.js';
|
|
41
42
|
import { jobCommand } from './commands/job.js';
|
|
42
43
|
import { rbacCommand } from './commands/rbac.js';
|
|
@@ -126,11 +127,11 @@ program.enablePositionalOptions();
|
|
|
126
127
|
const commonGroup = [skillCommand, projectCommand, addCommand, removeCommand, deployCommand];
|
|
127
128
|
const connectGroup = [claudeCommand, relayCommand];
|
|
128
129
|
const projectGroup = [domainCommand, statusCommand, initCommand];
|
|
129
|
-
const filesGroup = [fileCommand, syncCommand, pushCommand, uploadCommand];
|
|
130
|
+
const filesGroup = [fileCommand, storageCommand, syncCommand, pushCommand, uploadCommand];
|
|
130
131
|
const appBuildingGroup = [testCommand, fnCommand, serviceCommand, secretsCommand, notifyCommand, paymentsCommand, jobCommand, dbCommand, logsCommand, workflowCommand, realtimeCommand, rbacCommand, auditCommand, recordsCommand];
|
|
131
132
|
const utilitiesGroup = [pageCommand, sandboxCommand, generateCommand, emailCommand, gmailCommand, locationCommand, textCommand];
|
|
132
|
-
const agentGroup = [chatCommand, memoryCommand, agentCommand, approvalCommand];
|
|
133
|
-
const setupGroup = [loginCommand, logoutCommand, tokenCommand, creditsCommand,
|
|
133
|
+
const agentGroup = [chatCommand, memoryCommand, agentCommand, approvalCommand, bugCommand];
|
|
134
|
+
const setupGroup = [loginCommand, logoutCommand, tokenCommand, creditsCommand, doctorCommand, updateCommand, uninstallCommand];
|
|
134
135
|
const HELP_SECTIONS = [
|
|
135
136
|
{ title: 'Common', cmds: commonGroup },
|
|
136
137
|
{ title: 'Connect', cmds: connectGroup },
|
package/dist/knowledge.js
CHANGED
|
@@ -64,6 +64,10 @@ Gipity ships first-party services for what apps usually pull from third parties
|
|
|
64
64
|
|
|
65
65
|
When a user asks about Gipity itself - how to install it, what it costs, what's shipped, how a command or flag works - answer from an authoritative source, not memory, and don't hedge with "I don't want to guess." Check in this order: (1) \`gipity skill read <name>\` / \`gipity skill list\` - install and account basics live in \`getting-started\`; (2) \`gipity <command> --help\` for command syntax; (3) if it's genuinely not in the skills or CLI help, fetch the live site at \`https://gipity.ai\` (or web search) and cite what you found. A wrong or vague answer about the product is worse than spending one tool call to get the current, correct one.
|
|
66
66
|
|
|
67
|
+
## Plans, limits & upgrading - unblock the user
|
|
68
|
+
|
|
69
|
+
Gipity runs on **credits** (the one consumable) and **plans** (Free / Gipity Pro) that set limits and the monthly credit grant. When a metered action fails with a limit error - "limit reached", "on your plan", "Pro only", or "Insufficient credits" - that's your cue to help them upgrade, not just report the error. The play: name what they hit, run \`gipity credits list\` to compare plans, surface what Pro unlocks for *their* task, then run \`gipity credits buy\` and hand them the checkout link (it only prints a link - Stripe takes payment; nothing is charged until they click and pay). Do it proactively and once - don't nag. \`gipity credits\` shows their current plan, balance, and full limits. Load the \`plans\` skill for the full model and honest positioning vs other platforms; never quote a price or limit from memory - read it live.
|
|
70
|
+
|
|
67
71
|
## Gipity is opinionated - build on its stack
|
|
68
72
|
|
|
69
73
|
Gipity is an opinionated platform with its own best-practice stack, and that stack is the one you use - whatever tools the user names. The platform layer is fixed:
|
|
@@ -105,12 +109,30 @@ mkdir -p ~/GipityProjects/<slug> && cd ~/GipityProjects/<slug> && gipity init <s
|
|
|
105
109
|
Key commands: \`gipity add <template|kit>\`, \`gipity deploy dev\`, \`gipity sandbox run\`, \`gipity page inspect <url>\`, \`gipity page screenshot <url>\`, \`gipity db query "SQL"\`, \`gipity fn call <name>\`, \`gipity logs fn <name>\`, \`gipity secrets set <NAME> <value> [--account]\` (store an API key/token encrypted; read in functions via \`secrets.get('NAME')\` — never hardcode keys), \`gipity email send --to <addr> --subject <s> --body <b>\` (sends as \`gipity@gipity.ai\`; omit \`--to\` to self-send), \`gipity skill read <name>\`.
|
|
106
110
|
Pull an existing remote project local (given its URL/slug): \`mkdir -p ~/GipityProjects/<slug> && cd ~/GipityProjects/<slug> && gipity init <slug>\` (adopts the matching project and syncs files down - this is the "clone").
|
|
107
111
|
For deterministic text questions (letter/word counts, substring occurrences, nth word/char, anagrams), use \`gipity text analyze "<text>"\` - local and instant, no sandbox or LLM needed.
|
|
112
|
+
Hit a platform bug or friction? File it in real time: \`gipity bug report --category <cli|deploy|template|kit|db|docs|skill|service|sandbox|other> --severity <S1|S2|S3|S4> --summary "<7 words max>" [--detail "<what failed + workaround>"]\` (see below).
|
|
108
113
|
Run \`gipity --help\` for the full list. Use \`--help\` on any command for details.
|
|
109
114
|
|
|
110
115
|
Function return shape: \`gipity fn call\`, the in-test \`ctx.fn.call\`/\`callAs\`, and the client \`Gipity.fn\` all return your function's value **unwrapped** - read/assert \`result.field\`. Only raw HTTP/\`curl\` wraps it as \`{ data: ... }\`; never write \`result.data.field\` in a test.
|
|
111
116
|
|
|
112
117
|
Tests are isolated, not run against your live DB: \`gipity test\` points \`ctx.fn.call\`/\`callAs\` at a throwaway copy of your database (your \`migrations/\` + \`seeds/\`), reset (truncate + reseed) before every run - so test rows never reach the deployed app and you don't write teardown. Functions see \`ctx.isTest === true\` during a run (use it to skip your own rate limiting); the platform also suppresses \`notify()\` push so a suite can't spam subscribers. Reference data tests need goes in seed files; a runtime-written settings table that isn't seeded goes under \`test.preserve\` in \`gipity.yaml\`. Build per-file fixtures in \`setup(fn)\` → \`ctx.fixtures\`, and namespace unique values with \`ctx.testId\`.
|
|
113
118
|
|
|
119
|
+
## Hit friction on the platform? Report it in real time
|
|
120
|
+
|
|
121
|
+
When *the Gipity platform itself* fights you — a CLI command errors or behaves unexpectedly, a doc/skill is wrong or missing, a deploy/template/kit/service/sandbox misbehaves — file a bug report the moment it happens, **even if you found a workaround and kept going.** Capturing it in the moment (with the real cause fresh) beats us mining it out of transcripts later.
|
|
122
|
+
|
|
123
|
+
\`\`\`
|
|
124
|
+
gipity bug report --category <cli|deploy|template|kit|db|docs|skill|service|sandbox|other> \\
|
|
125
|
+
--severity <S1|S2|S3|S4> \\
|
|
126
|
+
--summary "one line, 7 words max" \\
|
|
127
|
+
--detail "what you did, what failed, the workaround"
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
- **Severity:** S1 blocker (no workaround) · S2 major (costly workaround) · S3 minor (easy workaround) · S4 friction (papercut).
|
|
131
|
+
- **summary** ≤ 7 words; **detail** as succinct as possible (a few sentences, not a transcript).
|
|
132
|
+
- **Never include PII or user data** (emails, names, secrets, tokens, prompt/file contents) — describe the platform problem in the abstract.
|
|
133
|
+
- File it for *platform* problems, not your own mistakes or the app's own bugs. One report per distinct problem.
|
|
134
|
+
- Reports go to a review queue for the team to triage into fixes; see what you've filed with \`gipity bug list\`.
|
|
135
|
+
|
|
114
136
|
## Tool output is complete and synchronous
|
|
115
137
|
|
|
116
138
|
Every tool call returns its full output with that call. There is no output buffer to flush. Never run no-op commands (echo, date, sleep, repeated reads) to "retrieve" or "flush" lagged output - if a result looks empty or delayed, treat it as the actual result and move on, or re-run the real command once.
|
package/dist/platform.js
CHANGED
|
@@ -16,7 +16,7 @@ export function resolveCommand(cmd) {
|
|
|
16
16
|
if (process.platform !== 'win32')
|
|
17
17
|
return cmd;
|
|
18
18
|
try {
|
|
19
|
-
const lines = execSync(`where ${cmd}`, { encoding: 'utf-8' })
|
|
19
|
+
const lines = execSync(`where ${cmd}`, { encoding: 'utf-8', windowsHide: true })
|
|
20
20
|
.split(/\r?\n/)
|
|
21
21
|
.map(l => l.trim())
|
|
22
22
|
.filter(Boolean);
|
|
@@ -54,20 +54,24 @@ export function winBatchInvocation(cmd, args) {
|
|
|
54
54
|
* Drop-in `spawn` that survives Windows batch shims. When `cmd` is a `.cmd`/
|
|
55
55
|
* `.bat` on win32, it is launched via cmd.exe with verbatim arguments;
|
|
56
56
|
* otherwise this is a plain `spawn`. Use for anything from `resolveCommand`.
|
|
57
|
+
*
|
|
58
|
+
* `windowsHide: true` is the default so background/detached children (and the
|
|
59
|
+
* cmd.exe wrapper we use for batch shims) never flash a console window on
|
|
60
|
+
* Windows; a caller can still override it in `options`.
|
|
57
61
|
*/
|
|
58
62
|
export function spawnCommand(cmd, args = [], options = {}) {
|
|
59
63
|
if (isBatchShim(cmd)) {
|
|
60
64
|
const inv = winBatchInvocation(cmd, args);
|
|
61
|
-
return spawn(inv.file, inv.args, { ...options, windowsVerbatimArguments: true });
|
|
65
|
+
return spawn(inv.file, inv.args, { windowsHide: true, ...options, windowsVerbatimArguments: true });
|
|
62
66
|
}
|
|
63
|
-
return spawn(cmd, [...args], options);
|
|
67
|
+
return spawn(cmd, [...args], { windowsHide: true, ...options });
|
|
64
68
|
}
|
|
65
69
|
/** Drop-in `spawnSync` counterpart of {@link spawnCommand}. */
|
|
66
70
|
export function spawnSyncCommand(cmd, args = [], options = {}) {
|
|
67
71
|
if (isBatchShim(cmd)) {
|
|
68
72
|
const inv = winBatchInvocation(cmd, args);
|
|
69
|
-
return spawnSync(inv.file, inv.args, { ...options, windowsVerbatimArguments: true });
|
|
73
|
+
return spawnSync(inv.file, inv.args, { windowsHide: true, ...options, windowsVerbatimArguments: true });
|
|
70
74
|
}
|
|
71
|
-
return spawnSync(cmd, [...args], options);
|
|
75
|
+
return spawnSync(cmd, [...args], { windowsHide: true, ...options });
|
|
72
76
|
}
|
|
73
77
|
//# sourceMappingURL=platform.js.map
|
package/dist/relay/daemon.js
CHANGED
|
@@ -124,10 +124,11 @@ function lockLogPerms(dir, file) {
|
|
|
124
124
|
chmodSync(dir, 0o700);
|
|
125
125
|
}
|
|
126
126
|
catch { /* ignore - best-effort */ }
|
|
127
|
-
// Ensure file exists before chmod; open+close creates it if missing.
|
|
127
|
+
// Ensure file exists before chmod; open+close creates it if missing. Pass
|
|
128
|
+
// mode 0600 so it's owner-only from creation (no umask-default race window).
|
|
128
129
|
if (!existsSync(file)) {
|
|
129
130
|
try {
|
|
130
|
-
closeSync(openSync(file, 'a'));
|
|
131
|
+
closeSync(openSync(file, 'a', 0o600));
|
|
131
132
|
}
|
|
132
133
|
catch { /* ignore */ }
|
|
133
134
|
}
|
|
@@ -403,10 +404,36 @@ function getRelaySecrets() {
|
|
|
403
404
|
* Every entry is run through `redactEntries` first: a dispatched
|
|
404
405
|
* `bypassPermissions` session can read the host's credentials, so this is
|
|
405
406
|
* the single chokepoint that keeps a leaked secret out of the transcript. */
|
|
407
|
+
// Server-side per-entry length caps (remote-sessions.ts ingest schema). The
|
|
408
|
+
// server rejects the ENTIRE batch with a 400 if any entry violates one, which
|
|
409
|
+
// would drop good content (and, for the prompt echo, the "Running…" marker
|
|
410
|
+
// batched with it). We clamp defensively here so a batch never 400s on length
|
|
411
|
+
// - truncating an over-long value is strictly better than losing the batch.
|
|
412
|
+
const INGEST_PROMPT_MAX = 200_000;
|
|
413
|
+
const INGEST_ASSISTANT_MAX = 500_000;
|
|
414
|
+
const INGEST_SYSTEM_MAX = 500;
|
|
415
|
+
const TRUNCATE_SUFFIX = '… [truncated]';
|
|
416
|
+
function clampText(s, max) {
|
|
417
|
+
return s.length <= max ? s : s.slice(0, max - TRUNCATE_SUFFIX.length) + TRUNCATE_SUFFIX;
|
|
418
|
+
}
|
|
419
|
+
/** Clamp the human-text fields that have server caps. Runs AFTER redaction so
|
|
420
|
+
* truncation can't split a secret past the literal-match scrubber. Exported
|
|
421
|
+
* for unit testing. */
|
|
422
|
+
export function clampForIngest(entries) {
|
|
423
|
+
return entries.map(e => {
|
|
424
|
+
if (e.kind === 'prompt')
|
|
425
|
+
return { ...e, prompt: clampText(e.prompt, INGEST_PROMPT_MAX) };
|
|
426
|
+
if (e.kind === 'assistant')
|
|
427
|
+
return { ...e, text: clampText(e.text, INGEST_ASSISTANT_MAX) };
|
|
428
|
+
if (e.kind === 'system')
|
|
429
|
+
return { ...e, content: clampText(e.content, INGEST_SYSTEM_MAX) };
|
|
430
|
+
return e;
|
|
431
|
+
});
|
|
432
|
+
}
|
|
406
433
|
async function postIngest(convGuid, entries) {
|
|
407
434
|
if (!entries.length)
|
|
408
435
|
return { ok: true };
|
|
409
|
-
const safeEntries = redactEntries(entries, getRelaySecrets());
|
|
436
|
+
const safeEntries = clampForIngest(redactEntries(entries, getRelaySecrets()));
|
|
410
437
|
try {
|
|
411
438
|
const res = await deviceFetch('POST', `/remote-sessions/${encodeURIComponent(convGuid)}/ingest`, {
|
|
412
439
|
entries: safeEntries,
|
|
@@ -525,10 +552,16 @@ function formatDuration(ms) {
|
|
|
525
552
|
const s = totalSec - m * 60;
|
|
526
553
|
return `${m}:${s.toFixed(1).padStart(4, '0')}`;
|
|
527
554
|
}
|
|
555
|
+
// The server's ack schema caps `error` at 2000 chars and 400s anything longer
|
|
556
|
+
// - which would leave the dispatch stuck in `delivering` forever (no ack, no
|
|
557
|
+
// broadcast, a permanent queue-cap slot). Some error strings we build embed an
|
|
558
|
+
// arbitrary OS/spawn message, so clamp here to stay under the cap.
|
|
559
|
+
const MAX_ACK_ERROR_CHARS = 2000;
|
|
528
560
|
async function ack(shortGuid, status, error) {
|
|
561
|
+
const safeError = error != null ? error.slice(0, MAX_ACK_ERROR_CHARS) : null;
|
|
529
562
|
try {
|
|
530
563
|
const res = await deviceFetch('POST', `/remote-devices/dispatches/${encodeURIComponent(shortGuid)}/ack`, {
|
|
531
|
-
status, error:
|
|
564
|
+
status, error: safeError,
|
|
532
565
|
}, 10_000);
|
|
533
566
|
if (!res.ok) {
|
|
534
567
|
// fetch() doesn't throw on 4xx/5xx - surface it ourselves so a
|
|
@@ -588,9 +621,9 @@ async function handleDispatch(d) {
|
|
|
588
621
|
// the dispatch (the old in-process bootstrap sync could hang forever).
|
|
589
622
|
if (bootstrapped) {
|
|
590
623
|
await postIngest(d.conversation_guid, [{ kind: 'system', content: 'Syncing project files…' }]);
|
|
624
|
+
let syncKilled = false;
|
|
591
625
|
try {
|
|
592
|
-
await
|
|
593
|
-
await postIngest(d.conversation_guid, [{ kind: 'system', content: 'Project files synced.' }]);
|
|
626
|
+
syncKilled = (await runDispatchSync(d, cwd)).killed;
|
|
594
627
|
}
|
|
595
628
|
catch (err) {
|
|
596
629
|
const msg = `project sync ${err?.message || 'failed'}`;
|
|
@@ -599,6 +632,16 @@ async function handleDispatch(d) {
|
|
|
599
632
|
await ack(d.short_guid, 'error', msg);
|
|
600
633
|
return;
|
|
601
634
|
}
|
|
635
|
+
if (syncKilled) {
|
|
636
|
+
// The user cancelled (or a newer message for this conv superseded us)
|
|
637
|
+
// WHILE the pre-Claude sync was running. Before this was registered in
|
|
638
|
+
// `running`, a cancel was silently ignored until the 120s sync timeout.
|
|
639
|
+
log('info', 'dispatch cancelled during project sync', { id: d.short_guid });
|
|
640
|
+
await postIngest(d.conversation_guid, [{ kind: 'system', content: 'Claude Code cancelled (during project sync)' }]);
|
|
641
|
+
await ack(d.short_guid, 'cancelled');
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
await postIngest(d.conversation_guid, [{ kind: 'system', content: 'Project files synced.' }]);
|
|
602
645
|
}
|
|
603
646
|
// Build argv for `gipity claude -p …` (or with --resume). No shell - argv
|
|
604
647
|
// as array so the message string can't be interpreted as shell syntax.
|
|
@@ -813,6 +856,11 @@ export function getRunningConvGuids() {
|
|
|
813
856
|
* cancelled marker). Used at the top of handleDispatch so a new message
|
|
814
857
|
* for a busy conv cleanly replaces the in-flight one. No-op if no child
|
|
815
858
|
* matches. */
|
|
859
|
+
/** Grace period between SIGTERM and the SIGKILL escalation. A child that traps
|
|
860
|
+
* or ignores SIGTERM (or is blocked in uninterruptible I/O) must not hang the
|
|
861
|
+
* handler forever - that would permanently hold one of the concurrency slots.
|
|
862
|
+
* Overridable for tests. */
|
|
863
|
+
const KILL_GRACE_MS = parseInt(process.env.GIPITY_RELAY_KILL_GRACE_MS || '10000', 10);
|
|
816
864
|
export async function killRunningForConv(convGuid) {
|
|
817
865
|
const matches = [...running.values()].filter(e => e.convGuid === convGuid);
|
|
818
866
|
if (matches.length === 0)
|
|
@@ -824,7 +872,29 @@ export async function killRunningForConv(convGuid) {
|
|
|
824
872
|
}
|
|
825
873
|
catch { /* ignore - already exited */ }
|
|
826
874
|
}
|
|
875
|
+
// Wait for a clean unwind, but escalate to SIGKILL if the grace period
|
|
876
|
+
// elapses so a stuck child can't wedge a slot. Whichever resolves first,
|
|
877
|
+
// we still await `exited` so the outgoing children post their cancelled
|
|
878
|
+
// markers + acks before the replacement spawns.
|
|
879
|
+
const graceTimers = [];
|
|
880
|
+
const escalate = new Promise(resolve => {
|
|
881
|
+
const t = setTimeout(() => {
|
|
882
|
+
for (const e of matches) {
|
|
883
|
+
log('warn', 'previous dispatch ignored SIGTERM - escalating to SIGKILL', { conv: convGuid });
|
|
884
|
+
try {
|
|
885
|
+
e.child.kill('SIGKILL');
|
|
886
|
+
}
|
|
887
|
+
catch { /* already gone */ }
|
|
888
|
+
}
|
|
889
|
+
resolve();
|
|
890
|
+
}, KILL_GRACE_MS);
|
|
891
|
+
graceTimers.push(t);
|
|
892
|
+
});
|
|
893
|
+
await Promise.race([Promise.all(matches.map(e => e.exited)), escalate]);
|
|
894
|
+
// Ensure every child has actually exited (SIGKILL fires the exit event too).
|
|
827
895
|
await Promise.all(matches.map(e => e.exited));
|
|
896
|
+
for (const t of graceTimers)
|
|
897
|
+
clearTimeout(t);
|
|
828
898
|
}
|
|
829
899
|
/** Spawn `gipity claude …` in `cwd` with `--output-format stream-json
|
|
830
900
|
* --verbose` so every event (assistant messages, tool_use blocks,
|
|
@@ -839,7 +909,7 @@ export async function killRunningForConv(convGuid) {
|
|
|
839
909
|
* back to VFS. Runs as a child so we inherit sync's cwd-walk for config
|
|
840
910
|
* resolution (the daemon itself doesn't chdir into projects).
|
|
841
911
|
* Non-blocking on failure - caller catches and logs. */
|
|
842
|
-
async function spawnSync(cwd, timeoutMs) {
|
|
912
|
+
async function spawnSync(cwd, timeoutMs, onSpawn) {
|
|
843
913
|
// resolveCommand: on Windows the bare `gipity` is a .cmd shim that spawn
|
|
844
914
|
// can't launch without an explicit path. An explicit env override is used
|
|
845
915
|
// verbatim (it may be a full path); only the default name is resolved.
|
|
@@ -850,6 +920,9 @@ async function spawnSync(cwd, timeoutMs) {
|
|
|
850
920
|
env: process.env,
|
|
851
921
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
852
922
|
});
|
|
923
|
+
// Hand the child to the caller so it can register the sync in `running`,
|
|
924
|
+
// making it cancellable (the poller / kill-on-new-message can SIGTERM it).
|
|
925
|
+
onSpawn?.(child);
|
|
853
926
|
// Drain pipes so the child doesn't stall on a full buffer.
|
|
854
927
|
let stdoutLen = 0;
|
|
855
928
|
let stderrBuf = '';
|
|
@@ -1001,6 +1074,38 @@ export async function spawnGipityClaude(args, cwd, d) {
|
|
|
1001
1074
|
});
|
|
1002
1075
|
});
|
|
1003
1076
|
}
|
|
1077
|
+
/** Run the pre-Claude `gipity sync` for a dispatch, registered in `running`
|
|
1078
|
+
* so it's cancellable. Without this the dispatch is invisible to the
|
|
1079
|
+
* cancellation poller and to kill-on-new-message during the sync, so a slow
|
|
1080
|
+
* sync couldn't be interrupted for up to PROJECT_SYNC_TIMEOUT_MS. Returns
|
|
1081
|
+
* `{ killed }` = true when the sync child was SIGTERMed externally (user
|
|
1082
|
+
* cancel or a newer message on the same conv), distinct from a genuine sync
|
|
1083
|
+
* failure (which throws) - the daemon's own timeout uses SIGKILL, so a
|
|
1084
|
+
* SIGTERM here can only be an external interrupt. */
|
|
1085
|
+
async function runDispatchSync(d, cwd) {
|
|
1086
|
+
let killed = false;
|
|
1087
|
+
try {
|
|
1088
|
+
await spawnSync(cwd, PROJECT_SYNC_TIMEOUT_MS, (child) => {
|
|
1089
|
+
const exited = new Promise(resolve => {
|
|
1090
|
+
child.once('exit', (_code, signal) => {
|
|
1091
|
+
if (signal === 'SIGTERM')
|
|
1092
|
+
killed = true;
|
|
1093
|
+
resolve();
|
|
1094
|
+
});
|
|
1095
|
+
});
|
|
1096
|
+
running.set(d.short_guid, { child, convGuid: d.conversation_guid, exited });
|
|
1097
|
+
});
|
|
1098
|
+
return { killed: false };
|
|
1099
|
+
}
|
|
1100
|
+
catch (err) {
|
|
1101
|
+
if (killed)
|
|
1102
|
+
return { killed: true };
|
|
1103
|
+
throw err;
|
|
1104
|
+
}
|
|
1105
|
+
finally {
|
|
1106
|
+
running.delete(d.short_guid);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1004
1109
|
/** SIGTERM a specific running dispatch. Returns true if one was killed,
|
|
1005
1110
|
* false if no such child was running on this daemon. */
|
|
1006
1111
|
export function killDispatch(shortGuid) {
|
package/dist/relay/installers.js
CHANGED
|
@@ -60,7 +60,15 @@ function launchdPlan(cliPath) {
|
|
|
60
60
|
<string>run</string>
|
|
61
61
|
</array>
|
|
62
62
|
<key>RunAtLoad</key><true/>
|
|
63
|
-
|
|
63
|
+
<!-- Restart ONLY on a non-zero exit, mirroring systemd's Restart=on-failure.
|
|
64
|
+
The daemon exits 0 on a clean revoke/shutdown; a bare KeepAlive=true
|
|
65
|
+
would relaunch it anyway, and run() would then silently re-register a
|
|
66
|
+
new device - undoing the revoke. SuccessfulExit=false keeps crash
|
|
67
|
+
recovery without that re-pair loop. -->
|
|
68
|
+
<key>KeepAlive</key>
|
|
69
|
+
<dict>
|
|
70
|
+
<key>SuccessfulExit</key><false/>
|
|
71
|
+
</dict>
|
|
64
72
|
<key>StandardOutPath</key><string>${join(logDir, 'relay.out.log')}</string>
|
|
65
73
|
<key>StandardErrorPath</key><string>${join(logDir, 'relay.err.log')}</string>
|
|
66
74
|
<key>ProcessType</key><string>Background</string>
|
|
@@ -80,7 +88,7 @@ function launchdPlan(cliPath) {
|
|
|
80
88
|
enableDisplay: display(enableCmds),
|
|
81
89
|
disableDisplay: display(disableCmds),
|
|
82
90
|
statusDisplay: statusCmd.join(' '),
|
|
83
|
-
summary: 'LaunchAgent at ~/Library/LaunchAgents/ai.gipity.relay.plist (starts at login,
|
|
91
|
+
summary: 'LaunchAgent at ~/Library/LaunchAgents/ai.gipity.relay.plist (starts at login, restarts on failure)',
|
|
84
92
|
};
|
|
85
93
|
}
|
|
86
94
|
// ─── Linux - systemd --user unit ───────────────────────────────────────
|
package/dist/relay/onboarding.js
CHANGED
|
@@ -56,8 +56,11 @@ export async function maybeOfferRelayOn() {
|
|
|
56
56
|
}
|
|
57
57
|
catch (err) {
|
|
58
58
|
console.error(`\n ${clrError(`Could not create device: ${err?.message || err}`)}`);
|
|
59
|
-
console.error(` ${dim('Skipping
|
|
60
|
-
|
|
59
|
+
console.error(` ${dim('Skipping for now - we\'ll offer again next time. Or turn it on with `gipity relay install`.')}`);
|
|
60
|
+
// Deliberately DON'T persist relay_enabled here: the user SAID YES, and
|
|
61
|
+
// this is a transient failure (network blip, server down). Leaving the
|
|
62
|
+
// tri-state unset means onboarding re-offers on the next `gipity claude`
|
|
63
|
+
// run instead of silently opting the user out forever.
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
66
|
// Start the daemon for this session.
|
package/dist/relay/redact.js
CHANGED
|
@@ -38,15 +38,38 @@ const JWT_RE = /eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
|
38
38
|
* literal-secret list. An `sk-ant-` token in a relay transcript is always a
|
|
39
39
|
* credential, so over-redaction risk is negligible. */
|
|
40
40
|
const ANTHROPIC_KEY_RE = /sk-ant-[A-Za-z0-9_-]{20,}/g;
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
41
|
+
/** Well-known third-party credential shapes. A `bypassPermissions` session can
|
|
42
|
+
* read the host's environment and files, so a `cat .env` / `env` could echo
|
|
43
|
+
* ANY of these into the transcript - not just the Gipity/Anthropic tokens on
|
|
44
|
+
* the literal-secret list. Each pattern is a high-entropy, provider-specific
|
|
45
|
+
* prefix that is effectively never a false positive in a relay transcript, so
|
|
46
|
+
* the over-redaction risk is the same negligible trade-off already accepted
|
|
47
|
+
* for the JWT and `sk-ant-` passes. Extend this list as new providers appear;
|
|
48
|
+
* it is defense-in-depth, NOT a guarantee (a base64/chunked secret still
|
|
49
|
+
* slips through - the real backstop remains an instantly-revocable
|
|
50
|
+
* credential). */
|
|
51
|
+
const THIRD_PARTY_KEY_RES = [
|
|
52
|
+
/sk-[A-Za-z0-9_-]{20,}/g, // OpenAI (sk-, sk-proj-) + any sk- key
|
|
53
|
+
/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36,}\b/g, // GitHub tokens
|
|
54
|
+
/\bgithub_pat_[A-Za-z0-9_]{60,}\b/g, // GitHub fine-grained PAT
|
|
55
|
+
/\bAKIA[0-9A-Z]{16}\b/g, // AWS access key id
|
|
56
|
+
/\b(?:sk|rk)_live_[A-Za-z0-9]{20,}\b/g, // Stripe live secret/restricted key
|
|
57
|
+
/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g, // Slack tokens
|
|
58
|
+
/\bAIza[A-Za-z0-9_-]{35}\b/g, // Google API key
|
|
59
|
+
/-----BEGIN (?:RSA |EC |OPENSSH |DSA |PGP )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH |DSA |PGP )?PRIVATE KEY-----/g, // PEM private keys
|
|
60
|
+
];
|
|
61
|
+
/** Replace every occurrence of each known secret - plus any JWT-, Anthropic-,
|
|
62
|
+
* or well-known-third-party-key-shaped substring - in `text` with the marker. */
|
|
43
63
|
function redactString(text, secrets) {
|
|
44
64
|
let out = text;
|
|
45
65
|
for (const secret of secrets) {
|
|
46
66
|
if (out.includes(secret))
|
|
47
67
|
out = out.split(secret).join(REDACTION_MARKER);
|
|
48
68
|
}
|
|
49
|
-
|
|
69
|
+
out = out.replace(JWT_RE, REDACTION_MARKER).replace(ANTHROPIC_KEY_RE, REDACTION_MARKER);
|
|
70
|
+
for (const re of THIRD_PARTY_KEY_RES)
|
|
71
|
+
out = out.replace(re, REDACTION_MARKER);
|
|
72
|
+
return out;
|
|
50
73
|
}
|
|
51
74
|
/** Deep-walk any JSON-ish value, redacting every string. Returns a new
|
|
52
75
|
* value; objects/arrays are cloned, primitives passed through. */
|
package/dist/relay/setup.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* the interactive prompts that live in `onboarding.ts`. No `console` output
|
|
11
11
|
* and no `process.exit` in this module: callers own all UX.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { spawnCommand, spawnSyncCommand } from '../platform.js';
|
|
14
14
|
import { hostname, platform as osPlatform } from 'os';
|
|
15
15
|
import { resolve, dirname } from 'path';
|
|
16
16
|
import { mkdirSync, writeFileSync } from 'fs';
|
|
@@ -87,7 +87,7 @@ export function startDaemon() {
|
|
|
87
87
|
if (state.isDaemonRunning())
|
|
88
88
|
return;
|
|
89
89
|
try {
|
|
90
|
-
const child =
|
|
90
|
+
const child = spawnCommand(process.execPath, [resolveCliPath(), 'relay', 'run'], {
|
|
91
91
|
detached: true,
|
|
92
92
|
stdio: 'ignore',
|
|
93
93
|
});
|
|
@@ -118,7 +118,7 @@ export function installAutostart(opts = {}) {
|
|
|
118
118
|
writeFileSync(plan.path, plan.content);
|
|
119
119
|
let ok = true;
|
|
120
120
|
for (const argv of plan.enableCmds) {
|
|
121
|
-
const r =
|
|
121
|
+
const r = spawnSyncCommand(argv[0], argv.slice(1), { stdio });
|
|
122
122
|
if (r.status !== 0) {
|
|
123
123
|
ok = false;
|
|
124
124
|
break;
|
|
@@ -136,7 +136,7 @@ export function removeAutostart(opts = {}) {
|
|
|
136
136
|
const plan = planFor({ cliPath: resolveCliPath() });
|
|
137
137
|
let ok = true;
|
|
138
138
|
for (const argv of plan.disableCmds) {
|
|
139
|
-
const r =
|
|
139
|
+
const r = spawnSyncCommand(argv[0], argv.slice(1), { stdio });
|
|
140
140
|
if (r.status !== 0)
|
|
141
141
|
ok = false;
|
|
142
142
|
}
|
package/dist/relay/state.js
CHANGED
|
@@ -47,9 +47,12 @@ export function loadState() {
|
|
|
47
47
|
}
|
|
48
48
|
export function saveState(state) {
|
|
49
49
|
mkdirSync(RELAY_DIR, { recursive: true });
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
//
|
|
50
|
+
// `mode` on write means a NEWLY-created file is owner-only from the first
|
|
51
|
+
// byte - no window where it exists at the umask default (typically 0644)
|
|
52
|
+
// before a follow-up chmod tightens it. The chmodSync still runs to fix a
|
|
53
|
+
// file that already existed with looser permissions (mode is ignored for
|
|
54
|
+
// an existing file).
|
|
55
|
+
writeFileSync(RELAY_FILE, JSON.stringify(state, null, 2) + '\n', { mode: FILE_MODE });
|
|
53
56
|
try {
|
|
54
57
|
chmodSync(RELAY_FILE, FILE_MODE);
|
|
55
58
|
}
|
package/dist/setup.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { resolve, join, dirname } from 'path';
|
|
5
5
|
import { homedir } from 'os';
|
|
6
6
|
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
|
|
7
|
-
import { spawnSync } from 'child_process';
|
|
8
7
|
import { resolveCommand, spawnSyncCommand } from './platform.js';
|
|
9
8
|
import { SKILLS_CONTENT, BUILD_VS_NON_BUILD_RULE, DEFINITION_OF_DONE } from './knowledge.js';
|
|
10
9
|
export { SKILLS_CONTENT };
|
|
@@ -257,10 +256,10 @@ export function userScopePluginCurrent() {
|
|
|
257
256
|
}
|
|
258
257
|
}
|
|
259
258
|
function claudeOnPath() {
|
|
260
|
-
const probe =
|
|
259
|
+
const probe = spawnSyncCommand(process.platform === 'win32' ? 'where' : 'which', ['claude'], {
|
|
261
260
|
encoding: 'utf-8',
|
|
262
261
|
});
|
|
263
|
-
return probe.status === 0 && !!probe.stdout?.trim();
|
|
262
|
+
return probe.status === 0 && !!probe.stdout?.toString().trim();
|
|
264
263
|
}
|
|
265
264
|
/** Materialize the Gipity plugin at USER scope via Claude Code's own plugin
|
|
266
265
|
* CLI, so its hooks (session capture + file sync) load in EVERY directory.
|