@yasaswy.nagavolu/agents 0.36.0 → 0.36.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/content/manifest.json +15 -0
- package/content/mcps/chrome_devtools_policy.js +4 -0
- package/content/mcps/chrome_devtools_rules.json +6 -1
- package/content/proxy/bg_process_registry.py +3 -1
- package/content/proxy/chrome_devtools_guard.py +5 -0
- package/content/proxy/chrome_profile_lock.py +8 -0
- package/content/proxy/push_hold.py +240 -0
- package/content/skills/resale/CONTRACTS.md +61 -7
- package/content/skills/resale/README.md +85 -9
- package/content/skills/resale/SKILL.md +11 -5
- package/content/skills/resale/resale/analysis/bundle.py +2 -1
- package/content/skills/resale/resale/analysis/paid_check.py +5 -3
- package/content/skills/resale/resale/analysis/stats.py +3 -1
- package/content/skills/resale/resale/comps/specs.py +1 -1
- package/content/skills/resale/resale/contracts/__init__.py +5 -1
- package/content/skills/resale/resale/contracts/event.schema.json +1 -1
- package/content/skills/resale/resale/contracts/inquiry_batch.schema.json +34 -0
- package/content/skills/resale/resale/contracts/item_specs.schema.json +8 -1
- package/content/skills/resale/resale/db/migrations/0024_buyer_inquiries.sql +44 -0
- package/content/skills/resale/resale/db/migrations/0025_listing_copy.sql +7 -0
- package/content/skills/resale/resale/db/migrations/0026_selling_lifecycle.sql +6 -0
- package/content/skills/resale/resale/db/migrations/0027_own_listing_alias.sql +1 -0
- package/content/skills/resale/resale/inquiries/__init__.py +1 -0
- package/content/skills/resale/resale/inquiries/commands.py +28 -0
- package/content/skills/resale/resale/inquiries/match.py +85 -0
- package/content/skills/resale/resale/inquiries/parse.py +156 -0
- package/content/skills/resale/resale/inquiries/queries.py +24 -0
- package/content/skills/resale/resale/inquiries/refs.py +63 -0
- package/content/skills/resale/resale/inquiries/rules.py +84 -0
- package/content/skills/resale/resale/inquiries/scan.py +124 -0
- package/content/skills/resale/resale/inquiries/store.py +90 -0
- package/content/skills/resale/resale/inventory/paid.py +10 -4
- package/content/skills/resale/resale/portal/bundles.py +3 -1
- package/content/skills/resale/resale/portal/layout.py +1 -1
- package/content/skills/resale/resale/portal/paid_cells.py +11 -3
- package/content/skills/resale/resale/portal/panel.py +1 -1
- package/content/skills/resale/resale/portal/views_conditions.py +121 -0
- package/content/skills/resale/resale/portal/views_inquiries.py +72 -0
- package/content/skills/resale/resale/portal/views_items.py +23 -7
- package/content/skills/resale/resale/portal/views_postkit.py +20 -6
- package/content/skills/resale/resale/portal/views_selling.py +132 -0
- package/content/skills/resale/resale/poster/adapters.py +86 -14
- package/content/skills/resale/resale/poster/commands.py +114 -6
- package/content/skills/resale/resale/poster/driver.py +193 -8
- package/content/skills/resale/resale/poster/review_window.py +210 -0
- package/content/skills/resale/resale/poster/rules.py +16 -2
- package/content/skills/resale/resale/poster/runner.py +76 -13
- package/content/skills/resale/resale/poster/specs.py +31 -0
- package/content/skills/resale/resale/postkit/drafts.py +111 -27
- package/content/skills/resale/resale/postkit/fill.py +6 -2
- package/content/skills/resale/resale/postkit/health.py +71 -0
- package/content/skills/resale/resale/postkit/lint.py +111 -0
- package/content/skills/resale/resale/postkit/platforms.py +1 -4
- package/content/skills/resale/resale/postkit/post_id.py +55 -0
- package/content/skills/resale/resale/postkit/pricing.py +5 -2
- package/content/skills/resale/resale/postkit/selling.py +112 -0
- package/content/skills/resale/resale/postkit/specs.py +29 -0
- package/content/skills/resale/resale/postkit/text.py +109 -26
- package/content/skills/resale/resale/price_rule.py +40 -0
- package/content/skills/resale/resale/publisher/allowlist.py +2 -2
- package/content/skills/resale/resale/publisher/chrome_profile_lock.py +8 -0
- package/content/skills/resale/resale/publisher/commands.py +2 -2
- package/content/skills/resale/resale/publisher/pricing.py +3 -0
- package/content/skills/resale/resale/publisher/proposals.py +3 -0
- package/content/skills/resale/resale/service/commands.py +31 -3
- package/content/skills/resale/resale/service/condition_refresh.py +34 -0
- package/content/skills/resale/resale/service/copy_plan.py +92 -0
- package/content/skills/resale/resale/service/drafts.py +5 -1
- package/content/skills/resale/resale/service/inventory_ops.py +62 -4
- package/content/skills/resale/resale/service/round_prices.py +82 -0
- package/content/skills/resale/resale/service/scheduler.py +14 -0
- package/content/skills/resale/resale/service/server.py +104 -5
- package/content/skills/resale/resale/settings.py +6 -0
- package/content/skills/resale/resale/sources/amazon_reader.py +4 -0
- package/content/skills/resale/resale/sources/client.py +16 -0
- package/content/skills/resale/resale/sources/commands.py +17 -2
- package/content/skills/resale/resale/sources/listing_page.py +52 -0
- package/content/skills/resale/resale/sources/notify.py +13 -0
- package/content/skills/resale/resale/sources/own_check.py +70 -0
- package/content/skills/resale/resale/sources/runner.py +4 -0
- package/content/skills/resale/settings.example.env +8 -0
- package/content/skills/resale/tasks/reader_task.py +6 -0
- package/content/skills/resale/tests/conftest.py +11 -0
- package/content/skills/resale/tests/inquiry_fixtures.py +115 -0
- package/content/skills/resale/tests/test_condition_refresh.py +146 -0
- package/content/skills/resale/tests/test_conditions_page.py +258 -0
- package/content/skills/resale/tests/test_inquiries_parse.py +94 -0
- package/content/skills/resale/tests/test_inquiries_scan.py +168 -0
- package/content/skills/resale/tests/test_inquiries_service.py +280 -0
- package/content/skills/resale/tests/test_listing_copy.py +357 -0
- package/content/skills/resale/tests/test_lock_priority.py +40 -0
- package/content/skills/resale/tests/test_own_check.py +123 -0
- package/content/skills/resale/tests/test_paid_incl_tax.py +19 -4
- package/content/skills/resale/tests/test_paid_incl_tax_views.py +7 -6
- package/content/skills/resale/tests/test_portal_postkit.py +4 -3
- package/content/skills/resale/tests/test_post_id.py +118 -0
- package/content/skills/resale/tests/test_poster.py +292 -18
- package/content/skills/resale/tests/test_poster_review_window.py +367 -0
- package/content/skills/resale/tests/test_poster_specs.py +41 -0
- package/content/skills/resale/tests/test_postkit.py +32 -20
- package/content/skills/resale/tests/test_postkit_fill.py +22 -0
- package/content/skills/resale/tests/test_publisher_allowlist.py +5 -0
- package/content/skills/resale/tests/test_publisher_api.py +3 -3
- package/content/skills/resale/tests/test_publisher_apply.py +3 -3
- package/content/skills/resale/tests/test_publisher_commands.py +14 -6
- package/content/skills/resale/tests/test_publisher_pricing.py +3 -3
- package/content/skills/resale/tests/test_publisher_proposals.py +2 -2
- package/content/skills/resale/tests/test_publisher_review.py +3 -3
- package/content/skills/resale/tests/test_round_prices.py +217 -0
- package/content/skills/resale/tests/test_selling.py +349 -0
- package/content/skills/resale/tests/test_selling_notes.py +2 -2
- package/content/skills/resale/tests/test_service_http.py +2 -2
- package/content/skills/ship-the-code/SKILL.md +2 -1
- package/content/skills/ship-the-code/ship.py +88 -5
- package/content/skills/ship-the-code/tests/test_ship.py +25 -0
- package/content/skills/ship-the-code/tests/test_ship_manifest_lint.py +110 -0
- package/content/skills/ship-the-code/tests/test_ship_push_hold.py +122 -0
- package/lib/bootstrap/index.js +6 -5
- package/lib/bootstrap/probe.js +12 -2
- package/lib/bootstrap/tools.js +4 -4
- package/lib/prepack.js +25 -4
- package/package.json +1 -1
package/content/manifest.json
CHANGED
|
@@ -105,6 +105,11 @@
|
|
|
105
105
|
"path": "skills/ship-the-code",
|
|
106
106
|
"kind": "skill"
|
|
107
107
|
},
|
|
108
|
+
{
|
|
109
|
+
"path": "proxy/push_hold.py",
|
|
110
|
+
"kind": "infra",
|
|
111
|
+
"note": "Repo-level main push hold (set/clear/status, managed pre-push hook); ship.py refuses to push a branch another session holds, release.ps1 checks it in preflight — not wired to an event itself."
|
|
112
|
+
},
|
|
108
113
|
{
|
|
109
114
|
"path": "proxy/agents_env.py",
|
|
110
115
|
"kind": "hook",
|
|
@@ -3029,6 +3034,16 @@
|
|
|
3029
3034
|
"kind": "skill",
|
|
3030
3035
|
"note": "The edit-review page is rendered by html-mocker, which the publisher loads from the sibling skill folder. Also claimed by visual-review; safe to double-claim."
|
|
3031
3036
|
},
|
|
3037
|
+
{
|
|
3038
|
+
"path": "proxy/headless_launch.py",
|
|
3039
|
+
"kind": "infra",
|
|
3040
|
+
"note": "The review window starts its detached holder through this launcher (own hidden console, breakaway from the caller's job object), loaded by path from the deployed proxy folder. Also claimed by self-infra; safe to double-claim."
|
|
3041
|
+
},
|
|
3042
|
+
{
|
|
3043
|
+
"path": "proxy/headless_process.py",
|
|
3044
|
+
"kind": "infra",
|
|
3045
|
+
"note": "Imported by headless_launch.py. Also claimed by several bundles; safe to double-claim."
|
|
3046
|
+
},
|
|
3032
3047
|
{
|
|
3033
3048
|
"path": "skills/resale/container/docker-compose.yml",
|
|
3034
3049
|
"kind": "container",
|
|
@@ -25,6 +25,8 @@ const LOGIN_PATH = rx('loginPath');
|
|
|
25
25
|
const PURCHASE_ELEMENT = rx('purchaseElement');
|
|
26
26
|
const DESTRUCTIVE_ELEMENT = rx('destructiveElement');
|
|
27
27
|
const SENSITIVE_FIELD = rx('sensitiveField');
|
|
28
|
+
const CONTACT_FIELD = rx('contactField');
|
|
29
|
+
const PRIVATE_TEXT = [['privatePhone', 'a phone number'], ['privateEmail', 'an email address'], ['privateAddress', 'a street address'], ['privateUrl', 'a web link']].map(([key, what]) => [rx(key), what]);
|
|
28
30
|
const PASSWORD_FIELD = rx('passwordField');
|
|
29
31
|
const INPUT_ROLE = rx('inputRole');
|
|
30
32
|
|
|
@@ -70,6 +72,7 @@ function checkValues(name, args) {
|
|
|
70
72
|
const digits = v.replace(/[\s-]/g, '');
|
|
71
73
|
if (/^\d{13,19}$/.test(digits) && luhn(digits)) return 'the value looks like a payment card number';
|
|
72
74
|
if (/^\d{3}-\d{2}-\d{4}$/.test(v.trim())) return 'the value looks like a social security number';
|
|
75
|
+
for (const [re, what] of PRIVATE_TEXT) if (re.test(v)) return `the value contains ${what}; contact goes through the site message or mail relay only`;
|
|
73
76
|
}
|
|
74
77
|
return null;
|
|
75
78
|
}
|
|
@@ -220,6 +223,7 @@ function checkElements(name, args, snapshot, ctx = {}) {
|
|
|
220
223
|
if (PURCHASE_ELEMENT.test(line)) return `element "${line.slice(0, 80)}" is a purchase, bid, offer or paid-promotion control`;
|
|
221
224
|
if (DESTRUCTIVE_ELEMENT.test(line)) return `element "${line.slice(0, 80)}" logs out or removes the account`;
|
|
222
225
|
if (TEXT_ENTRY_TOOLS.has(name) && SENSITIVE_FIELD.test(line)) return `element "${line.slice(0, 80)}" is a password or payment field`;
|
|
226
|
+
if (TEXT_ENTRY_TOOLS.has(name) && CONTACT_FIELD.test(line)) return `element "${line.slice(0, 80)}" is a phone, address or email field; contact goes through the site message or mail relay only`;
|
|
223
227
|
}
|
|
224
228
|
if (TEXT_ENTRY_TOOLS.has(name)) {
|
|
225
229
|
for (const line of snapshot.values()) {
|
|
@@ -67,6 +67,11 @@
|
|
|
67
67
|
"destructiveElement": "\\b(log ?out|sign ?out|delete (my |your |the )?account|deactivate|close (my |your )?account|permanently delete|remove payment|delete (my |your )?(profile|data))\\b",
|
|
68
68
|
"sensitiveField": "\\b(password|passcode|passwd|pin|card number|credit card|debit card|cvv|cvc|security code|expir(y|ation|es)|routing number|bank account|account number|ssn|social security|one[- ]time (code|password)|otp|2fa|two[- ]factor|verification code|security answer)\\b",
|
|
69
69
|
"passwordField": "\\b(password|passcode|passwd)\\b",
|
|
70
|
-
"inputRole": "^(textbox|combobox|searchbox|spinbutton)\\b"
|
|
70
|
+
"inputRole": "^(textbox|combobox|searchbox|spinbutton)\\b",
|
|
71
|
+
"privatePhone": "(?<!\\d)(?:\\+?1[\\s.-]?)?(?:\\(\\d{3}\\)|\\d{3})[\\s.-]\\d{3}[\\s.-]\\d{4}(?!\\d)|(?<!\\d)\\d{10}(?!\\d)",
|
|
72
|
+
"privateEmail": "[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}",
|
|
73
|
+
"privateAddress": "\\b\\d{1,6}\\s+(?:[a-z0-9.']+\\s+){0,3}(?:street|st|avenue|ave|road|rd|drive|dr|lane|ln|boulevard|blvd|parkway|pkwy|highway|hwy|trail|trl|court)\\b",
|
|
74
|
+
"privateUrl": "\\b(?:https?:\\/\\/|www\\.)\\S+",
|
|
75
|
+
"contactField": "\\b(phone|telephone|mobile|cell|street|address|e-?mail)\\b"
|
|
71
76
|
}
|
|
72
77
|
}
|
|
@@ -290,7 +290,9 @@ def _sole_active_session(session_id: str, procs: ledger.ProcTable) -> bool:
|
|
|
290
290
|
|
|
291
291
|
|
|
292
292
|
def _spelled_in_command(name: str, cmdline: str, command: str) -> bool:
|
|
293
|
-
"""True when every argument of the process is spelled in the launching command; without arguments, when its full image file name is."""
|
|
293
|
+
"""True when every argument of the process is spelled in the launching command; without arguments, when its full image file name is; an unreadable (empty) command line never matches."""
|
|
294
|
+
if not cmdline.strip():
|
|
295
|
+
return False
|
|
294
296
|
try:
|
|
295
297
|
tokens = shlex.split(cmdline, posix=False)[1:]
|
|
296
298
|
except ValueError:
|
|
@@ -52,6 +52,8 @@ LOCAL_TOOLS = frozenset(RULES["sets"]["local"])
|
|
|
52
52
|
ALLOWED_TOOLS = READ_TOOLS | WRITE_TOOLS | LOCAL_TOOLS
|
|
53
53
|
URL_TOOLS = frozenset({"new_page", "navigate_page"})
|
|
54
54
|
UPLOAD_EXTENSIONS = frozenset(RULES["sets"]["uploadExtensions"])
|
|
55
|
+
PRIVATE_TEXT = [(re.compile(RULES["regex"][key], re.IGNORECASE), what) for key, what in
|
|
56
|
+
(("privatePhone", "a phone number"), ("privateEmail", "an email address"), ("privateAddress", "a street address"), ("privateUrl", "a web link"))]
|
|
55
57
|
MUTATING_PATH = re.compile(RULES["regex"]["mutatingPath"], re.IGNORECASE)
|
|
56
58
|
PAYMENT_PATH = re.compile(RULES["regex"]["paymentPath"], re.IGNORECASE)
|
|
57
59
|
PAYMENT_HOST = re.compile(RULES["regex"]["paymentHost"], re.IGNORECASE)
|
|
@@ -223,6 +225,9 @@ def tool_violation(tool: str, args: object) -> str | None:
|
|
|
223
225
|
return "the value looks like a payment card number"
|
|
224
226
|
if re.fullmatch(r"\d{3}-\d{2}-\d{4}", value.strip()):
|
|
225
227
|
return "the value looks like a social security number"
|
|
228
|
+
for pattern, what in PRIVATE_TEXT:
|
|
229
|
+
if pattern.search(value):
|
|
230
|
+
return f"the value contains {what}; contact goes through the site message or mail relay only"
|
|
226
231
|
if tool == "upload_file":
|
|
227
232
|
paths = args.get("filePaths")
|
|
228
233
|
if not isinstance(paths, list) or not paths:
|
|
@@ -119,6 +119,14 @@ def _remove_own(path: Path) -> None:
|
|
|
119
119
|
path.unlink()
|
|
120
120
|
|
|
121
121
|
|
|
122
|
+
def yield_requested(profile_dir: str | Path, own_pid: int | None = None) -> dict | None:
|
|
123
|
+
"""The live want request of another process (an interactive post-fill, login or review waiting for the profile), else None; a holder that can pause calls this between pages."""
|
|
124
|
+
want = _read_json(want_path(profile_dir))
|
|
125
|
+
if want and want.get("pid") != (own_pid if own_pid is not None else os.getpid()) and pid_alive(want.get("pid")) and time.time() - float(want.get("ts") or 0) < 3600:
|
|
126
|
+
return want
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
|
|
122
130
|
def status(profile_dir: str | Path) -> dict:
|
|
123
131
|
holder = _read_json(lock_path(profile_dir))
|
|
124
132
|
live = holder if holder and pid_alive(holder.get("pid")) else None
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""push_hold.py - one repo-level "main push hold": while a session holds the default branch, no other session pushes to it (my-agents#61).
|
|
3
|
+
|
|
4
|
+
python push_hold.py status [--json] # exit 0 no hold, 3 held
|
|
5
|
+
python push_hold.py set --holder NAME --reason TEXT [--branch main] [--force]
|
|
6
|
+
python push_hold.py clear [--holder NAME] [--force]
|
|
7
|
+
python push_hold.py check [--branch main] # exit 0 may push, 1 refused
|
|
8
|
+
python push_hold.py install-hook # `set` does this already
|
|
9
|
+
python push_hold.py hook REMOTE URL # the pre-push hook entry; reads git's ref lines on stdin
|
|
10
|
+
|
|
11
|
+
The hold is one JSON file in the git common dir (shared by every worktree): holder, reason, branch, since. `set` also installs the
|
|
12
|
+
pre-push hook, which refuses any push to the held branch. The holder passes by exporting PUSH_HOLD_HOLDER=<its holder name> before
|
|
13
|
+
`ship.py`, `git push` or `tools/release.ps1`. A hold older than PUSH_HOLD_STALE_S (default 6 h) is shown STALE but still enforced;
|
|
14
|
+
`clear --force` removes any hold. Non-held branches are never affected. Nothing is killed or rewritten.
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import argparse
|
|
19
|
+
import json
|
|
20
|
+
import os
|
|
21
|
+
import subprocess
|
|
22
|
+
import sys
|
|
23
|
+
import time
|
|
24
|
+
from datetime import datetime
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
BYPASS_ENV = "PUSH_HOLD_HOLDER"
|
|
28
|
+
STALE_ENV = "PUSH_HOLD_STALE_S"
|
|
29
|
+
DEFAULT_STALE_S = 6 * 3600
|
|
30
|
+
HELD_EXIT = 3
|
|
31
|
+
HOLD_FILE = "push-hold.json"
|
|
32
|
+
HOOK_MARKER = "# push-hold-managed"
|
|
33
|
+
LEGACY_SIGNATURE = "TEMPORARY main-push hold"
|
|
34
|
+
CHAINED = "pre-push.chained"
|
|
35
|
+
|
|
36
|
+
HOOK_TEMPLATE = """#!/bin/sh
|
|
37
|
+
{marker}: installed by proxy/push_hold.py, do not edit
|
|
38
|
+
hold="$(git rev-parse --path-format=absolute --git-common-dir)/{hold_file}"
|
|
39
|
+
script="{script}"
|
|
40
|
+
input=$(cat)
|
|
41
|
+
if [ -f "$hold" ]; then
|
|
42
|
+
py=$(command -v python || command -v python3 || command -v py)
|
|
43
|
+
if [ -n "$py" ] && [ -f "$script" ]; then
|
|
44
|
+
printf '%s\\n' "$input" | "$py" "$script" hook "$@" || exit $?
|
|
45
|
+
else
|
|
46
|
+
echo "push hold: $hold exists but push_hold.py or python is missing; restore $script or delete the hold file" >&2
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
fi
|
|
50
|
+
chained="$(dirname "$0")/{chained}"
|
|
51
|
+
if [ -f "$chained" ]; then
|
|
52
|
+
printf '%s\\n' "$input" | sh "$chained" "$@" || exit $?
|
|
53
|
+
fi
|
|
54
|
+
exit 0
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _git(repo: Path, *args: str) -> str:
|
|
59
|
+
kw = {"creationflags": getattr(subprocess, "CREATE_NO_WINDOW", 0)} if os.name == "nt" else {}
|
|
60
|
+
r = subprocess.run(["git", "-C", str(repo), *args], capture_output=True, text=True, **kw)
|
|
61
|
+
if r.returncode != 0:
|
|
62
|
+
raise SystemExit(f"push_hold: git {' '.join(args)} failed in {repo}: {r.stderr.strip()}")
|
|
63
|
+
return r.stdout.strip()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def common_dir(repo: Path) -> Path:
|
|
67
|
+
return Path(_git(repo, "rev-parse", "--path-format=absolute", "--git-common-dir"))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def hold_path(repo: Path) -> Path:
|
|
71
|
+
return common_dir(repo) / HOLD_FILE
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def hook_dir(repo: Path) -> Path:
|
|
75
|
+
return Path(_git(repo, "rev-parse", "--path-format=absolute", "--git-path", "hooks"))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def read_hold(repo: Path) -> dict | None:
|
|
79
|
+
try:
|
|
80
|
+
doc = json.loads(hold_path(repo).read_text(encoding="utf-8"))
|
|
81
|
+
except (OSError, ValueError):
|
|
82
|
+
return None
|
|
83
|
+
return doc if isinstance(doc, dict) and doc.get("holder") else None
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def stale_after_s() -> float:
|
|
87
|
+
try:
|
|
88
|
+
return float(os.environ[STALE_ENV])
|
|
89
|
+
except (KeyError, ValueError):
|
|
90
|
+
return DEFAULT_STALE_S
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def is_stale(doc: dict, now: float | None = None) -> bool:
|
|
94
|
+
now = time.time() if now is None else now
|
|
95
|
+
return now - float(doc.get("since") or 0) > stale_after_s()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _age_text(since: float, now: float) -> str:
|
|
99
|
+
mins = max(0, int((now - since) // 60))
|
|
100
|
+
return f"{mins // 60}h{mins % 60:02d}m"
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def describe(doc: dict, now: float | None = None) -> str:
|
|
104
|
+
now = time.time() if now is None else now
|
|
105
|
+
since = float(doc.get("since") or 0)
|
|
106
|
+
when = datetime.fromtimestamp(since).strftime("%Y-%m-%d %H:%M:%S")
|
|
107
|
+
stale = " STALE" if is_stale(doc, now) else ""
|
|
108
|
+
return (f"{doc['branch']} push hold{stale}: held by {doc['holder']} since {when} ({_age_text(since, now)} ago): "
|
|
109
|
+
f"{doc.get('reason') or 'no reason given'}")
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def blocked_by(repo: Path, branch: str, env: dict | None = None) -> dict | None:
|
|
113
|
+
"""The hold that stops this caller pushing `branch`, or None. The holder (env PUSH_HOLD_HOLDER) passes."""
|
|
114
|
+
env = os.environ if env is None else env
|
|
115
|
+
doc = read_hold(repo)
|
|
116
|
+
if not doc or doc.get("branch") != branch or env.get(BYPASS_ENV) == doc["holder"]:
|
|
117
|
+
return None
|
|
118
|
+
return doc
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def refusal_text(doc: dict) -> str:
|
|
122
|
+
return (f"{describe(doc)}. Pushing {doc['branch']} is refused until {doc['holder']} clears it "
|
|
123
|
+
f"(`python proxy/push_hold.py clear --holder {doc['holder']}`). Nothing is lost: commit locally and retry after the hold clears. "
|
|
124
|
+
f"The holder passes with {BYPASS_ENV}={doc['holder']}.")
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def install_hook(repo: Path) -> Path:
|
|
128
|
+
"""Write the managed pre-push hook. An existing foreign hook is kept and run after the check; the legacy hand-made hold is replaced."""
|
|
129
|
+
hooks = hook_dir(repo)
|
|
130
|
+
hooks.mkdir(parents=True, exist_ok=True)
|
|
131
|
+
target, chained = hooks / "pre-push", hooks / CHAINED
|
|
132
|
+
if target.is_file():
|
|
133
|
+
text = target.read_text(encoding="utf-8", errors="replace")
|
|
134
|
+
if HOOK_MARKER not in text and LEGACY_SIGNATURE not in text:
|
|
135
|
+
if chained.exists():
|
|
136
|
+
raise SystemExit(f"push_hold: {target} is a foreign hook and {chained} already exists; merge them by hand")
|
|
137
|
+
target.replace(chained)
|
|
138
|
+
body = HOOK_TEMPLATE.format(marker=HOOK_MARKER, hold_file=HOLD_FILE, script=Path(__file__).resolve().as_posix(), chained=CHAINED)
|
|
139
|
+
target.write_bytes(body.encode("utf-8"))
|
|
140
|
+
os.chmod(target, 0o755)
|
|
141
|
+
return target
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def hook_installed(repo: Path) -> bool:
|
|
145
|
+
target = hook_dir(repo) / "pre-push"
|
|
146
|
+
return target.is_file() and HOOK_MARKER in target.read_text(encoding="utf-8", errors="replace")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def set_hold(repo: Path, holder: str, reason: str, branch: str = "main", force: bool = False, now: float | None = None) -> dict:
|
|
150
|
+
current = read_hold(repo)
|
|
151
|
+
if current and current["holder"] != holder and not force:
|
|
152
|
+
raise SystemExit(f"push_hold set: already held. {describe(current)}. The holder clears it, or pass --force.")
|
|
153
|
+
doc = {"holder": holder, "reason": reason, "branch": branch, "since": time.time() if now is None else now}
|
|
154
|
+
path = hold_path(repo)
|
|
155
|
+
tmp = path.with_name(f"{path.name}.{os.getpid()}.tmp")
|
|
156
|
+
tmp.write_text(json.dumps(doc), encoding="utf-8")
|
|
157
|
+
os.replace(tmp, path)
|
|
158
|
+
install_hook(repo)
|
|
159
|
+
return doc
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def clear_hold(repo: Path, holder: str | None = None, force: bool = False) -> bool:
|
|
163
|
+
doc = read_hold(repo)
|
|
164
|
+
if not doc:
|
|
165
|
+
return False
|
|
166
|
+
if not force and holder != doc["holder"]:
|
|
167
|
+
raise SystemExit(f"push_hold clear: {describe(doc)}. Pass --holder {doc['holder']} (or --force for a stale hold).")
|
|
168
|
+
hold_path(repo).unlink()
|
|
169
|
+
return True
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def refs_pushed(lines: list[str]) -> list[str]:
|
|
173
|
+
"""Remote refs of git's pre-push stdin lines: `<local ref> <local sha> <remote ref> <remote sha>`."""
|
|
174
|
+
return [parts[2] for parts in (ln.split() for ln in lines) if len(parts) >= 3]
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def hook_main(repo: Path, stdin_lines: list[str], env: dict | None = None) -> int:
|
|
178
|
+
for ref in refs_pushed(stdin_lines):
|
|
179
|
+
if ref.startswith("refs/heads/"):
|
|
180
|
+
doc = blocked_by(repo, ref[len("refs/heads/"):], env)
|
|
181
|
+
if doc:
|
|
182
|
+
print(f"push refused: {refusal_text(doc)}", file=sys.stderr)
|
|
183
|
+
return 1
|
|
184
|
+
return 0
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def main(argv: list[str] | None = None) -> int:
|
|
188
|
+
ap = argparse.ArgumentParser(prog="push_hold", description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
189
|
+
ap.add_argument("--repo", default=".", help="any path inside the repository (default: cwd)")
|
|
190
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
191
|
+
st = sub.add_parser("status")
|
|
192
|
+
st.add_argument("--json", action="store_true")
|
|
193
|
+
s = sub.add_parser("set")
|
|
194
|
+
s.add_argument("--holder", default=os.environ.get(BYPASS_ENV))
|
|
195
|
+
s.add_argument("--reason", required=True)
|
|
196
|
+
s.add_argument("--branch", default="main")
|
|
197
|
+
s.add_argument("--force", action="store_true")
|
|
198
|
+
c = sub.add_parser("clear")
|
|
199
|
+
c.add_argument("--holder")
|
|
200
|
+
c.add_argument("--force", action="store_true")
|
|
201
|
+
ck = sub.add_parser("check")
|
|
202
|
+
ck.add_argument("--branch", default="main")
|
|
203
|
+
sub.add_parser("install-hook")
|
|
204
|
+
h = sub.add_parser("hook")
|
|
205
|
+
h.add_argument("remote", nargs="?")
|
|
206
|
+
h.add_argument("url", nargs="?")
|
|
207
|
+
args = ap.parse_args(argv)
|
|
208
|
+
repo = Path(args.repo).resolve()
|
|
209
|
+
if args.cmd == "hook":
|
|
210
|
+
return hook_main(repo, sys.stdin.read().splitlines())
|
|
211
|
+
if args.cmd == "set":
|
|
212
|
+
if not args.holder:
|
|
213
|
+
raise SystemExit(f"push_hold set: --holder NAME is required (or set {BYPASS_ENV})")
|
|
214
|
+
print(json.dumps(set_hold(repo, args.holder, args.reason, args.branch, args.force)))
|
|
215
|
+
print(f"holder passes with: $env:{BYPASS_ENV} = '{args.holder}'", file=sys.stderr)
|
|
216
|
+
return 0
|
|
217
|
+
if args.cmd == "clear":
|
|
218
|
+
print(json.dumps({"cleared": clear_hold(repo, args.holder, args.force)}))
|
|
219
|
+
return 0
|
|
220
|
+
if args.cmd == "install-hook":
|
|
221
|
+
print(install_hook(repo))
|
|
222
|
+
return 0
|
|
223
|
+
if args.cmd == "check":
|
|
224
|
+
doc = blocked_by(repo, args.branch)
|
|
225
|
+
if doc:
|
|
226
|
+
print(f"push refused: {refusal_text(doc)}", file=sys.stderr)
|
|
227
|
+
return 1
|
|
228
|
+
return 0
|
|
229
|
+
doc = read_hold(repo)
|
|
230
|
+
installed = hook_installed(repo)
|
|
231
|
+
if args.json:
|
|
232
|
+
print(json.dumps({"held": bool(doc), "hold": doc, "stale": bool(doc) and is_stale(doc), "hook_installed": installed}))
|
|
233
|
+
else:
|
|
234
|
+
print(describe(doc) if doc else "no push hold")
|
|
235
|
+
print(f"pre-push hook: {'installed' if installed else 'NOT installed (a plain git push is not guarded)'}")
|
|
236
|
+
return HELD_EXIT if doc else 0
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
if __name__ == "__main__":
|
|
240
|
+
raise SystemExit(main())
|
|
@@ -19,6 +19,9 @@ Order: `settings.example.env` -> `~/.claude/resale/settings.env` (override: `RES
|
|
|
19
19
|
| `RESALE_EBAY_DAILY_CALL_LIMIT` | 5000 | planner stays strictly below |
|
|
20
20
|
| `RESALE_AUCTION_HORIZON_DAYS` | 7 | 1..30 |
|
|
21
21
|
| `RESALE_READER_RUNS_PER_DAY` | 4 | 1..48 |
|
|
22
|
+
| `RESALE_INQUIRY_SCAN_MINUTES` | 5 | 1..1440; minutes between Gmail scans for buyer mail |
|
|
23
|
+
| `RESALE_INQUIRY_LOOKBACK_DAYS` | 30 | 1..365; how far the first scan looks back |
|
|
24
|
+
| `RESALE_LISTING_STALE_DAYS` | 14 | 1..365; days a posted listing stays up unsold before one "renew or reprice" notice per period |
|
|
22
25
|
| `RESALE_PORTAL_PORT` | 4731 | 1024..65535, not 3456/4000/4500 |
|
|
23
26
|
| `RESALE_PORTAL_BIND` | 127.0.0.1 | loopback only |
|
|
24
27
|
| `RESALE_PROFILE_DIR` | `~/.claude/resale/chrome-profile` | path, `~` expanded |
|
|
@@ -66,14 +69,15 @@ API: `get`, `require`, `require_file`, `generated_file`, `agents_base`, `check_a
|
|
|
66
69
|
| `ingest_batches` | batch_id (PK), source, reader_run_id, captured_at, received_at, accepted | idempotency key |
|
|
67
70
|
| `own_listings` | id, item_id, source, source_listing_id, url, active, allowlisted_at | UNIQUE(source, source_listing_id) |
|
|
68
71
|
| `events` | id, event_id, kind, severity, item_id, listing_id, source, message, payload_json, occurred_at, created_at, toasted_at, acked_at | event_id UNIQUE; kind/severity CHECK |
|
|
72
|
+
| `inquiries` | id, gmail_message_id, platform, kind (`inquiry`, `notice`, `posted`), draft_id, item_id, matched_by (`url`, `posting_id`, `title`, `none`, `ambiguous`), title, buyer, sender, subject, preview, listing_url, note, received_at, created_at | gmail_message_id UNIQUE (a mail is stored once); draft_id SET NULL and item_id CASCADE on delete; migration 0024 |
|
|
69
73
|
| `edit_proposals` | id, own_listing_id, field, old_value, new_value, note, batch_id, status, created_at, decided_at, applied_at | field in title/description/price/condition; insert trigger requires active allowlisted listing |
|
|
70
74
|
| `edit_audit` | id, proposal_id, action, actor, detail_json, created_at | append-only (update/delete triggers) |
|
|
71
75
|
| `comp_reviews` | item_id, comp_key, verdict, reason, title, reviewed_at | PK (item_id, comp_key); verdict CHECK in 7 values (`match`, `equivalent`, `variant_mismatch`, `wrong_product`, `accessory_or_part`, `incomplete_set`, `duplicate_listing`; migration 0019); cascade from items; `comp_key` is `L|<source>|<listing id>` or `Q|<url>`; the stored title must equal the current one or the comp is unreviewed again |
|
|
72
76
|
| `schema_migrations` | version, name, checksum, applied_at | runner-owned |
|
|
73
77
|
|
|
74
|
-
`items.key_specs` (JSON, migration 0016): the receipt's key specs for the comps pre-filter (`item_specs` schema). Its `commodity` object (`type`, `weight`, `quantity`, optional `weight_lb`) marks plain or private-label gear whose comps may be `equivalent` (another brand, same type, weight and quantity); only marked items accept that verdict. `market_snapshots.comps_reviewed` is 1 when the item had a review when the snapshot was built; `market_snapshots.equivalent_n` (migration 0019) is how many equivalent comps the used price rests on.
|
|
78
|
+
`items.key_specs` (JSON, migration 0016): the receipt's key specs for the comps pre-filter (`item_specs` schema). Its `commodity` object (`type`, `weight`, `quantity`, optional `weight_lb`) marks plain or private-label gear whose comps may be `equivalent` (another brand, same type, weight and quantity); only marked items accept that verdict. The posting keys `make`, `model`, `model_number`, `dimensions`, `weight`, `color`, `quantity` (text, at most 120 characters, never guessed) feed the fill plan's `specs` block: `make` and `model` fall back to the item's brand and model, the rest stay empty when unset. `market_snapshots.comps_reviewed` is 1 when the item had a review when the snapshot was built; `market_snapshots.equivalent_n` (migration 0019) is how many equivalent comps the used price rests on.
|
|
75
79
|
|
|
76
|
-
Enums: sources `ebay facebook offerup craigslist cloudynights astromart` (`resale.sources.SITES`); listing_type `auction fixed classified`; listing status `active ended sold gone`; condition `New, Like new, Good, Fair, For parts`; event kinds `auction_final_minutes competitor_price_drop competitor_gone captcha_pause service_down boot_health comps_ready analysis_ready`; severity `info warn critical`.
|
|
80
|
+
Enums: sources `ebay facebook offerup craigslist cloudynights astromart` (`resale.sources.SITES`); listing_type `auction fixed classified`; listing status `active ended sold gone`; condition `New, Like new, Good, Fair, For parts`; event kinds `auction_final_minutes competitor_price_drop competitor_gone captcha_pause service_down boot_health comps_ready analysis_ready buyer_inquiry listing_notice`; severity `info warn critical`.
|
|
77
81
|
|
|
78
82
|
Retention: `purge_expired(conn, now, retention_days) -> thumbnail paths` deletes eBay listings (observations cascade) once `items.sold_at` is older than the window. Own records are kept. Caller deletes the files.
|
|
79
83
|
|
|
@@ -87,6 +91,8 @@ Host reader/notifier to container, JSON bodies, on `RESALE_PORTAL_BIND:RESALE_PO
|
|
|
87
91
|
|---|---|---|
|
|
88
92
|
| `GET /api/health` | none | `{status:'ok', schema_version, db_version}` |
|
|
89
93
|
| `POST /api/observations` | `observation_batch` | `202 {batch_id, accepted, duplicate}`; same `batch_id` again gives `duplicate:true` |
|
|
94
|
+
| `POST /api/inquiries` | `inquiry_batch` | `202 {stored, duplicates, matched, unmatched, posted_marked, events}`; matches each mail to a draft, stores it once per Gmail message id, adds one alert event, and a posting confirmation marks its draft posted |
|
|
95
|
+
| `GET /api/inquiries[?item_id=]` | none | `{inquiries:[row], listings:[{draft_id, item_id, site, count, last_at}]}`: newest 200 rows and the per-listing inquiry count and last inquiry time |
|
|
90
96
|
| `POST /api/events` | `event` | `202 {event_id, duplicate}` |
|
|
91
97
|
| `GET /api/events/pending` | none | `{events:[event + id]}` with `toasted_at` null, oldest first |
|
|
92
98
|
| `POST /api/events/{id}/delivered` | none | `204`, sets `toasted_at` |
|
|
@@ -105,6 +111,8 @@ Host reader/notifier to container, JSON bodies, on `RESALE_PORTAL_BIND:RESALE_PO
|
|
|
105
111
|
| `POST /api/bundles/<parent id>/drafts` | `{site}` | creates or refreshes the combined bundle draft and one draft per qualifying piece; drafts only, nothing is posted; `422` for an unknown site or a parent with no parts |
|
|
106
112
|
| `POST /api/drafts/<id>/status` | `{status}` (draft, posted, sold, withdrawn, stale) | `sold` updates the linked bundle and piece drafts; `422` for an unknown status or draft |
|
|
107
113
|
| `GET /api/analysis` | none | `{reports:[...]}`: the stored 7-day analysis per tracked item |
|
|
114
|
+
| `GET /api/items/condition-missing` | none | `{count, items:[{item_id, name, state, paid_cents, purchased_at}]}`: kept items (hidden_reason empty, state not dropped or sold) with no condition, most paid first |
|
|
115
|
+
| `POST /api/items/<id>/condition` | `{condition}` (New, Like new, Good, Fair, For parts; empty clears) | `{item_id, condition}`; changes only the condition; `422` for another value or an unknown item |
|
|
108
116
|
| `GET /api/post-kit` | none | `{drafts:[...]}`: every Post kit draft row of `listing_drafts` (builds them on first call) |
|
|
109
117
|
| `POST /api/analysis/run` | `{}` | `{items, complete, partial, ready, ready_event_new}`; rebuilds the reports now (the scheduler does it daily) |
|
|
110
118
|
|
|
@@ -113,6 +121,8 @@ The last three rows are proposed by T1, not in the PRD; T2 and T4 may change the
|
|
|
113
121
|
`observation_batch`: `schema_version`=1, `batch_id` (8-64 of `A-Za-z0-9_-`), `source`, `reader_run_id`, `captured_at`, `observations` (0..500; an empty list is a complete-run marker and must name `complete_item_ids`, else `422`).
|
|
114
122
|
Observation: required `item_id`, `source_listing_id`, `listing_type`, `status`; optional `url`, `title`, `price_cents`, `shipping_cents`, `currency` (USD), `condition_raw`, `bid_count`, `city`, `end_at`, `listed_at`, `thumbnail` (null or `{media_type: image/jpeg|png|webp, data_base64 <= 400000 chars}`).
|
|
115
123
|
|
|
124
|
+
`inquiry_batch`: `schema_version`=1, `scanned_at`, `messages` (0..200) of `{message_id, platform (a site), kind (inquiry, notice, posted), received_at, sender?, buyer?, subject?, preview? (<= 600), titles? (<= 8 candidate titles), refs? (listing keys like `craigslist:7812345678`), listing_url?}`; links that carry secrets (Craigslist manage links) never become a ref or a url.
|
|
125
|
+
|
|
116
126
|
`event`: required `schema_version`=1, `event_id` (8-64), `kind`, `severity`, `message` (1..500), `occurred_at`; optional `item_id`, `source`, `payload` (object).
|
|
117
127
|
|
|
118
128
|
`review_decisions`: map of item id (digits) to `{keep, reason, note?}`; `reason` is `keep:<category>` when `keep` is true, else one of `promo`, `not_purchase`, `consumable`, `accessory`, `low_value`, `digital`, `service`, `duplicate`.
|
|
@@ -206,7 +216,7 @@ Extra endpoints (JSON; same guards):
|
|
|
206
216
|
|
|
207
217
|
Pictures (`0011_item_images.sql`): `item_images(id, item_id, kind own|stock, source, file, source_url, position, created_at)` holds one row per picture file in `photos/`; `items.product_url` is the retailer page linked from the receipt (gmail-reader 1.10.0 reads it); `photo_attempts(item_id, attempted_at, outcome, detail, links_checked_at)` records stock fill tries. The cover of an item is its first own photo, else its stock photo, else the old `items.photo_path`, else the remote receipt URL, else the "No photo yet" box with an upload slot. Stock sources in order: `receipt` (receipt email image, Amazon thumbnails requested larger first), `retailer_page` (og:image of `items.product_url`), `market` (og:image of the market snapshot page), `manual_link` (the `Source:` link in the note of a manual item). Fetches are read-only GETs with a normal browser agent, https only, public addresses only (redirect hops re-checked), no login. A miss is retried after 7 days. Own photo sources: `upload` today; `phone` and `watched_folder` are reserved so a later intake plugs into `photos.add_own(conn, photos_dir, item_id, [(filename, bytes)], now, source)` and the same table. `0012_page_images.sql` adds `page_images(url, file, outcome, fetched_at)`: the cached product picture of each price-quote page, shown on the comp rows (a miss retries after 7 days). `0013_display_name_inbox.sql` adds `items.display_name` (the founder's list name; empty means the automatic short name from `resale.portal.names.clean_name`, which drops warranty and plan segments, order references and filler words and never changes `items.name`) and `folder_imports(item_id, sha, file_name, imported_at)` (a picture is imported once per item, so removing it in the portal does not bring it back). Drop folders: the container mounts the host folder `RESALE_PHOTO_INBOX` (default `<home>/Pictures/resale`, created when missing) read-write at `/inbox` (`RESALE_PHOTO_INBOX_DIR`; the host path for display is `RESALE_PHOTO_INBOX_HOST`). It creates `<item id>-<short slug>` for every visible item, imports new pictures every 30 s as own photos with source `watched_folder` once the file is 5 s old, and never changes or deletes the files. The item page shows the folder path with a Copy path button. The portal stays on loopback. Items page: one list of horizontal rows (`data-region="items-list"`, heading `Items (N rows, M items)`) holds every kept item that is not hidden or dropped, whatever its stage (candidate, selected, tracking, priced, posted, sold); there are no stage sections and no jump links, and the stage shows as a pill under the name. Layout: two sections side by side, each half of the width at every width, each scrolling vertically on its own; the page never scrolls sideways. Left is the list, right is the detail of the clicked item (empty-state text until one is clicked; a click on a row, name or `/items/{id}` link never leaves the page). The left section clips its content: the table has a fixed layout at 100% width and every cell wraps (long words break), so no header cell, selected-row highlight, bundle line, price cell or badge passes the section edge. List width 960 px and wider (`LIST_TABLE_MIN` in `portal/layout.py`): table with columns tick box (candidates only), picture, Item, Value, Paid, New now, Used now; Proof, Bought and Merchant join only when the list section has room (container query on `.split-list`: from 1160, 1290 and 1440 px, `LIST_PROOF_MIN`, `LIST_DATE_MIN`, `LIST_MERCHANT_MIN`). Narrower: each row is a card with the picture, Item and tick box on the first line and Value, Paid, New now, Used now (labelled) on the second; the sort links stay as a sticky header row. The item panel and item page always carry Merchant, Proof and Bought. The bundle line under a name is capped at 2 lines (`N pieces`, `$X paid so far`, `no price: N pieces` for the unpriced sellable pieces, never the "(bundle)" container itself; the names are in its hover and in the open piece rows; a container is not counted as a piece). Spacing tokens never change with width. `tests/test_portal_layout.py` (headless Chromium; it fails, never skips, without Chromium; CI job `resale-layout` runs it) loads the page at 1280, 1740, 2290, 2560 and 3440 px at scale 1, 1.25 and 1.5, empty and with an item selected, seeded with the worst case (14 unpriced pieces with long names, a 220-character name, a very long merchant and order number, long notes), and asserts no sideways page scroll, equal halves within 2 percent, every element of the list inside the left box, every element of the detail inside the right box, and no clipped cell. Default order is Value descending (`?sort=value_desc`). Value of a row is its Used now price when it has one, else what was paid, else none (a row with no value sorts last in both directions); the line under the number says `used now` or `paid`. A bundle row's value is the sum of the values of the main item and each piece (`bundle value`), so a bundle ranks by its whole worth; ties keep the newest row first. Every column header still sorts both ways, and the merchant filter applies to all rows. A piece that sells with a main item (note `Bundle: sells with <main> (item #id)`) shows inside the main item's row, in whatever stage the piece is; a piece folds only while its main item is shown (a merchant filter that hides a main item leaves its pieces as rows). Row actions (`/items/track`, unhide, add to list) carry `data-inplace`: the portal script posts them with fetch, re-reads the current URL and swaps the `data-region` blocks, restoring the scroll offset, open bundles (`data-key`) and ticks; without script the form posts and redirects (`/` for tracking). Price cells: New now links to the retailer or eBay page it came from; Used now `comps (n)` links its price to the listing closest to the median (`market_snapshots.url`, `.source`) and the `(n)` to `/items/{id}#comps`; an estimate has no link and says so; each linked price carries a site badge; every comp row links title and price to its listing. Split view (every width): A click on a row, card or `/items/{id}` link loads `GET /items/{id}/panel` (the item page as one column: photo, market prices with sources, top 5 comps by source, receipt and proof lines, analysis so far, drafts, My photos, forms) without leaving the page; the URL becomes `/?item={id}` (bookmarkable, back button restores, `/?item={id}` renders the panel filled), Arrow Up and Down move the selection, and any form inside the panel posts with fetch and reloads the panel and the list regions. A bundle's main item opens the combined view (pieces, sum of parts, bundle price and real bundle comps when analysed); a piece opens its own panel with a link back. Links marked `data-full` use the full pages. Price cells in the list keep the detail in the hover and wrap inside their column; an estimate's price opens the item's comps in the panel (`#comps`). Item portal routes: `POST /items/{id}/photos` (multipart, field `photos`, many files), `POST /items/{id}/photos/{image_id}/move` (`direction=up|down`), `POST /items/{id}/photos/{image_id}/remove`, `POST /items/{id}/photos/find`.
|
|
208
218
|
|
|
209
|
-
Portal (HTML): `/` items by stage with receipt tick list, `/items/{id}`, `/add`, `/own`, `/events`, `/backup`, `/thumbs/{name}`, `/photos/{name}`; form posts redirect (303).
|
|
219
|
+
Portal (HTML): `/` items by stage with receipt tick list, `/items/{id}`, `/add`, `/conditions[?ids=1,2,3]`, `POST /items/{id}/condition` (form field `condition`, 303 to `/conditions`), `/own`, `/events`, `/backup`, `/thumbs/{name}`, `/photos/{name}`; form posts redirect (303).
|
|
210
220
|
|
|
211
221
|
eBay adapter rules: Browse search (no seller fields read), `itemWebUrl` cut to `https://www.ebay.com/itm/<id>`, per tracked item per `RESALE_DISCOVERY_INTERVAL_SECONDS` two US-wide searches (all listings, then the 50 soonest-ending auctions with `buyingOptions:{AUCTION}`; the plain search returns best-match results where auctions are rare), the query is brand + model (a model with no brand gets the name's first word, a bare model code matches unrelated listings; a title that holds only the model code, without the brand word, is not a comp), then the product name without filler words and `N-in-N` descriptors, then the name without its last word, the first one that finds listings wins, discovery pauses for the day at 70% of the daily limit so auction follow-ups keep the rest, comps and followed auctions skip parts-only, for-repair, accessory-only (`... for <item>`) and eBay "For parts or not working" listings, top `RESALE_FOLLOWED_AUCTIONS_PER_ITEM` ranked auctions followed through the cadence with `getItems` batches. Auctions further from their end than the coarsest cadence step were just refreshed by the discovery search and get no follow call, only a new check time. `getItems` is a Limited Release method (the production keyset of this install is not approved for it, so follows run one item per call); on 403 or error 1100/1001/1002 the poller records `ebay_getitems_mode=single` and follows one item per call (budget still enforced, so fewer items fit). Day counter is UTC, persisted, and a call is refused when it would reach the limit. A 429 or 5xx pauses eBay for 300 s. Only items in state `tracking` inside `RESALE_TRACKING_DAYS` are polled or sent to the reader.
|
|
212
222
|
|
|
@@ -233,7 +243,7 @@ Paid (`items.paid_cents`) is the net after discounts and never changes meaning.
|
|
|
233
243
|
| Founder | a founder-entered Paid that differs from the receipt net is `unknown`; one equal to it keeps the proven tax |
|
|
234
244
|
| Order total | a sole item whose Paid is the printed order total (`price_basis = order_total`, Paid = the receipt's total) already holds the order's tax, shipping and fees: it gets the order's whole charges, its total is its Paid and `breakdown` shows the net as Paid less them; Paid itself is never rewritten |
|
|
235
245
|
| Unpriced twins | `store.supersede_unpriced_duplicates` (run by every `refilter_candidates`): an untouched row with no price whose product (names equal up to the cut) the same order already holds on a priced row leaves the queue as `filter:superseded`, one row per priced twin; a reconcile does not add such a row (`store._same_product_rows`) |
|
|
236
|
-
| Total | `inventory.paid.breakdown`: total = net + tax + shipping + fees only when the net is proven and the basis is `line_tax` or `allocated`; `comparison` = total, else the net labelled `net_only`, else none |
|
|
246
|
+
| Total | `inventory.paid.breakdown`: total = net + tax + shipping + fees only when the net is proven and the basis is `line_tax` or `allocated`; `comparison` = total, else the net labelled `net_only`, else none. While the tax is unknown a proven net above zero gets an estimate: `breakdown.estimated` is true, `tax_cents` = 7% of the net (`paid.EST_RATE_PCT`, label `tax est. 7%`), `total_cents` = net + estimate, `comparison` basis `incl_tax_est` (shipping and fees are not estimated; a sole item paid its order total is not estimated, its Paid already holds the tax); the stored `tax_basis` stays `unknown` and the real tax replaces the estimate as soon as a receipt or order page proves it |
|
|
237
247
|
| Runs | `store.save_receipt`, `store.refresh_charges` (`gmail-reprice`), `amazon_history.apply_order`, `store.refilter_candidates` and `paid-tax` call `charges.allocate_order` or `allocate_everything` inside their transaction; `updated_at` is never touched |
|
|
238
248
|
| Report | analysis report `paid` = `{net_cents, tax_cents, shipping_cents, fees_cents, total_cents, tax_basis, compare_cents, compare_basis incl_tax\|net_only\|none, above_paid:[{ask quick\|patient, ask_cents, paid_cents, basis}], bundle?:{compare_cents, compare_basis, above_paid}}` |
|
|
239
249
|
| CLI | `python -m resale.receipts.commands paid-tax [--db] [--coverage-only]` prints `{before, all, kept, visible}` counts by `line_tax`, `allocated`, `unknown` |
|
|
@@ -249,18 +259,59 @@ Ready-to-paste drafts; the founder posts by hand, nothing is automated. The kit
|
|
|
249
259
|
| Astromart | category is the name of Astromart's own classifieds category (`platforms.ASTROMART_CATEGORIES`: Telescope - Catadioptric, Telescope - Refractor, Telescope - Reflectors, Binoculars, Eyepieces, Barlows, Filters, Tripods & Piers, Mounts - Alt Az, Mounts - Equatorial, Diagonals, Focusers, Finders, CCD Cameras ASTRO, Spotting Scopes, Binoviewers, else Misc & Other Astronomy; names read from the live category pages); the description ends with `platforms.ASTROMART_PAYMENT` (cash or Zelle that must show in the bank app at pickup, no checks); each Astromart panel shows `ASTROMART_NOTE` (Type For Sale, one fixed required price with no auction or range, location from the profile, condition, shipping and payment in the description). The ad form itself is behind the Astromart login, so Type, Price, Category, Title, Description and photos are the fields known from the public pages and the site's removal rule |
|
|
250
260
|
| Title caps | facebook 100, craigslist 70, offerup 80, nextdoor 80, cloudynights 80, astromart 80, ebay 80 (kept at or under each site's limit); saved titles over the cap are refused |
|
|
251
261
|
| Price | stored analysis recommendation, else the used-now estimate (`analysis.stats.recommend`); a bundle is the sum of its priced pieces minus `RESALE_BUNDLE_DISCOUNT_PCT`, except that a bundle whose main item has no price has none (`confidence` and `price_method` `main_unpriced`, `price_cents` and `patient_cents` NULL, label `main item unpriced, no bundle price, ...`, note `main item unpriced`; `postkit.set_posted` refuses it; the analysis `bundle` block has `main_unpriced` true and null sums and prices); label `preliminary (day N of 7), confidence C` (`final` after the window, `not tracked yet` before); a weak price adds the bundle work's `check before posting` note |
|
|
262
|
+
| Round figures | every price the skill suggests, stores or prints in a listing is a round figure, never a charm price or cents (`resale.price_rule`, the one owner): $100 and up to the nearest $10, $20 to $99 to the nearest $5, under $20 to the nearest whole dollar, half rounds up (19.6 to 20, 97.5 to 100, 104 to 100, 105 to 110, 199 to 200, 1985 to 1990). Computed prices are rounded where they are made: `analysis.stats.recommend` (quick and patient), `analysis.bundle.discounted`, `postkit.pricing.bundle_quote` and `item_quote`, `service.drafts.piece_quote`. Typed prices are refused, not changed: an ask (`inventory_ops.change_state`), a stored suggestion (`publisher.pricing.store_suggestion`) and a price proposal (`proposals.validate_value`) fail with the nearest round figure named. the listing lint (`postkit.lint.price_flags`) flags a draft whose price (`patient_cents`) or quick-sale price is not round as `price $X is not a round figure: use $Y`, the flag blocks approval even for text the founder edited (withdrawing an approval is never blocked), `fill.fill_plan` refuses it, a refresh never moves the non-round price of a posted or already filled draft (the live price; only the founder's edit does), and `poster.driver.Driver.run` refuses it (`price_not_round`) before it touches the page. `python -m resale round-prices [--dry-run]` (run in the container) rounds stored suggested prices and asks of items with no posted draft, unposted draft prices and the prices inside stored analysis reports, and lists posted drafts that are not round (they are never changed) |
|
|
252
263
|
| Ad price | the ad price (`patient_cents`) is the asking price you set (`items.ask_price_cents`), else the stored suggested asking price (`suggested_price_cents`), else the analysis patient price (a bundle main item's own ask never prices the whole bundle; only a `(bundle)` container takes one); label `asking price you set` or `suggested asking price`, confidence `set`; the quick-sale floor stays in `price_cents` for you and is never the ad price; public draft text never reads `items.notes`, only `selling_notes` and generated text. |
|
|
253
264
|
| Price pending check | a price that rests on comps (analysis comp methods, or a used-now estimate whose snapshot method is `comps`), or any price while `report.comps_review.unverified > 0`, while `CompGate(conn, item).reviewed` is false is held: `price_cents` NULL, `confidence` = `pending`, label `price pending check: comps not reviewed yet, ...`; `patient_cents` keeps the indicative value only for sorting and the eBay test; the page shows no price and no price Copy buttons; a bundle is pending when any priced piece is; reviewing the comps releases the price on the next refresh |
|
|
254
265
|
| Names | `portal.names.display_name` (founder name, else cleaned receipt name), model first when the item has a model |
|
|
255
266
|
| Text | description = key specs line (from `items.key_specs`, JSON object read like `comps.specs.load_specs`), `What you get` (one line for a single item; for a bundle every piece by value under headings per family: fitness Racks & stations / Bars / Weights / Accessories, astronomy Telescope & optics / Mounts & tripods / Eyepieces & accessories, 3D printing Printer / Filament / Accessories), one condition placeholder line, optional `Originally paid $X` (service_state `postkit_show_paid`, default off), pickup-only Wylie line, cash or Zelle line; it never contains a price, so a daily price refresh never changes it; a very long bundle drops specs, shortens names, then collapses the list so the closing lines always fit 1500 characters |
|
|
256
267
|
| Titles | single and piece: model-first display name (a founder display name is used as written); bundle: the pieces by value joined with ` + ` (a real main item always first, duplicates once), then ` – <label> (N pcs)` for a `(bundle)` container or ` bundle (N pcs)`; always inside the site cap |
|
|
268
|
+
| Condition refresh | setting or changing an item's condition (`POST /api/items/{id}/condition`, the `/conditions` click, an item page edit) runs `postkit.refresh(only={item_id})` at once: only units whose item or piece is that item are rebuilt (its own drafts, and the bundle and piece drafts of any bundle or kit that holds it); posted, filled, withdrawn and missing drafts are skipped, hand-edited text is kept, no draft is created or removed; the API returns `drafts_updated`; `/conditions` shows `<item> set to <level>: N drafts updated.` |
|
|
257
269
|
| Edit protection | `gen_title` and `gen_description` hold the last generated text; a title or description that differs from them is the founder's and a refresh never overwrites it; posted drafts keep their text, only prices move; sold and withdrawn drafts are untouched; a changed text clears its approval; drafts made by the bundle API are adopted on the next refresh |
|
|
258
270
|
| Posted toggle | `postkit.set_posted(conn, draft_id, url, now)`: the URL must belong to the tab's site, is registered in `own_listings`, the item walks to `posted` one lifecycle hop at a time, the draft becomes `posted`; `clear_posted` deactivates the allowlist row and returns the item to `priced` when no site is posted. Selling goes through the bundle work's `set_status` (linked effects) |
|
|
259
271
|
| Refresh | `postkit.refresh(conn, now, zip_code=, tracking_days=, discount_pct=, piece_min_cents=)`: on the first `/post-kit` visit, on **Refresh prices now**, and after every daily analysis run |
|
|
260
272
|
| Ask check | a card whose patient or quick-sale ask is above paid incl. tax of its items (sum of the pieces for a bundle; paid before tax, labelled `tax unknown`, when any piece's tax is unproven) shows an `Ask above paid` flag with the sentence in its hover; computed live from the item columns by `analysis.paid_check` (a price pending check is never an ask) |
|
|
261
273
|
|
|
274
|
+
| Listing template | every draft of every platform is built from one template in code (`postkit/text.py` `description`), always in this order: hook line, reason for selling, `What you get` (+ `Seller's notes:` when set), `Why it's good:`, `What you can do with it:`, `Key specs:` (single items and pieces: make and model when real, then the numbers of `key_specs`; never its comps notes), `Condition:`, `Bought: <Mon YYYY> (about N months/years ago)` (+ `Originally paid` when opted in), the pickup line, the payment line (`Cash or Zelle (must show in my bank app at pickup). No checks.`, the same on every platform), then a platform extra (eBay only). Platform adapters only cut titles and shorten for the 1,500-character cap (piece specs, then use cases, then selling points, then bracketed piece details, then grouping go first); they never reorder. A missing optional section (selling points, use cases, specs, bought) is left out, never invented; a missing reason is the standard line `We are clearing out and no longer use this, so it is time to pass it on.` |
|
|
275
|
+
| Listing copy fields | migration `0025_listing_copy.sql`: `items.copy_hook` (at most 120 characters), `copy_reason` (300), `copy_points` and `copy_uses` (one per line, at most 6 lines of 200); edited in the item page (Edit), `inventory_ops.update_item`, or in bulk with `python -m resale copy-apply [--dry-run] <json|file|->` (a JSON list of `{id, hook, reason, points[], uses[]}`, every field optional; checked by `service/copy_plan.py`: plain public wording, hook names its item; a field already set is skipped, never overwritten). A bundle's copy lives on its main item (or its `(bundle)` container); a piece has its own. The condition line is the item's own `condition` (a bundle: its main item's, else the worst piece when every piece has one); with none set it stays the `[condition: ... confirm]` placeholder, so the draft fails the lint until the founder sets it |
|
|
276
|
+
| Listing lint | `postkit/lint.py`, run on every generated draft at refresh, on every saved text and again at approve, stored in `listing_drafts.lint_flags` (JSON list; migration 0025) and shown in the portal: the first line is the hook (at most 160 characters) and names the item; sections are in template order and the condition, pickup, payment and what-you-get sections exist; the condition is confirmed; no email, phone number or street address; no internal notes (item `notes` sentences, `Review:`, `(item #n)`, `check comps` and the like); no dollar amount except the opt-in `Originally paid` line; no hype wording or `!`; at most 1,500 characters. A failing generated draft loses its approval and `approve` refuses it (HTTP 400 with the failed rules); text the founder wrote is blocked only by the privacy and price rules (contact, internal notes, price) |
|
|
277
|
+
| New copy | when the generated text changes under a draft the founder edited, the founder's text is kept and the draft gets the note `new copy available` with the generated title and description in `new_title` and `new_description` (migration 0025; the portal shows them under the tab, **Reset to generated** takes them); a posted draft keeps its live text and also shows the new copy; refresh reports `new_copy` |
|
|
278
|
+
|
|
262
279
|
Routes: `GET /post-kit[?platform=&family=&sort=]`, `POST /post-kit/refresh`, `POST /post-kit/settings`, `POST /post-kit/drafts/{id}/(text|approve|reset|posted|unpost)`.
|
|
263
280
|
|
|
281
|
+
## Selling lifecycle (`resale.postkit.selling`, `resale.postkit.health`, `/selling`)
|
|
282
|
+
|
|
283
|
+
Migration `0026_selling_lifecycle.sql`: `items.sold_site`; `listing_drafts.takedown_due_at`, `taken_down_at`, `health` (`live|gone|unknown`), `health_note`, `health_checked_at`.
|
|
284
|
+
|
|
285
|
+
- `selling.mark_sold(conn, item_id, now, price=, site=, sold_on=)`: item must be `posted`; price is required (> 0); `sold_on` is `YYYY-MM-DD` (empty = now, a future day is refused) stored as noon UTC; `site` must have a posted draft of the item, or `None` for "sold somewhere else". One transaction: the item becomes `sold` with `sold_price_cents`, `sold_at`, `sold_site`; the sold draft becomes `sold` (link effects of `service.drafts.link_effects` apply); every other posted draft of the item or its link group becomes `withdrawn` with `takedown_due_at = now`; unposted drafts become `withdrawn` with no takedown; all their allowlist entries are deactivated. Any refusal changes nothing.
|
|
286
|
+
- `selling.takedown_list` returns drafts with `takedown_due_at` and no `taken_down_at` (site, address, last check); `confirm_taken_down` sets `taken_down_at` once (repeat is a no-op).
|
|
287
|
+
- `health.classify(site, status, url, html, listing_url)` (in `sources/listing_page.py`, no browser, no database): 404 or 410 is `gone`; 401, 403, 429, 5xx, no answer or a sign-in address is `unknown`; a site message ("this posting has expired", "this listing isn't available", "no longer available" and so on, data in `GONE_TEXT`) or an address that no longer holds the listing id is `gone`; otherwise `live`. A wall is never `live`.
|
|
288
|
+
- `health.record_check(conn, draft_id, state, note, now)`: `unknown` keeps the last known state and only stamps the check; `gone` raises one `listing_notice` warning per outage (event id `gone-<draft>-<time>`) and, for a draft waiting for takedown, sets `taken_down_at` with no alert; `live` after `gone` re-arms the alert. A site mail whose subject says expired, removed, flagged or rejected (`notice_means_gone`) records `gone` without a second alert.
|
|
289
|
+
- `health.checks_due(conn, now, interval_seconds=21600)`: posted or stale drafts with an address, plus takedown drafts not yet confirmed, not read in the interval. `health.age_nudges(conn, now, stale_days)`: one `listing_notice` info event per draft per `stale_days` period (event id `age-<draft>-<period>`), run hourly by the scheduler, with the inquiry count.
|
|
290
|
+
- Host: `python -m resale check-listings` (`sources/own_check.py`) reads `GET /api/own-checks` and posts `POST /api/drafts/{id}/health {state, note}`; it uses `open_page` (read-only page methods, headless, shared profile lock), pauses 6 seconds between pages, reads at most 12 per run, stops on a captcha or rate limit without recording that listing, and is run at the end of every `ResaleReader` tick.
|
|
291
|
+
- Routes: `GET /selling`, `GET /api/takedowns`, `GET /api/own-checks`, `POST /api/drafts/{id}/health`, `POST /post-kit/drafts/{id}/sold` (form `price`, `sold_on`), `POST /post-kit/drafts/{id}/taken-down`; `POST /items/{id}/state` with `target=sold` now takes `sold`, `sold_on` and `site`.
|
|
292
|
+
|
|
293
|
+
## Buyer inquiries (`resale.inquiries`, `/inquiries`)
|
|
294
|
+
|
|
295
|
+
Host: the hidden `ResaleNotifier` task runs `inquiries.scan.run_due` on every tick; a scan happens when `RESALE_INQUIRY_SCAN_MINUTES` have passed since the last one (`python -m resale inquiries-scan [--dry-run|--status]` runs one now). It lists Gmail with `({from:craigslist.org OR from:astromart.com OR from:ebay.com OR from:facebookmail.com OR from:offerup.com OR from:cloudynights.com}) after:<epoch>` through gmail-reader (`messages.list` and `messages.get` only), classifies each unseen mail (`parse.classify`, rules as data in `rules.py`), and posts the hits as one `inquiry_batch`. State file `RESALE_DATA_DIR/inquiry_scan.json`: `seen` message ids (so a mail is fetched once), `last_ok_at` (the next query starts a day before it), `last_started_at`, `last_error`, `error_event_at`. A scan that fails (no Gmail consent, HTTP error, container down) is recorded in `last_error` and raises one `service_down` event per 24 hours; it never stops the toasts of the same tick. The mail is never replied to, sent, labelled or deleted (`tests/test_inquiries_scan.py` lints the package and spies on the Gmail client).
|
|
296
|
+
|
|
297
|
+
| Mail | Kind | Rule |
|
|
298
|
+
|---|---|---|
|
|
299
|
+
| Craigslist relay mail (any non-system `*@*.craigslist.org` sender that is not a posting or notice mail) | `inquiry` | the buyer is the sender's display name; the listing is found by Posting ID or link, then by title |
|
|
300
|
+
| Craigslist `POST/EDIT/DELETE : <title>` mail from the robot that says the posting can be seen at, or is live or published | `posted` | carries the listing link; manage links (they hold a secret token) are never kept |
|
|
301
|
+
| Craigslist robot mail about expiring, flagged or removed postings | `notice` | |
|
|
302
|
+
| Astromart `<buyer> responded to <title>` (body: `You have a new response by <buyer> to your classified ad`) | `inquiry` | the `RECEIPT: ...` copy of the founder's own response to someone else's ad, purchase confirmations and account mail are ignored |
|
|
303
|
+
| Astromart ad posted or approved, and expiring or rejected notices | `posted`, `notice` | |
|
|
304
|
+
| eBay member messages, questions and offers about an item (item number or `/itm/` link) | `inquiry` | deals, saved searches, order, payment and account mail are ignored |
|
|
305
|
+
| Facebook (`facebookmail.com`) and OfferUp messages and offers; OfferUp item live; Cloudy Nights messages | `inquiry`, `posted` | Facebook needs a Marketplace or listing word in the mail; log-in and security mail is ignored |
|
|
306
|
+
|
|
307
|
+
Match rules (`match.find`, container side), first rule that gives exactly one draft wins:
|
|
308
|
+
|
|
309
|
+
1. Listing link or id: a link or id in the mail (`craigslist:<posting id>`, `ebay:<item number>`, `astromart:<slug>`, `facebook:<id>`) equals the key of a draft's `listing_url` or registered own listing on the same site: `matched_by` is `posting_id` (Craigslist, eBay) or `url`.
|
|
310
|
+
2. Title: the mail's title candidates (subject without `Re:`, price and place; the title in the body) against the draft's title and generated title on the same site. Score 3 same words, 2 one title inside the other (3+ words and 15+ letters), 1 nearly the same word set (4+ words, 85 percent); the highest score wins. An inquiry prefers a posted draft on a tie; a posting confirmation prefers a draft that is not yet posted. Anything else tied is `ambiguous`.
|
|
311
|
+
3. Otherwise `none`. An `ambiguous` or `none` mail is stored with no draft and still raises its alert, saying it matches no single listing; the code never guesses between two drafts.
|
|
312
|
+
|
|
313
|
+
Container (`inquiries.store.ingest`): one `inquiries` row per Gmail message id (a repeat scan stores nothing and alerts nothing), plus one event (already marked toasted when the mail is older than 2 days) (`buyer_inquiry` info, `listing_notice` warn or info) with the item id, shown on the item's Events list, `/events` and as a silent toast through `ResaleNotifier`. A `posted` mail that matches one draft runs `postkit.set_posted(draft, listing_url)` (the Posted toggle: draft posted, item posted, link added to My listings); a draft already posted with its link changes nothing and stays quiet; a refusal (for example an unpriced bundle) is saved in `inquiries.note` and alerted as a warning. Per-listing count and last time: `inquiries.queries.listing_stats` (inquiries of kind `inquiry` per draft), shown on the item page table, the Post kit Posted line and `GET /api/inquiries`.
|
|
314
|
+
|
|
264
315
|
## Reader and notifier (`resale.sources`, `tasks/`)
|
|
265
316
|
|
|
266
317
|
Host side, read-only. `python -m resale read` loads search and detail pages with an installed Chrome on `RESALE_PROFILE_DIR`, sends `observation_batch` bodies (with `complete_item_ids` only for searches that finished) to the container, and stops the whole run on a captcha, login wall or rate limit (a `captcha_pause` event, retried next run). Site modules: facebook, offerup, craigslist, cloudynights, astromart. Browser surface: `readonly.ReadOnlyPage` (navigate, page text, scroll, cookie names, image GET); `readonly_lint.py` and `test_reader_lint.py` fail on any other Playwright call.
|
|
@@ -269,16 +320,19 @@ Host side, read-only. `python -m resale read` loads search and detail pages with
|
|
|
269
320
|
|---|---|
|
|
270
321
|
| `read [--due] [--site S] [--budget N] [--min-delay S]` | 0 ok, 1 attention, 2 usage, 3 profile busy, 4 browser unavailable |
|
|
271
322
|
| `check-logins [--site S] [--text]` | same; JSON by default; writes `logins.json` |
|
|
272
|
-
| `notify [--no-boot-check]` | silent toasts for unseen events, once-per-boot health check |
|
|
323
|
+
| `notify [--no-boot-check]` | Gmail scan for buyer mail when due, then silent toasts for unseen events, once-per-boot health check |
|
|
324
|
+
| `inquiries-scan [--dry-run] [--status]` | 0 ok, 1 the scan failed (Gmail or container); runs the buyer mail scan now (`--dry-run` prints what it would send and remembers nothing) |
|
|
273
325
|
| `browser-audit [--tail N] [--since-hours H] [--json] [--set-item ID\|--clear-item] [--resale-dir D]` | 0 ok, 2 usage; prints the browser write audit log summary and the last N records |
|
|
274
326
|
| `review [--list] [--url U] [--hours H]` | 0 ok, 2 usage (not a terminal, nothing waiting, no Chrome), 3 profile busy; founder only, opens a visible Chrome on `RESALE_PROFILE_DIR` at the `ready_for_review` pages of the last H hours (default 48) that no `review_opened` event covers, then logs `review_opened` |
|
|
275
|
-
| `post-fill <draft_id
|
|
327
|
+
| `post-fill <draft_id>... [--review-window]` | 0 ok, 1 attention (warnings, logged out, a step failed), 2 usage (draft refused, no adapter, container down), 3 profile busy (also: a review window is already open), 4 window not alive (`window_not_alive`, `holder_died`, `fill_timeout`, `holder_launch_failed`); with `--review-window` one JSON line `{window_pid, holder_pid, title, tabs[{site, draft_id, stopped_before, unfilled}], breakaway}` printed only after every tab reached `ready_for_review` and holder, Chrome and window title were verified alive; without it a JSON summary of the headless dry run |
|
|
328
|
+
| `post-status` | 0 a review window is open, 1 not open; JSON `{open, state, holder_pid, window_pid, title, tabs, drafts}` from live state (`none`, `starting`, `filling`, `ready`, `closed`, `error`, `dead` when the recorded holder is gone) |
|
|
329
|
+
| `post-hold <draft_id>...` | internal: the detached owner of the review window (profile lock, Chrome, fill, wait for the founder); writes `<resale>/audit/poster-review-window.json`; started only by `post-fill --review-window` |
|
|
276
330
|
| `post-confirm <draft_id> [--url U]` | 0 ok, 2 refused (draft not postable); marks posted via `POST /api/drafts/<id>/posted` |
|
|
277
331
|
| `amazon-orders [--list] [--status] [--years Y,Y] [--since D] [--max-orders N] [--min-delay S] [--retry] [--force]` | 0 ok, 1 attention (wall, errors, unreadable page), 2 usage, 3 profile busy; headless, read-only (order-details and order-history pages only), takes the profile lock and `reader.lock`; state `amazon_orders.json` (per-order status, last wall, last report); stops on the first captcha, sign-in or rate-limit page, raises a `captcha_pause` event (payload site `amazon`) and pauses 6 h; `login --site amazon` and `check-logins` cover its login |
|
|
278
332
|
|
|
279
333
|
Browser tool (`chrome-devtools` MCP, `mcps/chrome_devtools_gate.js`, `mcps/chrome_devtools_policy.js`): headless on `RESALE_PROFILE_DIR` under the shared profile lock. Child flags are fixed: `categoryInput=true`, `javascriptEvaluation=false`, `headless=true`, two `--workspace` folders (`<resale>/uploads`, `<resale>/data/photos`, the only accepted values). Tools: the 12 read tools plus `click fill fill_form type_text upload_file press_key hover drag handle_dialog`. Per-call checks before any write: the open page is read with `list_pages` (fail closed), then page rules (Gmail and Google account pages, checkout and payment hosts and paths, login paths for text entry), element rules from the last snapshot the gate saw (purchase, bid, offer, subscribe, boost, promote, log out, account delete, password, card, CVV and bank fields; a password field anywhere on the page blocks text entry), value rules (Luhn card numbers, SSN) and upload rules (inside the two folders, allowed extension). Fill only: `mcps/chrome_devtools_final_actions.json` (deployed next to the gate; the gate refuses to start without it) lists final submit and publish control names (generic `exact` names for button and menu roles, `contains` regexes for every clickable role, per-site `exact` additions by host, `nextIsFinal`). `click` on such a control is refused; `press_key` Enter or Space on a focused final control, and Enter (also `type_text` `submitKey`) in a single-line field of a page that has a final control, are refused (Enter in a multiline box is a newline). The gate adds the local tool `ready_for_review {pageId?, item?, draftSaved?, note?}`: it reads the open page, logs `event: ready_for_review` (`draftSaved`, `note`, `url`, `site`, `item`) and never reaches the browser. Audit: `<resale>/audit/browser-writes.jsonl`, one JSON object per line, `event` is `sent`, `result` (`ok`, `error`, `aborted`), `blocked`, `ready_for_review` or `review_opened`; fields `ts gatePid callId tool site url urlRef item element uid value|fields|files reason outcome detail`; `item` comes from `<resale>/audit/current-item.json` (`{"item": id}`); the file rotates to `.1` at 5 MB.
|
|
280
334
|
|
|
281
|
-
Poster (`resale/poster`): container routes `GET /api/drafts/<id>/fill-plan` (409 with the reason when the draft is not approved, current, priced and photographed), `POST /api/drafts/<id>/filled {note}` (sets `listing_drafts.filled_at`, `fill_note`; migration 0022) and `POST /api/drafts/<id>/posted {url?}` (the Posted toggle). The fill plan holds `draft_id item_id site kind create_url category title price_cents condition description zip photos[] price_label review_note`; `price_cents` is the ad price (`patient_cents`); photos are own photo file names under `<RESALE_DATA_DIR>/photos` in portal order (a bundle adds its pieces). Adapters are data (`Step(kind, target, value, label)` with kinds text, rich, select, check, radio, combo, upload, click, choose (pick a radio, press continue), warn_unless; an adapter can set `photo_types` and `hooks`, or `unsupported` for a site with no web form); the driver checks the page address, the field label, the control name and the upload path against the shared rules before every action, writes `poster_fill`, `poster_warning`, `blocked`, `ready_for_review` and `posted_detected` audit events, and has no submit method.
|
|
335
|
+
Poster (`resale/poster`): container routes `GET /api/drafts/<id>/fill-plan` (409 with the reason when the draft is not approved, current, priced and photographed), `POST /api/drafts/<id>/filled {note}` (sets `listing_drafts.filled_at`, `fill_note`; migration 0022) and `POST /api/drafts/<id>/posted {url?}` (the Posted toggle). The fill plan holds `draft_id item_id site kind create_url category title price_cents condition description zip photos[] price_label review_note specs`; `specs` is `{make, model, model_number, dimensions, weight, color, quantity}` (text, empty when unknown, built from the item brand, model and `key_specs`); `price_cents` is the ad price (`patient_cents`); photos are own photo file names under `<RESALE_DATA_DIR>/photos` in portal order (a bundle adds its pieces). Adapters are data (`Step(kind, target, value, label)` with kinds text, rich, select, check, off (untick), menu (open a menu button that announces aria-haspopup; the only way a button named like Post is pressed), pick (a picker path a > b > c), chip, radio, combo, upload, click, choose (pick a radio, press continue), warn_unless; an adapter can set `photo_types` and `hooks`, or `unsupported` for a site with no web form); the driver checks the page address, the field label, the control name and the upload path against the shared rules before every action, writes `poster_fill`, `poster_warning`, `blocked`, `ready_for_review` and `posted_detected` audit events, and has no submit method. An `optional` step is skipped, and reported in the run's `unfilled` list, when the draft has no value for it or the form does not offer the field; the poster also lists any other visible empty box (`gap_scope`, `gap_ignore` per adapter).
|
|
282
336
|
|
|
283
337
|
Defaults per run: 8 page loads per target (so every tracked item is read each run; `--budget N` sets a fixed cap), 4 s minimum delay plus jitter, 60 listings and 24 thumbnails per target, 5 detail pages per target, detail cache 7 days. State files in `RESALE_DATA_DIR`: `reader_state.json`, `detail_cache.json`, `reader.lock`, `logins.json`.
|
|
284
338
|
|