work-packet 0.1.0__py3-none-any.whl
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.
- work_packet/__about__.py +9 -0
- work_packet/__init__.py +2 -0
- work_packet/__main__.py +3 -0
- work_packet/actions.py +281 -0
- work_packet/archived.py +161 -0
- work_packet/attention.py +175 -0
- work_packet/bghook.py +60 -0
- work_packet/blobs.py +71 -0
- work_packet/brief.py +622 -0
- work_packet/briefagent.py +470 -0
- work_packet/briefing.py +167 -0
- work_packet/card.py +423 -0
- work_packet/check.py +399 -0
- work_packet/checkpoint.py +202 -0
- work_packet/cli.py +3761 -0
- work_packet/clock.py +220 -0
- work_packet/closeout.py +737 -0
- work_packet/convert.py +151 -0
- work_packet/cost.py +126 -0
- work_packet/credentials.py +276 -0
- work_packet/ctxhook.py +178 -0
- work_packet/dash/__init__.py +1 -0
- work_packet/dash/agent.py +524 -0
- work_packet/dash/app.py +3292 -0
- work_packet/dash/board.js +142 -0
- work_packet/dash/compose.js +25 -0
- work_packet/dash/console.js +247 -0
- work_packet/dash/console.py +617 -0
- work_packet/dash/crawl.py +72 -0
- work_packet/dash/data.py +2215 -0
- work_packet/dash/desk.js +183 -0
- work_packet/dash/desk.py +113 -0
- work_packet/dash/dfmrun.py +297 -0
- work_packet/dash/events.py +237 -0
- work_packet/dash/guard.py +355 -0
- work_packet/dash/ide.js +18 -0
- work_packet/dash/ide.py +1660 -0
- work_packet/dash/ide_desk.js +103 -0
- work_packet/dash/ide_forward.js +22 -0
- work_packet/dash/ide_forward.py +285 -0
- work_packet/dash/ide_presence.js +29 -0
- work_packet/dash/live.js +37 -0
- work_packet/dash/login.py +346 -0
- work_packet/dash/markup.js +191 -0
- work_packet/dash/markup.py +287 -0
- work_packet/dash/new.js +308 -0
- work_packet/dash/newjobs.py +154 -0
- work_packet/dash/notify.js +54 -0
- work_packet/dash/packets.js +66 -0
- work_packet/dash/page.js +50 -0
- work_packet/dash/pane.js +40 -0
- work_packet/dash/panels.py +154 -0
- work_packet/dash/plan.py +465 -0
- work_packet/dash/render_gate.py +92 -0
- work_packet/dash/resolve.js +131 -0
- work_packet/dash/restart.py +125 -0
- work_packet/dash/runner.py +298 -0
- work_packet/dash/sched.js +21 -0
- work_packet/dash/sched.py +159 -0
- work_packet/dash/server.py +638 -0
- work_packet/dash/shell.js +168 -0
- work_packet/dash/shells.py +265 -0
- work_packet/dash/studio.js +572 -0
- work_packet/dash/studio.py +1038 -0
- work_packet/dash/studio_chart.js +136 -0
- work_packet/dash/studio_edit.js +61 -0
- work_packet/dash/studio_files.js +323 -0
- work_packet/dash/studio_wait.js +5 -0
- work_packet/dash/tailscale.py +113 -0
- work_packet/dash/templates/_answer.html +65 -0
- work_packet/dash/templates/_autoopen.html +11 -0
- work_packet/dash/templates/_close.html +61 -0
- work_packet/dash/templates/_console.html +28 -0
- work_packet/dash/templates/_dfm.html +53 -0
- work_packet/dash/templates/_inbox.html +33 -0
- work_packet/dash/templates/_log.html +23 -0
- work_packet/dash/templates/_markup_css.html +23 -0
- work_packet/dash/templates/_note.html +17 -0
- work_packet/dash/templates/_open.html +26 -0
- work_packet/dash/templates/_outline.html +44 -0
- work_packet/dash/templates/_panels.html +7 -0
- work_packet/dash/templates/_pause.html +44 -0
- work_packet/dash/templates/_plan.html +26 -0
- work_packet/dash/templates/_project_tasks.html +26 -0
- work_packet/dash/templates/_report.html +56 -0
- work_packet/dash/templates/_sched.html +68 -0
- work_packet/dash/templates/_settings.html +37 -0
- work_packet/dash/templates/_side.html +32 -0
- work_packet/dash/templates/_snapshot.html +47 -0
- work_packet/dash/templates/_tabs.html +111 -0
- work_packet/dash/templates/_tokens.html +130 -0
- work_packet/dash/templates/_vscode.html +37 -0
- work_packet/dash/templates/backlog.html +56 -0
- work_packet/dash/templates/base.html +299 -0
- work_packet/dash/templates/board.html +290 -0
- work_packet/dash/templates/brief.html +75 -0
- work_packet/dash/templates/close.html +62 -0
- work_packet/dash/templates/closed.html +24 -0
- work_packet/dash/templates/closed_one.html +47 -0
- work_packet/dash/templates/compose.html +163 -0
- work_packet/dash/templates/console_list.html +19 -0
- work_packet/dash/templates/console_view.html +28 -0
- work_packet/dash/templates/desk.html +78 -0
- work_packet/dash/templates/doc.html +36 -0
- work_packet/dash/templates/docs_wait.html +19 -0
- work_packet/dash/templates/ide_open.html +20 -0
- work_packet/dash/templates/job.html +17 -0
- work_packet/dash/templates/learn.html +16 -0
- work_packet/dash/templates/live.html +117 -0
- work_packet/dash/templates/missing.html +11 -0
- work_packet/dash/templates/new.html +126 -0
- work_packet/dash/templates/overview.html +326 -0
- work_packet/dash/templates/packet.html +272 -0
- work_packet/dash/templates/packets.html +103 -0
- work_packet/dash/templates/plan.html +132 -0
- work_packet/dash/templates/project.html +69 -0
- work_packet/dash/templates/project_console.html +14 -0
- work_packet/dash/templates/project_cost.html +30 -0
- work_packet/dash/templates/project_settings.html +23 -0
- work_packet/dash/templates/project_steps.html +36 -0
- work_packet/dash/templates/project_tasks.html +13 -0
- work_packet/dash/templates/rhythm.html +36 -0
- work_packet/dash/templates/run.html +99 -0
- work_packet/dash/templates/runs.html +19 -0
- work_packet/dash/templates/sched.html +181 -0
- work_packet/dash/templates/settings.html +46 -0
- work_packet/dash/templates/shutdown.html +33 -0
- work_packet/dash/templates/stats.html +113 -0
- work_packet/dash/templates/step.html +121 -0
- work_packet/dash/templates/studio.html +178 -0
- work_packet/dash/templates/studio_chart.html +63 -0
- work_packet/dash/templates/studio_frame.html +27 -0
- work_packet/dash/templates/studio_table_frame.html +26 -0
- work_packet/dash/templates/task.html +64 -0
- work_packet/dash/tls.py +198 -0
- work_packet/dash/tokens.py +640 -0
- work_packet/dash/vendor/codemirror/codemirror.js +35 -0
- work_packet/dash/vendor/draw/chunks/abnfDiagram-VCTEODGH-IYHP3IKK.js +1 -0
- work_packet/dash/vendor/draw/chunks/ar-SA-G6X2FPQ2-KEJZLJKC.js +10 -0
- work_packet/dash/vendor/draw/chunks/architecture-7GRP2DOG-2Z5WCH7N.js +1 -0
- work_packet/dash/vendor/draw/chunks/architectureDiagram-5GKGNRK7-6IPZX4AZ.js +36 -0
- work_packet/dash/vendor/draw/chunks/az-AZ-76LH7QW2-7N7KEOCQ.js +1 -0
- work_packet/dash/vendor/draw/chunks/bg-BG-XCXSNQG7-HBXPEYW3.js +5 -0
- work_packet/dash/vendor/draw/chunks/blockDiagram-I7D4REHJ-HIFF6SER.js +129 -0
- work_packet/dash/vendor/draw/chunks/bn-BD-2XOGV67Q-6CR6S4VC.js +5 -0
- work_packet/dash/vendor/draw/chunks/c4Diagram-7LVT6UL2-Y4HANMKS.js +38 -0
- work_packet/dash/vendor/draw/chunks/ca-ES-6MX7JW3Y-ZSE2E6LE.js +8 -0
- work_packet/dash/vendor/draw/chunks/chunk-2A6SUL6G.js +11 -0
- work_packet/dash/vendor/draw/chunks/chunk-2A6SUL6G.js.LEGAL.txt +7 -0
- work_packet/dash/vendor/draw/chunks/chunk-3WSYJLFQ.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-4GVQQSXF.js +2 -0
- work_packet/dash/vendor/draw/chunks/chunk-57H65VIK.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-5WBZJIWU.js +3 -0
- work_packet/dash/vendor/draw/chunks/chunk-5XG7XPNZ.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-6M4R4AFF.js +15 -0
- work_packet/dash/vendor/draw/chunks/chunk-6XR5RTUC.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-A5OTNI3R.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-AXGGC3JO.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-B2JFCMGE.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-CXPI5MBX.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-DFOXX6I4.js +231 -0
- work_packet/dash/vendor/draw/chunks/chunk-DGMO5G7F.js +62 -0
- work_packet/dash/vendor/draw/chunks/chunk-DH3UA6CM.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-DWHQWEYA.js +2 -0
- work_packet/dash/vendor/draw/chunks/chunk-DWHQWEYA.js.LEGAL.txt +12 -0
- work_packet/dash/vendor/draw/chunks/chunk-E4KINRNQ.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-E6R25O4I.js +206 -0
- work_packet/dash/vendor/draw/chunks/chunk-EEVTYQYK.js +322 -0
- work_packet/dash/vendor/draw/chunks/chunk-EEVTYQYK.js.LEGAL.txt +17 -0
- work_packet/dash/vendor/draw/chunks/chunk-ETOMFKZJ.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-FOIVC3BR.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-GGAT5HMK.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-GKM4W5P2.js +128 -0
- work_packet/dash/vendor/draw/chunks/chunk-GKM4W5P2.js.LEGAL.txt +5 -0
- work_packet/dash/vendor/draw/chunks/chunk-H4FYLJME.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-HGJHQCPF.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-HHQUKJHL.js +2 -0
- work_packet/dash/vendor/draw/chunks/chunk-IS3RX4DZ.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-IYCTUSGP.js +2 -0
- work_packet/dash/vendor/draw/chunks/chunk-K4BSAQ4O.js +10 -0
- work_packet/dash/vendor/draw/chunks/chunk-KNE6VAJC.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-KRICN4CP.js +32 -0
- work_packet/dash/vendor/draw/chunks/chunk-MJLMSHIR.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-MOYIBIMG.js +7 -0
- work_packet/dash/vendor/draw/chunks/chunk-NCSVWE73.js +19 -0
- work_packet/dash/vendor/draw/chunks/chunk-NWKTNFXW.js +35 -0
- work_packet/dash/vendor/draw/chunks/chunk-NWKTNFXW.js.LEGAL.txt +26 -0
- work_packet/dash/vendor/draw/chunks/chunk-NZE35NHD.js +162 -0
- work_packet/dash/vendor/draw/chunks/chunk-NZE35NHD.js.LEGAL.txt +16 -0
- work_packet/dash/vendor/draw/chunks/chunk-OFOH6VT4.js +168 -0
- work_packet/dash/vendor/draw/chunks/chunk-OTJMTYEK.js +2 -0
- work_packet/dash/vendor/draw/chunks/chunk-PMH6RVNG.js +23 -0
- work_packet/dash/vendor/draw/chunks/chunk-PMH6RVNG.js.LEGAL.txt +67 -0
- work_packet/dash/vendor/draw/chunks/chunk-PQZIXT6L.js +12 -0
- work_packet/dash/vendor/draw/chunks/chunk-REYPBTG2.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-TCGTRZFC.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-UEXIOLKA.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-UJJQB6FQ.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-UKWDWKKQ.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-V2JVHE45.js +72 -0
- work_packet/dash/vendor/draw/chunks/chunk-VCMTQKGO.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-VS6DJ7TG.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-WWJTG7EC.js +88 -0
- work_packet/dash/vendor/draw/chunks/chunk-X3JYDHLS.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-XN7N7522.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-YMWFUA6I.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-YSBIDXHK.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-ZBMVOOGI.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-ZCPSHBYU.js +1 -0
- work_packet/dash/vendor/draw/chunks/chunk-ZQNYZDUV.js +1 -0
- work_packet/dash/vendor/draw/chunks/classDiagram-ZZMXUADV-A3HYCVIK.js +1 -0
- work_packet/dash/vendor/draw/chunks/classDiagram-v2-VYDZK3BY-OR3UKMCB.js +1 -0
- work_packet/dash/vendor/draw/chunks/cose-bilkent-JH36ORCC-ZBHMVVRC.js +1 -0
- work_packet/dash/vendor/draw/chunks/cs-CZ-2BRQDIVT-WAS2JIES.js +11 -0
- work_packet/dash/vendor/draw/chunks/cynefin-OW5HDTMX-DNKJZJNJ.js +1 -0
- work_packet/dash/vendor/draw/chunks/cynefinDiagram-5FMLGOSQ-WZR4IPO2.js +62 -0
- work_packet/dash/vendor/draw/chunks/da-DK-5WZEPLOC-Y3K4BJKR.js +5 -0
- work_packet/dash/vendor/draw/chunks/dagre-GXQ25YYZ-NMUGD2TZ.js +4 -0
- work_packet/dash/vendor/draw/chunks/de-DE-XR44H4JA-R4WZKVJM.js +8 -0
- work_packet/dash/vendor/draw/chunks/diagram-S7CK7UJ4-KHOFK7GC.js +30 -0
- work_packet/dash/vendor/draw/chunks/diagram-UQ7AKVKN-3RLQX3F5.js +41 -0
- work_packet/dash/vendor/draw/chunks/diagram-VSXAHHWV-GXRQZGLU.js +3 -0
- work_packet/dash/vendor/draw/chunks/diagram-VX7I27RA-6PVSGYKP.js +24 -0
- work_packet/dash/vendor/draw/chunks/diagram-Z3DM3KII-YO2BWTGT.js +24 -0
- work_packet/dash/vendor/draw/chunks/directory-open-01563666-NLU3R3YR.js +1 -0
- work_packet/dash/vendor/draw/chunks/directory-open-4ed118d0-XLHSEDDC.js +1 -0
- work_packet/dash/vendor/draw/chunks/dist-X7FFHJYY.js +1 -0
- work_packet/dash/vendor/draw/chunks/ebnfDiagram-PWID7BFC-LIYXDZ32.js +1 -0
- work_packet/dash/vendor/draw/chunks/el-GR-BZB4AONW-V3KZ7AFO.js +10 -0
- work_packet/dash/vendor/draw/chunks/en-B4ZKOASM-YYJQHWSP.js +1 -0
- work_packet/dash/vendor/draw/chunks/erDiagram-RLTQ6QDP-2DJVT3NO.js +99 -0
- work_packet/dash/vendor/draw/chunks/es-ES-U4NZUMDT-3B3P6QZB.js +9 -0
- work_packet/dash/vendor/draw/chunks/eu-ES-A7QVB2H4-2N3JY2V3.js +11 -0
- work_packet/dash/vendor/draw/chunks/eventmodeling-NTZA5JFV-H5NMJ7UT.js +1 -0
- work_packet/dash/vendor/draw/chunks/fa-IR-HGAKTJCU-EEK6JILC.js +8 -0
- work_packet/dash/vendor/draw/chunks/fi-FI-Z5N7JZ37-UHRGEABJ.js +6 -0
- work_packet/dash/vendor/draw/chunks/file-open-002ab408-QL4G5Y3G.js +1 -0
- work_packet/dash/vendor/draw/chunks/file-open-7c801643-BHEAEOP5.js +1 -0
- work_packet/dash/vendor/draw/chunks/file-save-3189631c-X44O5Z2G.js +1 -0
- work_packet/dash/vendor/draw/chunks/file-save-745eba88-LWULGU5X.js +1 -0
- work_packet/dash/vendor/draw/chunks/flowDiagram-HODETNUW-DG3GYRDD.js +1 -0
- work_packet/dash/vendor/draw/chunks/fr-FR-RHASNOE6-AKSPOWGA.js +9 -0
- work_packet/dash/vendor/draw/chunks/ganttDiagram-EL5Y4UJY-EVS2NILE.js +292 -0
- work_packet/dash/vendor/draw/chunks/gitGraph-4MIJSDKK-AGIRN4FW.js +1 -0
- work_packet/dash/vendor/draw/chunks/gitGraphDiagram-WWUBYQGX-3PTH6ZIY.js +106 -0
- work_packet/dash/vendor/draw/chunks/gl-ES-HMX3MZ6V-CB33P6KB.js +10 -0
- work_packet/dash/vendor/draw/chunks/he-IL-6SHJWFNN-FCZNWKRK.js +10 -0
- work_packet/dash/vendor/draw/chunks/hi-IN-IWLTKZ5I-JYCAAJJJ.js +4 -0
- work_packet/dash/vendor/draw/chunks/hu-HU-A5ZG7DT2-RI7FK2E5.js +7 -0
- work_packet/dash/vendor/draw/chunks/id-ID-SAP4L64H-C6IOLM4B.js +10 -0
- work_packet/dash/vendor/draw/chunks/image-GAAHSSAO-UTPEFMNS.js +1 -0
- work_packet/dash/vendor/draw/chunks/image-blob-reduce.esm-KMSEY24P.js +3 -0
- work_packet/dash/vendor/draw/chunks/image-blob-reduce.esm-KMSEY24P.js.LEGAL.txt +10 -0
- work_packet/dash/vendor/draw/chunks/info-A6RAGUB7-65F2CQLR.js +1 -0
- work_packet/dash/vendor/draw/chunks/infoDiagram-27XIBGKW-3E4TD4YZ.js +2 -0
- work_packet/dash/vendor/draw/chunks/ishikawaDiagram-5VMMS53U-QV4CMB66.js +70 -0
- work_packet/dash/vendor/draw/chunks/it-IT-JPQ66NNP-72DFKLGV.js +11 -0
- work_packet/dash/vendor/draw/chunks/ja-JP-DBVTYXUO-KD37IMEP.js +8 -0
- work_packet/dash/vendor/draw/chunks/journeyDiagram-3NMN7TZE-7JEXCTW7.js +139 -0
- work_packet/dash/vendor/draw/chunks/kaa-6HZHGXH3-TCQIKBL4.js +1 -0
- work_packet/dash/vendor/draw/chunks/kab-KAB-ZGHBKWFO-C6XARYJN.js +8 -0
- work_packet/dash/vendor/draw/chunks/kanban-definition-UXKFOSKX-BGSHEGSQ.js +89 -0
- work_packet/dash/vendor/draw/chunks/katex-O25S2MFU.js +257 -0
- work_packet/dash/vendor/draw/chunks/kk-KZ-P5N5QNE5-XONCJNK3.js +1 -0
- work_packet/dash/vendor/draw/chunks/km-KH-HSX4SM5Z-OQX6J7CL.js +11 -0
- work_packet/dash/vendor/draw/chunks/ko-KR-MTYHY66A-VBXJ6C52.js +9 -0
- work_packet/dash/vendor/draw/chunks/ku-TR-6OUDTVRD-I4JMXP2I.js +9 -0
- work_packet/dash/vendor/draw/chunks/lt-LT-XHIRWOB4-FNR5H4LC.js +3 -0
- work_packet/dash/vendor/draw/chunks/lv-LV-5QDEKY6T-FEKLQ5BI.js +7 -0
- work_packet/dash/vendor/draw/chunks/mindmap-definition-YA3MSWOX-JJY52ZYZ.js +96 -0
- work_packet/dash/vendor/draw/chunks/mr-IN-CRQNXWMA-DLCZ4ZRB.js +13 -0
- work_packet/dash/vendor/draw/chunks/my-MM-5M5IBNSE-EHIIYKJP.js +1 -0
- work_packet/dash/vendor/draw/chunks/nb-NO-T6EIAALU-7N2HTYRU.js +10 -0
- work_packet/dash/vendor/draw/chunks/nl-NL-IS3SIHDZ-MOD6UX3Z.js +8 -0
- work_packet/dash/vendor/draw/chunks/nn-NO-6E72VCQL-EO4EK5CI.js +8 -0
- work_packet/dash/vendor/draw/chunks/oc-FR-POXYY2M6-3OCVSSCM.js +8 -0
- work_packet/dash/vendor/draw/chunks/pa-IN-N4M65BXN-YXWDCFG5.js +4 -0
- work_packet/dash/vendor/draw/chunks/packet-AYTQ26CC-A265IQGE.js +1 -0
- work_packet/dash/vendor/draw/chunks/pegDiagram-XKGWAZYB-DLDXNRBB.js +1 -0
- work_packet/dash/vendor/draw/chunks/percentages-BXMCSKIN-373SJ4JI.js +1 -0
- work_packet/dash/vendor/draw/chunks/pica-CSPC6DGP.js +3 -0
- work_packet/dash/vendor/draw/chunks/pica-CSPC6DGP.js.LEGAL.txt +14 -0
- work_packet/dash/vendor/draw/chunks/pie-WAS4IAKB-XTWJ4XYX.js +1 -0
- work_packet/dash/vendor/draw/chunks/pieDiagram-E7YTZNPT-TZORDS35.js +39 -0
- work_packet/dash/vendor/draw/chunks/pl-PL-T2D74RX3-EX2EC77W.js +9 -0
- work_packet/dash/vendor/draw/chunks/pt-BR-5N22H2LF-B3YAUDIP.js +9 -0
- work_packet/dash/vendor/draw/chunks/pt-PT-UZXXM6DQ-FRJOQAUZ.js +9 -0
- work_packet/dash/vendor/draw/chunks/quadrantDiagram-AXDQQJYC-JXJE5Z47.js +7 -0
- work_packet/dash/vendor/draw/chunks/radar-RG4KPBEZ-YJ2V3WS4.js +1 -0
- work_packet/dash/vendor/draw/chunks/railroad-74A4TZTK-TQCCW43F.js +1 -0
- work_packet/dash/vendor/draw/chunks/railroad-abnf-HS5TGJTU-KES3ZXDD.js +1 -0
- work_packet/dash/vendor/draw/chunks/railroad-ebnf-LZEXJU2U-RSI23BRN.js +1 -0
- work_packet/dash/vendor/draw/chunks/railroad-peg-WCYAUIDC-WN6UQARL.js +1 -0
- work_packet/dash/vendor/draw/chunks/railroadDiagram-O6MQD6OU-2XJMU5H3.js +1 -0
- work_packet/dash/vendor/draw/chunks/requirementDiagram-BXWQKSXE-6MOMC63A.js +84 -0
- work_packet/dash/vendor/draw/chunks/ro-RO-JPDTUUEW-ZVNZR3AH.js +11 -0
- work_packet/dash/vendor/draw/chunks/roundRect-EOJX3UJR.js +1 -0
- work_packet/dash/vendor/draw/chunks/ru-RU-B4JR7IUQ-C4G6WLHG.js +9 -0
- work_packet/dash/vendor/draw/chunks/sankeyDiagram-P5KCCOFB-35N7JVPZ.js +40 -0
- work_packet/dash/vendor/draw/chunks/sequenceDiagram-WJ2MYXX4-QGY6QK72.js +162 -0
- work_packet/dash/vendor/draw/chunks/si-LK-N5RQ5JYF-5BT2K3LR.js +1 -0
- work_packet/dash/vendor/draw/chunks/sizeCapture-INFHLROL-MFTOEHAO.js +1 -0
- work_packet/dash/vendor/draw/chunks/sk-SK-C5VTKIMK-OGVWZ7IE.js +6 -0
- work_packet/dash/vendor/draw/chunks/sl-SI-NN7IZMDC-BTGH6UGJ.js +6 -0
- work_packet/dash/vendor/draw/chunks/stateDiagram-D77RDMKH-27CRDXRJ.js +1 -0
- work_packet/dash/vendor/draw/chunks/stateDiagram-v2-MP3YSRHH-BQHZNOVQ.js +1 -0
- work_packet/dash/vendor/draw/chunks/subset-shared.chunk-SVRVB3Z4.js +1 -0
- work_packet/dash/vendor/draw/chunks/subset-worker.chunk-I2CVDE6L.js +1 -0
- work_packet/dash/vendor/draw/chunks/sv-SE-XGPEYMSR-FOOGTB4Y.js +10 -0
- work_packet/dash/vendor/draw/chunks/swimlanes-42K2YHIH-63I6QWBZ.js +1 -0
- work_packet/dash/vendor/draw/chunks/swimlanesDiagram-VR7AAH4N-3B2UDBAU.js +8 -0
- work_packet/dash/vendor/draw/chunks/ta-IN-2NMHFXQM-SAE3PZAY.js +9 -0
- work_packet/dash/vendor/draw/chunks/th-TH-HPSO5L25-4OPUJMQQ.js +2 -0
- work_packet/dash/vendor/draw/chunks/timeline-definition-24CTP7MA-CQDE4BLV.js +120 -0
- work_packet/dash/vendor/draw/chunks/tr-TR-DEFEU3FU-WLELAJAL.js +7 -0
- work_packet/dash/vendor/draw/chunks/treeView-Q6P3EWNA-IIOWVAIH.js +1 -0
- work_packet/dash/vendor/draw/chunks/treemap-WGGIJYW6-RVAEJ543.js +1 -0
- work_packet/dash/vendor/draw/chunks/uk-UA-QMV73CPH-Z6BPEBSW.js +6 -0
- work_packet/dash/vendor/draw/chunks/vennDiagram-4TSXK5OY-LN6NUZLY.js +34 -0
- work_packet/dash/vendor/draw/chunks/vi-VN-M7AON7JQ-CQBLIYY5.js +5 -0
- work_packet/dash/vendor/draw/chunks/wardley-WFR3VGLG-YIQTVMO6.js +1 -0
- work_packet/dash/vendor/draw/chunks/wardleyDiagram-VM6X3IG4-N7NFCY55.js +78 -0
- work_packet/dash/vendor/draw/chunks/xychartDiagram-S5SC5T6Z-R6PTX6RL.js +7 -0
- work_packet/dash/vendor/draw/chunks/zh-CN-LNUGB5OW-Q2DWG53W.js +10 -0
- work_packet/dash/vendor/draw/chunks/zh-HK-E62DVLB3-FSFIHZX5.js +1 -0
- work_packet/dash/vendor/draw/chunks/zh-TW-RAJ6MFWO-4H6R2NTS.js +9 -0
- work_packet/dash/vendor/draw/excalidraw.css +1 -0
- work_packet/dash/vendor/draw/excalidraw.js +156 -0
- work_packet/dash/vendor/draw/excalidraw.js.LEGAL.txt +45 -0
- work_packet/dash/vendor/draw/fonts/Assistant/Assistant-Bold.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Assistant/Assistant-Medium.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Assistant/Assistant-Regular.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Assistant/Assistant-SemiBold.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Cascadia/CascadiaCode-Regular.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/ComicShanns/ComicShanns-Regular-279a7b317d12eb88de06167bd672b4b4.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/ComicShanns/ComicShanns-Regular-6e066e8de2ac57ea9283adb9c24d7f0c.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/ComicShanns/ComicShanns-Regular-dc6a8806fa96795d7b3be5026f989a17.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/ComicShanns/ComicShanns-Regular-fcb0fc02dcbee4c9846b3e2508668039.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Excalifont/Excalifont-Regular-349fac6ca4700ffec595a7150a0d1e1d.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Excalifont/Excalifont-Regular-3f2c5db56cc93c5a6873b1361d730c16.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Excalifont/Excalifont-Regular-41b173a47b57366892116a575a43e2b6.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Excalifont/Excalifont-Regular-623ccf21b21ef6b3a0d87738f77eb071.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Excalifont/Excalifont-Regular-a88b72a24fb54c9f94e3b5fdaa7481c9.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Excalifont/Excalifont-Regular-b9dcf9d2e50a1eaf42fc664b50a3fd0d.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Excalifont/Excalifont-Regular-be310b9bcd4f1a43f571c46df7809174.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Liberation/LiberationSans-Regular.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Lilita/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYE98RXi4EwSsbg.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Lilita/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYEF8RXi4EwQ.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTA3j6zbXWjgevT5.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTQ3j6zbXWjgeg.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTk3j6zbXWjgevT5.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTo3j6zbXWjgevT5.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Nunito/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTs3j6zbXWjgevT5.woff2 +0 -0
- work_packet/dash/vendor/draw/fonts/Virgil/Virgil-Regular.woff2 +0 -0
- work_packet/dash/vendor/draw/mermaid-to-excalidraw.js +1 -0
- work_packet/dash/vendor/draw/mermaid.js +1 -0
- work_packet/dash/vendor/manifest.json +947 -0
- work_packet/dash/vendor/novnc/LICENSE.txt +62 -0
- work_packet/dash/vendor/novnc/novnc.js +5 -0
- work_packet/dash/vendor/term/LICENSE.txt +21 -0
- work_packet/dash/vendor/term/addon-fit.js +2 -0
- work_packet/dash/vendor/term/xterm.css +285 -0
- work_packet/dash/vendor/term/xterm.js +2 -0
- work_packet/dash/vendor/vega/vega.js +202 -0
- work_packet/dash/vendor/vega/vega.js.LEGAL.txt +13 -0
- work_packet/dash/vendored.py +102 -0
- work_packet/deliver.py +252 -0
- work_packet/desktop.py +145 -0
- work_packet/desktop_bin/xdg-mime +28 -0
- work_packet/docs.py +464 -0
- work_packet/executor.py +1745 -0
- work_packet/faults.py +28 -0
- work_packet/forecast.py +268 -0
- work_packet/forges.py +416 -0
- work_packet/frontmatter.py +90 -0
- work_packet/fsutil.py +122 -0
- work_packet/harness/__init__.py +184 -0
- work_packet/harness/claude.py +264 -0
- work_packet/harness/codex.py +132 -0
- work_packet/history.py +630 -0
- work_packet/hookcmd.py +296 -0
- work_packet/hooks.py +122 -0
- work_packet/icsfeed.py +207 -0
- work_packet/ide.py +563 -0
- work_packet/ide_launch.py +176 -0
- work_packet/ide_ports.py +99 -0
- work_packet/ide_releases.py +363 -0
- work_packet/ide_sessions.py +1406 -0
- work_packet/ide_stranded.py +257 -0
- work_packet/inbox.py +220 -0
- work_packet/index.py +101 -0
- work_packet/jobs.py +263 -0
- work_packet/journal.py +87 -0
- work_packet/layout.py +55 -0
- work_packet/learn.py +234 -0
- work_packet/lease.py +124 -0
- work_packet/ledger.py +487 -0
- work_packet/ledger_collect.py +708 -0
- work_packet/limits.py +158 -0
- work_packet/livecard.py +100 -0
- work_packet/migrate.py +567 -0
- work_packet/milestones.py +184 -0
- work_packet/model.py +151 -0
- work_packet/notes.py +132 -0
- work_packet/notify.py +301 -0
- work_packet/packet.py +110 -0
- work_packet/pathhook.py +91 -0
- work_packet/planning.py +279 -0
- work_packet/plugins.py +121 -0
- work_packet/pr.py +230 -0
- work_packet/presence.py +351 -0
- work_packet/prices.toml +75 -0
- work_packet/procs.py +136 -0
- work_packet/profiles.py +125 -0
- work_packet/profiles.toml +22 -0
- work_packet/progress.py +391 -0
- work_packet/project.py +458 -0
- work_packet/prompt.py +308 -0
- work_packet/prompts/brief.md +68 -0
- work_packet/prompts/console.md +54 -0
- work_packet/prompts/harness-claude.md +5 -0
- work_packet/prompts/instruct-list.md +20 -0
- work_packet/prompts/instruct-outline.md +40 -0
- work_packet/prompts/instruct-plan-only.md +26 -0
- work_packet/prompts/protocol.md +342 -0
- work_packet/prompts/resolve.md +71 -0
- work_packet/prompts/sizing-bounded.md +17 -0
- work_packet/prompts/sizing-persistent.md +7 -0
- work_packet/prompts/step.md +23 -0
- work_packet/prompts/studio.md +100 -0
- work_packet/questions.py +233 -0
- work_packet/registry.py +537 -0
- work_packet/report.py +282 -0
- work_packet/requests.py +496 -0
- work_packet/resolve.py +97 -0
- work_packet/reviews.py +465 -0
- work_packet/sched/__init__.py +2 -0
- work_packet/sched/authz.py +72 -0
- work_packet/sched/backends/__init__.py +131 -0
- work_packet/sched/backends/local.py +120 -0
- work_packet/sched/backends/lsf.py +204 -0
- work_packet/sched/backends/slurm.py +209 -0
- work_packet/sched/budget.py +697 -0
- work_packet/sched/classes.py +45 -0
- work_packet/sched/config.py +237 -0
- work_packet/sched/control.py +298 -0
- work_packet/sched/dispatcher.py +617 -0
- work_packet/sched/doctor.py +205 -0
- work_packet/sched/events.py +89 -0
- work_packet/sched/explain.py +168 -0
- work_packet/sched/gates.py +256 -0
- work_packet/sched/home_lease.py +188 -0
- work_packet/sched/ide.py +87 -0
- work_packet/sched/ide_job.py +256 -0
- work_packet/sched/ide_relay.py +207 -0
- work_packet/sched/ide_tls.py +96 -0
- work_packet/sched/jobs.py +135 -0
- work_packet/sched/queue.py +117 -0
- work_packet/sched/xproxy.py +625 -0
- work_packet/scheduler.py +146 -0
- work_packet/schema.py +1565 -0
- work_packet/scribe.py +498 -0
- work_packet/session_usage.py +120 -0
- work_packet/sessionhooks.py +216 -0
- work_packet/settings.py +171 -0
- work_packet/setup.py +1257 -0
- work_packet/skills.py +252 -0
- work_packet/spawn.py +78 -0
- work_packet/split.py +308 -0
- work_packet/starters/__init__.py +608 -0
- work_packet/starters/builtin.py +319 -0
- work_packet/stats.py +577 -0
- work_packet/statusline.py +75 -0
- work_packet/studio/__init__.py +2 -0
- work_packet/studio/chart.py +210 -0
- work_packet/studio/content.py +105 -0
- work_packet/studio/data.py +361 -0
- work_packet/studio/kernel.py +233 -0
- work_packet/studio/kernel_main.py +242 -0
- work_packet/studio/kinds.py +73 -0
- work_packet/studio/model.py +290 -0
- work_packet/studio/primer.py +105 -0
- work_packet/studio/record.py +166 -0
- work_packet/studio/render.py +446 -0
- work_packet/studio/renders.py +334 -0
- work_packet/studio/tree.py +340 -0
- work_packet/studio/versions.py +153 -0
- work_packet/studio/watch.py +188 -0
- work_packet/templates.py +601 -0
- work_packet/timelog.py +115 -0
- work_packet/tomlio.py +24 -0
- work_packet/toolcost.py +275 -0
- work_packet/tui/__init__.py +1 -0
- work_packet/tui/setup_app.py +522 -0
- work_packet/tui/terminal.py +212 -0
- work_packet/views.py +463 -0
- work_packet/waiting.py +127 -0
- work_packet/watch.py +507 -0
- work_packet/workspace.py +343 -0
- work_packet-0.1.0.dist-info/METADATA +162 -0
- work_packet-0.1.0.dist-info/RECORD +505 -0
- work_packet-0.1.0.dist-info/WHEEL +5 -0
- work_packet-0.1.0.dist-info/entry_points.txt +2 -0
- work_packet-0.1.0.dist-info/licenses/LICENSE +202 -0
- work_packet-0.1.0.dist-info/top_level.txt +1 -0
work_packet/__about__.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
version_info = (0, 1, 0)
|
|
2
|
+
|
|
3
|
+
# CI rewrites this to ".dev<run-id>+<forge>.g<sha>" on non-tag builds, so a
|
|
4
|
+
# wheel produced by an ordinary push can never carry a version that could
|
|
5
|
+
# collide with a release on PyPI. Tag builds leave it empty and ship the clean
|
|
6
|
+
# version_info number.
|
|
7
|
+
SUFFIX = ""
|
|
8
|
+
|
|
9
|
+
__version__ = ".".join([str(n) for n in version_info]) + SUFFIX
|
work_packet/__init__.py
ADDED
work_packet/__main__.py
ADDED
work_packet/actions.py
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"""What a front end can do to a packet or a project (docs/interaction.md §4).
|
|
2
|
+
|
|
3
|
+
The CLI, the web board and the TUI call these and add no logic of their own.
|
|
4
|
+
Each returns an ``executor.Outcome``.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
|
|
10
|
+
from . import clock, executor, fsutil, lease, notes, questions
|
|
11
|
+
from .project import ProjectError, allow, project_of, set_values
|
|
12
|
+
|
|
13
|
+
DRAFTS = os.path.join(".setup", "next") # <project>/.setup/next/<wpid>.{md,json}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def answer(pkt, answers=None, note=None, take_recommendations=False, by=None):
|
|
17
|
+
"""Answer a ``NEEDS_INPUT`` packet: grant what yes-answers grant, apply the
|
|
18
|
+
settings the answers pick (``sets``), then hand it off.
|
|
19
|
+
|
|
20
|
+
``answers`` maps question ids to text. With ``take_recommendations``,
|
|
21
|
+
every unanswered question gets its ``recommend``.
|
|
22
|
+
"""
|
|
23
|
+
by = by or executor._who()
|
|
24
|
+
qs = questions.of_packet(pkt)
|
|
25
|
+
if not qs:
|
|
26
|
+
return executor.Outcome(executor.NOT_RUNNABLE,
|
|
27
|
+
"%s has no open questions" % pkt.wpid[:8])
|
|
28
|
+
ids = {q["id"] for q in qs}
|
|
29
|
+
unknown = sorted(set(answers or {}) - ids)
|
|
30
|
+
if unknown:
|
|
31
|
+
return executor.Outcome(executor.USAGE, "no question %s; the questions are %s" % (
|
|
32
|
+
", ".join(unknown), ", ".join(q["id"] for q in qs)))
|
|
33
|
+
got = questions.fill(qs, answers, take_recommendations)
|
|
34
|
+
if not got and not (note and note.strip()):
|
|
35
|
+
return executor.Outcome(executor.USAGE, "nothing to send: give answers, a note, "
|
|
36
|
+
"or take the recommendations")
|
|
37
|
+
done = []
|
|
38
|
+
tools, vals = questions.grants(qs, got), questions.sets(qs, got)
|
|
39
|
+
proj = project_of(pkt.path) if tools or vals else None
|
|
40
|
+
if vals:
|
|
41
|
+
if not proj:
|
|
42
|
+
return executor.Outcome(executor.USAGE, "%s has no project to set %s in" % (
|
|
43
|
+
pkt.wpid[:8], ", ".join(vals)))
|
|
44
|
+
from . import registry
|
|
45
|
+
cap = registry.load_config().get("max_step_budget_usd")
|
|
46
|
+
if vals.get("step_budget_usd", 0) > cap:
|
|
47
|
+
return executor.Outcome(executor.USAGE, "the answer sets step_budget_usd %s, over "
|
|
48
|
+
"max_step_budget_usd %s in config.toml; raise that, or "
|
|
49
|
+
"`wpk set` the budget and answer otherwise" % (
|
|
50
|
+
vals["step_budget_usd"], cap))
|
|
51
|
+
if tools:
|
|
52
|
+
try:
|
|
53
|
+
ch = allow(proj, tools, by) if proj else []
|
|
54
|
+
except ProjectError as e:
|
|
55
|
+
return executor.Outcome(executor.LEASED, str(e))
|
|
56
|
+
if ch:
|
|
57
|
+
done.append("granted " + ", ".join(t.split(" ", 1)[1] for t in ch))
|
|
58
|
+
if vals:
|
|
59
|
+
try:
|
|
60
|
+
ch = set_values(proj, [(k, json.dumps(v)) for k, v in vals.items()], by)
|
|
61
|
+
except ProjectError as e:
|
|
62
|
+
return executor.Outcome(executor.LEASED, str(e))
|
|
63
|
+
if ch:
|
|
64
|
+
done.append("; ".join(ch))
|
|
65
|
+
for rid in questions.requests(qs, got):
|
|
66
|
+
from . import requests
|
|
67
|
+
try:
|
|
68
|
+
e = requests.send(pkt, rid, by=by)
|
|
69
|
+
except requests.RequestError as ex:
|
|
70
|
+
return executor.Outcome(executor.USAGE, "request %s: %s" % (rid, ex))
|
|
71
|
+
done.append("sent request %s to %s" % (rid, requests._where(e)))
|
|
72
|
+
out = executor.admin(pkt, "handoff", note=note, answers=got, by=by)
|
|
73
|
+
if out.code != executor.OK:
|
|
74
|
+
return out
|
|
75
|
+
n = len(got)
|
|
76
|
+
msg = "answered %d of %d question%s" % (n, len(qs), "" if len(qs) == 1 else "s")
|
|
77
|
+
return executor.Outcome(executor.OK, "; ".join([msg] + done) + "; " + out.msg)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def note(pkt, text, by=None, wake=False):
|
|
81
|
+
"""Queue a note from the owner (docs/interaction.md §6a). A running step gets it
|
|
82
|
+
after its next tool call; otherwise the next step's prompt shows it. With
|
|
83
|
+
``wake``, a SLEEPING packet becomes RUNNABLE now."""
|
|
84
|
+
by = by or executor._who()
|
|
85
|
+
try:
|
|
86
|
+
meta, _ = pkt.load_status()
|
|
87
|
+
except (OSError, executor.frontmatter.FrontMatterError) as e:
|
|
88
|
+
return executor.Outcome(executor.USAGE, str(e))
|
|
89
|
+
try:
|
|
90
|
+
notes.add(pkt, text, by)
|
|
91
|
+
except (ValueError, OSError) as e:
|
|
92
|
+
return executor.Outcome(executor.USAGE, str(e))
|
|
93
|
+
state, short = meta["state"], pkt.wpid[:8]
|
|
94
|
+
if wake and state == "SLEEPING":
|
|
95
|
+
out = executor.admin(pkt, "wake", by=by)
|
|
96
|
+
if out.code != executor.OK:
|
|
97
|
+
return out
|
|
98
|
+
return executor.Outcome(executor.OK, "note queued; %s; the next step shows it" % out.msg)
|
|
99
|
+
lz = lease.read(pkt.lease_path)
|
|
100
|
+
if lz and lz.get("attempt") and not lease.is_stale(lz, clock.now()):
|
|
101
|
+
how = "the running step gets it after its next tool call"
|
|
102
|
+
elif state in ("RUNNABLE", "SLEEPING"):
|
|
103
|
+
how = "the next step shows it" + (" (%s until %s)" % (state, meta.get("wake_at"))
|
|
104
|
+
if state == "SLEEPING" else "")
|
|
105
|
+
elif state in ("NEEDS_INPUT", "PAUSED", "FAILED"):
|
|
106
|
+
how = "it waits: %s is %s until it is handed off" % (short, state)
|
|
107
|
+
else:
|
|
108
|
+
how = "but %s is %s, so no step will see it" % (short, state)
|
|
109
|
+
return executor.Outcome(executor.OK, "note queued for %s; %s" % (short, how))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# --- the next batch of work (docs/dash-tasks.md §6) ---------------------------------
|
|
113
|
+
|
|
114
|
+
def _draft_paths(pkt):
|
|
115
|
+
proj = project_of(pkt.path)
|
|
116
|
+
if proj is None:
|
|
117
|
+
raise ValueError("%s is not in a project" % pkt.path)
|
|
118
|
+
base = os.path.join(proj, DRAFTS, pkt.wpid)
|
|
119
|
+
return base + ".md", base + ".json"
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def load_draft(pkt):
|
|
123
|
+
"""The saved draft: ``{"instruction", "note", "archive_outline", "carry_session",
|
|
124
|
+
"saved"}``, or None. Nothing in the packet changes until the hand-off."""
|
|
125
|
+
md, js = _draft_paths(pkt)
|
|
126
|
+
try:
|
|
127
|
+
text = fsutil.read_text(md)
|
|
128
|
+
except FileNotFoundError:
|
|
129
|
+
return None
|
|
130
|
+
try:
|
|
131
|
+
with open(js, encoding="utf-8") as fp:
|
|
132
|
+
opts = json.load(fp)
|
|
133
|
+
except (OSError, ValueError):
|
|
134
|
+
opts = {}
|
|
135
|
+
opts["instruction"] = text
|
|
136
|
+
return opts
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def save_draft(pkt, instruction, note="", archive_outline=None, carry_session=False):
|
|
140
|
+
md, js = _draft_paths(pkt)
|
|
141
|
+
os.makedirs(os.path.dirname(md), exist_ok=True)
|
|
142
|
+
fsutil.atomic_write(md, instruction or "")
|
|
143
|
+
fsutil.atomic_write(js, json.dumps({
|
|
144
|
+
"note": note or "", "archive_outline": archive_outline,
|
|
145
|
+
"carry_session": bool(carry_session),
|
|
146
|
+
"saved": executor._ts()}, indent=1) + "\n")
|
|
147
|
+
return executor.Outcome(executor.OK, "draft saved")
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def drop_draft(pkt):
|
|
151
|
+
for p in _draft_paths(pkt):
|
|
152
|
+
try:
|
|
153
|
+
os.unlink(p)
|
|
154
|
+
except FileNotFoundError:
|
|
155
|
+
pass
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def continue_(pkt, instruction, note=None, archive_outline=None, carry_session=False,
|
|
159
|
+
force=False, by=None, defer=False):
|
|
160
|
+
"""Give a stopped packet (``COMPLETED`` too) a new instruction and hand it to the
|
|
161
|
+
runner. The draft, if any, is removed once the hand-off is recorded. ``defer``:
|
|
162
|
+
start only once nobody is working on the project (docs/collaboration.md §5.2)."""
|
|
163
|
+
out = executor.admin(pkt, "continue", note=note, by=by or executor._who(),
|
|
164
|
+
instruction=instruction, archive_outline=archive_outline,
|
|
165
|
+
carry_session=carry_session, force=force, defer=defer)
|
|
166
|
+
if out.code == executor.OK:
|
|
167
|
+
try:
|
|
168
|
+
drop_draft(pkt)
|
|
169
|
+
except ValueError:
|
|
170
|
+
pass
|
|
171
|
+
n = executor.batch_of(executor.journal.read(pkt.journal_path).records)
|
|
172
|
+
out = executor.Outcome(executor.OK, "batch %d handed off; %s" % (n, out.msg))
|
|
173
|
+
return out
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
# --- a whole project: pause to re-prioritise (docs/pause-v1.md) ----------------------
|
|
177
|
+
|
|
178
|
+
def resumable(meta):
|
|
179
|
+
"""PAUSED by hand (or by a pause request), not for setup and not by a limit:
|
|
180
|
+
what Resume on a project gives back to the runner."""
|
|
181
|
+
from .project import SETUP_REASON
|
|
182
|
+
return meta.get("state") == "PAUSED" and meta.get("reason") != SETUP_REASON and \
|
|
183
|
+
not meta.get("stopped") and not meta.get("taken_by")
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _tree(entry):
|
|
187
|
+
from .views import packets
|
|
188
|
+
return [(p, m) for _, p, m, _ in packets(entry["path"], entry["root"]) if m is not None]
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def pause_project(entry, by=None, reason=None):
|
|
192
|
+
"""Pause every packet of ``entry`` that the runner would run: at once, or,
|
|
193
|
+
while its step runs, after that step."""
|
|
194
|
+
now, later, bad = 0, 0, []
|
|
195
|
+
for pkt, meta in _tree(entry):
|
|
196
|
+
if meta["state"] not in ("RUNNABLE", "SLEEPING"):
|
|
197
|
+
continue
|
|
198
|
+
out = executor.admin(pkt, "pause", by=by, reason=reason)
|
|
199
|
+
if out.code:
|
|
200
|
+
bad.append(out.msg)
|
|
201
|
+
elif executor.pause_request(pkt) is not None:
|
|
202
|
+
later += 1
|
|
203
|
+
else:
|
|
204
|
+
now += 1
|
|
205
|
+
_withdraw_job(pkt, by)
|
|
206
|
+
return _summary(entry, "paused", now, later, bad)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def claim(entry, by=None):
|
|
210
|
+
"""Opening a project to work on it yourself takes it from the runner
|
|
211
|
+
(docs/collaboration.md §5.1): every packet it would run is paused with reason
|
|
212
|
+
``claimed`` (a running step finishes first), and it stays yours, however long
|
|
213
|
+
the editor is open, until you hand it back (a hand-off of the root packet, or
|
|
214
|
+
Resume). Nothing to take: an OK outcome that says so."""
|
|
215
|
+
from . import schema
|
|
216
|
+
if not any(m["state"] in ("RUNNABLE", "SLEEPING") for _, m in _tree(entry)):
|
|
217
|
+
return executor.Outcome(executor.OK, "%s: yours; the runner has nothing of it"
|
|
218
|
+
% entry["name"])
|
|
219
|
+
out = pause_project(entry, by=by, reason=schema.REASON_CLAIMED)
|
|
220
|
+
if out.code == 0:
|
|
221
|
+
out = executor.Outcome(out.code, "%s; yours until you hand it back" % out.msg)
|
|
222
|
+
return out
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def resume_project(entry, by=None):
|
|
226
|
+
"""Give back to the runner what was paused by hand, and take back pauses
|
|
227
|
+
that have not happened yet. Setup, limits and questions are left alone."""
|
|
228
|
+
n, kept, bad = 0, 0, []
|
|
229
|
+
for pkt, meta in _tree(entry):
|
|
230
|
+
if executor.pause_request(pkt) is not None:
|
|
231
|
+
executor.withdraw_pause(pkt)
|
|
232
|
+
kept += 1
|
|
233
|
+
continue
|
|
234
|
+
try: # as it is now: handing back the root hands back a claim
|
|
235
|
+
meta = pkt.load_status()[0]
|
|
236
|
+
except Exception: # noqa: BLE001: unreadable now; the snapshot says what it was
|
|
237
|
+
pass
|
|
238
|
+
if resumable(meta):
|
|
239
|
+
out = executor.admin(pkt, "resume", by=by)
|
|
240
|
+
if out.code:
|
|
241
|
+
bad.append(out.msg)
|
|
242
|
+
else:
|
|
243
|
+
n += 1
|
|
244
|
+
if not (n or kept or bad):
|
|
245
|
+
return executor.Outcome(executor.NOT_RUNNABLE, "%s: nothing paused by hand" % entry["name"])
|
|
246
|
+
msg = "%s: resumed %d packet%s" % (entry["name"], n, "" if n == 1 else "s")
|
|
247
|
+
if kept:
|
|
248
|
+
msg += "; %d will not pause after all" % kept
|
|
249
|
+
return executor.Outcome(1 if bad else 0, "; ".join([msg] + bad))
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def stop_project(entry, by=None, h=None):
|
|
253
|
+
"""Pause the project, and end its running steps now: they are not counted as
|
|
254
|
+
failed attempts, and what they had not committed is redone later."""
|
|
255
|
+
from .sched import control
|
|
256
|
+
out = pause_project(entry, by=by, reason="stopped now")
|
|
257
|
+
gone = control.cancel_jobs(lambda r: r.project == entry["name"] and r.kind == "step",
|
|
258
|
+
by or executor._who(), "stopped by %s" % (by or "hand"), h=h)
|
|
259
|
+
if not gone:
|
|
260
|
+
return out
|
|
261
|
+
return executor.Outcome(out.code, "%s; ended %d running step%s" % (
|
|
262
|
+
out.msg, len(gone), "" if len(gone) == 1 else "s"))
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def _withdraw_job(pkt, by):
|
|
266
|
+
from .sched import control
|
|
267
|
+
try:
|
|
268
|
+
control.cancel_pending(pkt.wpid, by or executor._who())
|
|
269
|
+
except Exception: # noqa: BLE001: the dispatcher drops it at its next pass
|
|
270
|
+
pass
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def _summary(entry, verb, now, later, bad):
|
|
274
|
+
if not (now or later or bad):
|
|
275
|
+
return executor.Outcome(executor.NOT_RUNNABLE, "%s: nothing to pause" % entry["name"])
|
|
276
|
+
parts = []
|
|
277
|
+
if now:
|
|
278
|
+
parts.append("%s %d packet%s" % (verb, now, "" if now == 1 else "s"))
|
|
279
|
+
if later:
|
|
280
|
+
parts.append("%d after the running step" % later)
|
|
281
|
+
return executor.Outcome(1 if bad else 0, "%s: %s" % (entry["name"], "; ".join(parts + bad)))
|
work_packet/archived.py
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""Projects whose runs have been removed, seen through the history store.
|
|
2
|
+
|
|
3
|
+
When a finished project's ``packets/`` directory is gone, its records
|
|
4
|
+
(every file but ``work/``) are written once from the blob store into
|
|
5
|
+
``<home>/cache/archived/<project>/packets/``, read-only, and the project's
|
|
6
|
+
entry is pointed there. Everything that reads a project by its path (the
|
|
7
|
+
dashboard above all) then works unchanged. The other top-level items of
|
|
8
|
+
the real project directory, such as ``project.toml``, are linked in.
|
|
9
|
+
|
|
10
|
+
Only whole projects are handled: a project with a ``packets/`` directory
|
|
11
|
+
is read from it as before.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import shutil
|
|
17
|
+
|
|
18
|
+
from . import history, layout, registry
|
|
19
|
+
|
|
20
|
+
MARK = ".restored.json"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def cache_root(h=None):
|
|
24
|
+
return os.path.join(h or registry.home(), "cache", "archived")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def is_archived(entry):
|
|
28
|
+
return bool(entry.get("archived"))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _wanted(con, entry):
|
|
32
|
+
if os.path.isdir(layout.runs_dir(entry["path"])):
|
|
33
|
+
return []
|
|
34
|
+
return history.harvested(con, entry["name"])
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _current(d, ids):
|
|
38
|
+
try:
|
|
39
|
+
with open(os.path.join(d, MARK), encoding="utf-8") as fp:
|
|
40
|
+
return json.load(fp).get("packets") == ids
|
|
41
|
+
except (OSError, ValueError):
|
|
42
|
+
return False
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _rmtree(d):
|
|
46
|
+
for dp, dns, fns in os.walk(d):
|
|
47
|
+
for x in fns:
|
|
48
|
+
p = os.path.join(dp, x)
|
|
49
|
+
if not os.path.islink(p):
|
|
50
|
+
os.chmod(p, 0o644)
|
|
51
|
+
shutil.rmtree(d)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def materialize(con, entry, ids, h=None):
|
|
55
|
+
"""The cache directory for ``entry`` holding packets ``ids``, written if
|
|
56
|
+
it is missing or out of date."""
|
|
57
|
+
d = os.path.join(cache_root(h), entry["name"])
|
|
58
|
+
if _current(d, ids):
|
|
59
|
+
return d
|
|
60
|
+
tmp = "%s.tmp-%d" % (d, os.getpid())
|
|
61
|
+
if os.path.lexists(tmp):
|
|
62
|
+
_rmtree(tmp)
|
|
63
|
+
os.makedirs(tmp)
|
|
64
|
+
try:
|
|
65
|
+
history.restore_project(con, entry["name"], tmp, h)
|
|
66
|
+
if os.path.isdir(entry["path"]):
|
|
67
|
+
for n in sorted(os.listdir(entry["path"])):
|
|
68
|
+
if n not in (layout.LEGACY_RUNS, layout.RUNS):
|
|
69
|
+
os.symlink(os.path.join(entry["path"], n), os.path.join(tmp, n))
|
|
70
|
+
with open(os.path.join(tmp, MARK), "w", encoding="utf-8") as fp:
|
|
71
|
+
json.dump({"project": entry["name"], "path": entry["path"], "packets": ids}, fp)
|
|
72
|
+
except BaseException:
|
|
73
|
+
_rmtree(tmp)
|
|
74
|
+
raise
|
|
75
|
+
if os.path.lexists(d):
|
|
76
|
+
_rmtree(d)
|
|
77
|
+
os.replace(tmp, d)
|
|
78
|
+
return d
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def view(entry, h=None, con=None):
|
|
82
|
+
"""``entry``, or a copy pointed at the restored records when its runs are
|
|
83
|
+
gone (``archived`` set, ``origin`` the real path)."""
|
|
84
|
+
if os.path.isdir(layout.runs_dir(entry["path"])):
|
|
85
|
+
return entry
|
|
86
|
+
if not os.path.isfile(history.db_path(h)):
|
|
87
|
+
return entry
|
|
88
|
+
own = con is None
|
|
89
|
+
if own:
|
|
90
|
+
con = history.connect(h)
|
|
91
|
+
try:
|
|
92
|
+
ids = _wanted(con, entry)
|
|
93
|
+
if not ids:
|
|
94
|
+
return entry
|
|
95
|
+
d = materialize(con, entry, ids, h)
|
|
96
|
+
finally:
|
|
97
|
+
if own:
|
|
98
|
+
con.close()
|
|
99
|
+
return dict(entry, path=d, origin=entry["path"], archived=True)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def entries(h=None):
|
|
103
|
+
"""``registry.entries``, with archived projects pointed at their records."""
|
|
104
|
+
es = registry.entries(h)
|
|
105
|
+
if not any(not os.path.isdir(layout.runs_dir(e["path"])) for e in es):
|
|
106
|
+
return es
|
|
107
|
+
if not os.path.isfile(history.db_path(h)):
|
|
108
|
+
return es
|
|
109
|
+
con = history.connect(h)
|
|
110
|
+
try:
|
|
111
|
+
return [view(e, h, con) for e in es]
|
|
112
|
+
finally:
|
|
113
|
+
con.close()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def get(name, h=None):
|
|
117
|
+
e = registry.get(name, h)
|
|
118
|
+
return view(e, h) if e is not None else None
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def get_closed(name, h=None):
|
|
122
|
+
"""A closed packet (docs/close-remove-plan.md), newest of that name, as an
|
|
123
|
+
entry the dashboard reads like an archived one: read-only, ``closed`` its
|
|
124
|
+
record's id. Its runs are read where they are while its folder is kept,
|
|
125
|
+
else from the history store. None if no closed packet has that name."""
|
|
126
|
+
from . import closeout
|
|
127
|
+
rec = next((r for r in closeout.closed(h) if r.get("name") == name), None)
|
|
128
|
+
if rec is None or not rec.get("entry"):
|
|
129
|
+
return None
|
|
130
|
+
e = dict(rec["entry"])
|
|
131
|
+
try:
|
|
132
|
+
v = view(e, h)
|
|
133
|
+
except (OSError, ValueError):
|
|
134
|
+
v = e
|
|
135
|
+
if not os.path.isdir(layout.runs_dir(v["path"])):
|
|
136
|
+
return None # neither kept nor in history: only its closed page
|
|
137
|
+
return dict(v, archived=True, closed=rec["id"])
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def get_or_closed(name, h=None):
|
|
141
|
+
"""``get``, else the closed packet of that name: what the board's project
|
|
142
|
+
pages show."""
|
|
143
|
+
return get(name, h) or get_closed(name, h)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def closed_entries(h=None):
|
|
147
|
+
"""The closed packets whose names are not registered again, as
|
|
148
|
+
``get_closed`` has them, newest of each name: what the stats count beside
|
|
149
|
+
the registered ones, so closing never takes a packet's cost away."""
|
|
150
|
+
from . import closeout
|
|
151
|
+
have = {e["name"] for e in registry.entries(h)}
|
|
152
|
+
out, seen = [], set()
|
|
153
|
+
for r in closeout.closed(h):
|
|
154
|
+
n = r.get("name")
|
|
155
|
+
if n in have or n in seen:
|
|
156
|
+
continue
|
|
157
|
+
seen.add(n)
|
|
158
|
+
e = get_closed(n, h)
|
|
159
|
+
if e is not None:
|
|
160
|
+
out.append(e)
|
|
161
|
+
return out
|
work_packet/attention.py
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""What needs you, from the sessions you drive (docs/collaboration.md §4.3), and
|
|
2
|
+
the snoozes you set on any item.
|
|
3
|
+
|
|
4
|
+
The board's own reasons (a question, a failure, finished work to review) come
|
|
5
|
+
from the packets' state (``dash/data.overview``). This adds the ones only
|
|
6
|
+
presence records know about:
|
|
7
|
+
|
|
8
|
+
- **blocked**: a Claude session waits on a permission prompt (after
|
|
9
|
+
``BLOCKED_AFTER_S``);
|
|
10
|
+
- **your turn**: a Claude session you drive ended its turn and nothing has come
|
|
11
|
+
since (after ``[ide] idle_escalate``);
|
|
12
|
+
- **stale**: a session that says it is working has been silent for an hour.
|
|
13
|
+
|
|
14
|
+
None of them is raised while a web VS Code tab on the project is visible: you
|
|
15
|
+
already see it. Items are derived, never stored, so they close when their cause
|
|
16
|
+
does. A snooze is the only state: per person, in ``$WPK_HOME/attention/<user>.json``,
|
|
17
|
+
keyed by the item *and* when its cause began, so anything new brings it back.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import re
|
|
23
|
+
import time
|
|
24
|
+
|
|
25
|
+
from . import fsutil, presence
|
|
26
|
+
|
|
27
|
+
BLOCKED_AFTER_S = 120
|
|
28
|
+
IDLE_ESCALATE_S = 900
|
|
29
|
+
STALE_S = 3600
|
|
30
|
+
URGENCY = {"question": 3, "blocked": 3, "failure": 3, "review": 2, "decision": 2,
|
|
31
|
+
"your turn": 1, "stale": 1, "notify": 0}
|
|
32
|
+
_SAFE = re.compile(r"[^A-Za-z0-9_.@-]")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _visible(recs):
|
|
36
|
+
return any(r.get("kind") == "ide-web" and r.get("visible") for r in recs)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def session_items(proj, now=None, idle_escalate=IDLE_ESCALATE_S):
|
|
40
|
+
"""``[{"type", "since", "text", "source", "session", "tool"}]`` for ``proj``'s
|
|
41
|
+
Claude and Codex sessions, oldest first."""
|
|
42
|
+
now = time.time() if now is None else now
|
|
43
|
+
recs = presence.records(proj, now, ttl=None)
|
|
44
|
+
if _visible(presence.live(proj, now)):
|
|
45
|
+
return []
|
|
46
|
+
out = []
|
|
47
|
+
for r in recs:
|
|
48
|
+
if r.get("kind") not in presence.AGENTS or not presence.engaged(r):
|
|
49
|
+
continue
|
|
50
|
+
since = r.get("turn_since") or r.get("beat") or now
|
|
51
|
+
name = presence.AGENTS[r["kind"]]
|
|
52
|
+
where = presence.WHERE.get(r.get("via"), name)
|
|
53
|
+
base = {"since": since, "source": r.get("source"), "session": r.get("session"),
|
|
54
|
+
"tool": r.get("tool") or "", "via": r.get("via")}
|
|
55
|
+
if r.get("turn") == "blocked" and now - since >= BLOCKED_AFTER_S:
|
|
56
|
+
out.append(dict(base, type="blocked", text="%s (%s) wants to run %s" % (
|
|
57
|
+
name, where, r.get("tool") or "a tool")))
|
|
58
|
+
elif r.get("turn") == "waiting" and now - since >= idle_escalate:
|
|
59
|
+
out.append(dict(base, type="your turn", text="%s (%s) is waiting for you"
|
|
60
|
+
% (name, where)))
|
|
61
|
+
elif r.get("turn") == "working" and now - (r.get("beat") or now) >= STALE_S:
|
|
62
|
+
out.append(dict(base, since=r.get("beat"), type="stale",
|
|
63
|
+
text="%s (%s) said it was working, and has been silent since"
|
|
64
|
+
% (name, where)))
|
|
65
|
+
return sorted(out, key=lambda x: x["since"])
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def log_waits(proj, root, now=None, idle_escalate=IDLE_ESCALATE_S):
|
|
69
|
+
"""The journal's ``turn-waiting`` record (docs/collaboration.md §4.5): a Claude
|
|
70
|
+
or Codex session that has waited for you ``idle_escalate``, once per wait. Written by
|
|
71
|
+
the board's loop, not by the hook. Returns how many it wrote."""
|
|
72
|
+
from . import journal, layout
|
|
73
|
+
now = time.time() if now is None else now
|
|
74
|
+
n = 0
|
|
75
|
+
for r in presence.records(proj, now, ttl=None):
|
|
76
|
+
since = r.get("turn_since")
|
|
77
|
+
if r.get("kind") not in presence.AGENTS or r.get("turn") != "waiting" or not since or \
|
|
78
|
+
not presence.engaged(r) or \
|
|
79
|
+
now - since < idle_escalate or r.get("waited") == since:
|
|
80
|
+
continue
|
|
81
|
+
wpid = r.get("wpid") or root
|
|
82
|
+
if not wpid:
|
|
83
|
+
continue
|
|
84
|
+
ts = lambda t: time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(t))
|
|
85
|
+
try:
|
|
86
|
+
journal.append(os.path.join(layout.run_dir(proj, wpid), "journal.jsonl"), {
|
|
87
|
+
"type": "turn-waiting", "t": ts(since + idle_escalate), "by": r.get("by"),
|
|
88
|
+
"session": r.get("session"), "since": ts(since),
|
|
89
|
+
"actor": {"kind": r["kind"], "via": r.get("via"), "session": r.get("session")}})
|
|
90
|
+
except OSError:
|
|
91
|
+
continue
|
|
92
|
+
presence.mark(proj, r["source"], waited=since)
|
|
93
|
+
n += 1
|
|
94
|
+
return n
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def key(project, item):
|
|
98
|
+
"""An item's identity for a snooze: what it is, and when its cause began."""
|
|
99
|
+
return "%s|%s|%s|%d" % (project, item.get("type"), item.get("source") or "",
|
|
100
|
+
int(item.get("since") or 0))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _path(home, user):
|
|
104
|
+
return os.path.join(home, "attention", _SAFE.sub("_", user or "you") + ".json")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def snoozes(home, user, now=None):
|
|
108
|
+
"""``{key: until}`` still in force."""
|
|
109
|
+
now = time.time() if now is None else now
|
|
110
|
+
try:
|
|
111
|
+
with open(_path(home, user)) as fp:
|
|
112
|
+
d = json.load(fp)
|
|
113
|
+
except (OSError, ValueError):
|
|
114
|
+
return {}
|
|
115
|
+
return {k: v for k, v in (d if isinstance(d, dict) else {}).items()
|
|
116
|
+
if isinstance(v, (int, float)) and v > now}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def snooze(home, user, k, until, now=None):
|
|
120
|
+
"""Hide item ``k`` until ``until`` (epoch). Expired snoozes are dropped."""
|
|
121
|
+
now = time.time() if now is None else now
|
|
122
|
+
d = snoozes(home, user, now)
|
|
123
|
+
d[k] = until
|
|
124
|
+
p = _path(home, user)
|
|
125
|
+
os.makedirs(os.path.dirname(p), mode=0o700, exist_ok=True)
|
|
126
|
+
fsutil.atomic_write(p, json.dumps(d, sort_keys=True) + "\n")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def until_of(choice, now=None, tz=None):
|
|
130
|
+
"""When a snooze choice ends: ``1h``, ``tomorrow`` (08:00 local), ``change``
|
|
131
|
+
(until its cause changes: as long as it lasts)."""
|
|
132
|
+
import datetime
|
|
133
|
+
now = time.time() if now is None else now
|
|
134
|
+
if choice == "1h":
|
|
135
|
+
return now + 3600
|
|
136
|
+
if choice == "tomorrow":
|
|
137
|
+
d = datetime.datetime.fromtimestamp(now, tz) + datetime.timedelta(days=1)
|
|
138
|
+
return d.replace(hour=8, minute=0, second=0, microsecond=0).timestamp()
|
|
139
|
+
return now + 365 * 86400
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
SITTING_S = 1800 # views closer than this are one visit
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _visits(home, user):
|
|
146
|
+
p = _path(home, user)[:-5] + ".visit.json"
|
|
147
|
+
try:
|
|
148
|
+
with open(p) as fp:
|
|
149
|
+
d = json.load(fp)
|
|
150
|
+
return p, d if isinstance(d, dict) else {}
|
|
151
|
+
except (OSError, ValueError):
|
|
152
|
+
return p, {}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def since(home, user, now=None):
|
|
156
|
+
"""When ``user``'s previous visit to the Desk ended (None before any): what
|
|
157
|
+
"since you were last here" starts from. Views within ``SITTING_S`` of each
|
|
158
|
+
other are one visit, so a reload keeps it. Reads only (a GET changes nothing)."""
|
|
159
|
+
now = time.time() if now is None else now
|
|
160
|
+
_, d = _visits(home, user)
|
|
161
|
+
last = d.get("last")
|
|
162
|
+
if not isinstance(last, (int, float)):
|
|
163
|
+
return None
|
|
164
|
+
return last if now - last > SITTING_S else d.get("since")
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def visit(home, user, now=None):
|
|
168
|
+
"""Note that ``user`` is looking at the Desk now (the page's beacon, a POST).
|
|
169
|
+
Returns ``since`` as it was before."""
|
|
170
|
+
now = time.time() if now is None else now
|
|
171
|
+
was = since(home, user, now)
|
|
172
|
+
p, _ = _visits(home, user)
|
|
173
|
+
os.makedirs(os.path.dirname(p), mode=0o700, exist_ok=True)
|
|
174
|
+
fsutil.atomic_write(p, json.dumps({"last": now, "since": was}) + "\n")
|
|
175
|
+
return was
|