shennian 0.4.80 → 0.4.81

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.
Files changed (33) hide show
  1. package/dist/publish-build-manifest.json +71 -51
  2. package/dist/src/agent-env.js +3 -3
  3. package/dist/src/commands/daemon-service-spec.d.ts +0 -2
  4. package/dist/src/commands/daemon-service-spec.js +1 -1
  5. package/dist/src/commands/daemon-state.js +1 -1
  6. package/dist/src/commands/daemon-windows.d.ts +0 -3
  7. package/dist/src/commands/daemon-windows.js +12 -12
  8. package/dist/src/commands/daemon.d.ts +1 -0
  9. package/dist/src/commands/daemon.js +16 -16
  10. package/dist/src/commands/pair.js +7 -7
  11. package/dist/src/commands/upgrade.js +1 -1
  12. package/dist/src/index.js +3 -3
  13. package/dist/src/native-fusion/file-identity.d.ts +9 -0
  14. package/dist/src/native-fusion/file-identity.js +1 -0
  15. package/dist/src/native-fusion/local-repository.d.ts +6 -0
  16. package/dist/src/native-fusion/local-repository.js +1 -1
  17. package/dist/src/native-fusion/service.js +2 -2
  18. package/dist/src/native-fusion/session-native-sources.d.ts +24 -0
  19. package/dist/src/native-fusion/session-native-sources.js +1 -0
  20. package/dist/src/runtime-distribution.d.ts +2 -8
  21. package/dist/src/runtime-distribution.js +1 -1
  22. package/dist/src/session/deletion-synchronizer.d.ts +9 -0
  23. package/dist/src/session/deletion-synchronizer.js +1 -0
  24. package/dist/src/session/manager.d.ts +1 -1
  25. package/dist/src/session/manager.js +1 -1
  26. package/dist/src/session/queue-control.d.ts +27 -0
  27. package/dist/src/session/queue-control.js +1 -0
  28. package/dist/src/session/queue.d.ts +2 -1
  29. package/dist/src/session/queue.js +1 -1
  30. package/dist/src/upgrade/engine.js +2 -2
  31. package/dist/src/upgrade/scheduler.js +1 -1
  32. package/dist/src/upgrade/updater-launcher.js +3 -3
  33. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "jsMinified": true,
4
4
  "minifier": "esbuild",
5
- "fileCount": 222,
5
+ "fileCount": 226,
6
6
  "files": [
7
7
  {
8
8
  "file": "bin/shennian.js",
@@ -11,8 +11,8 @@
11
11
  },
12
12
  {
13
13
  "file": "src/agent-env.js",
14
- "beforeBytes": 11445,
15
- "afterBytes": 5115
14
+ "beforeBytes": 11128,
15
+ "afterBytes": 4946
16
16
  },
17
17
  {
18
18
  "file": "src/agents/acp/adapter.js",
@@ -331,8 +331,8 @@
331
331
  },
332
332
  {
333
333
  "file": "src/commands/daemon-service-spec.js",
334
- "beforeBytes": 4365,
335
- "afterBytes": 2648
334
+ "beforeBytes": 3873,
335
+ "afterBytes": 2332
336
336
  },
337
337
  {
338
338
  "file": "src/commands/daemon-start-wait.js",
@@ -341,18 +341,18 @@
341
341
  },
342
342
  {
343
343
  "file": "src/commands/daemon-state.js",
344
- "beforeBytes": 10369,
345
- "afterBytes": 5116
344
+ "beforeBytes": 10212,
345
+ "afterBytes": 4981
346
346
  },
347
347
  {
348
348
  "file": "src/commands/daemon-windows.js",
349
- "beforeBytes": 5732,
350
- "afterBytes": 4027
349
+ "beforeBytes": 4905,
350
+ "afterBytes": 3574
351
351
  },
352
352
  {
353
353
  "file": "src/commands/daemon.js",
354
- "beforeBytes": 34830,
355
- "afterBytes": 17590
354
+ "beforeBytes": 35833,
355
+ "afterBytes": 17960
356
356
  },
357
357
  {
358
358
  "file": "src/commands/integration.js",
@@ -386,8 +386,8 @@
386
386
  },
387
387
  {
388
388
  "file": "src/commands/pair.js",
389
- "beforeBytes": 16528,
390
- "afterBytes": 9150
389
+ "beforeBytes": 16512,
390
+ "afterBytes": 9134
391
391
  },
392
392
  {
393
393
  "file": "src/commands/room.js",
@@ -411,8 +411,8 @@
411
411
  },
412
412
  {
413
413
  "file": "src/commands/upgrade.js",
414
- "beforeBytes": 13446,
415
- "afterBytes": 6795
414
+ "beforeBytes": 13052,
415
+ "afterBytes": 6572
416
416
  },
417
417
  {
418
418
  "file": "src/commands/worker.js",
@@ -491,13 +491,13 @@
491
491
  },
492
492
  {
493
493
  "file": "src/fs/text-decoder.js",
494
- "beforeBytes": 4660,
494
+ "beforeBytes": 4682,
495
495
  "afterBytes": 1844
496
496
  },
497
497
  {
498
498
  "file": "src/index.js",
499
- "beforeBytes": 42085,
500
- "afterBytes": 20878
499
+ "beforeBytes": 41937,
500
+ "afterBytes": 20803
501
501
  },
502
502
  {
503
503
  "file": "src/log-redaction.js",
@@ -564,6 +564,11 @@
564
564
  "beforeBytes": 225,
565
565
  "afterBytes": 109
566
566
  },
567
+ {
568
+ "file": "src/native-fusion/file-identity.js",
569
+ "beforeBytes": 776,
570
+ "afterBytes": 205
571
+ },
567
572
  {
568
573
  "file": "src/native-fusion/file-watcher.js",
569
574
  "beforeBytes": 7353,
@@ -571,8 +576,8 @@
571
576
  },
572
577
  {
573
578
  "file": "src/native-fusion/local-repository.js",
574
- "beforeBytes": 27323,
575
- "afterBytes": 13527
579
+ "beforeBytes": 27624,
580
+ "afterBytes": 13695
576
581
  },
577
582
  {
578
583
  "file": "src/native-fusion/native-source-deletions.js",
@@ -596,14 +601,19 @@
596
601
  },
597
602
  {
598
603
  "file": "src/native-fusion/service.js",
599
- "beforeBytes": 39178,
600
- "afterBytes": 17772
604
+ "beforeBytes": 39355,
605
+ "afterBytes": 17813
601
606
  },
602
607
  {
603
608
  "file": "src/native-fusion/session-header.js",
604
609
  "beforeBytes": 4294,
605
610
  "afterBytes": 1996
606
611
  },
612
+ {
613
+ "file": "src/native-fusion/session-native-sources.js",
614
+ "beforeBytes": 2473,
615
+ "afterBytes": 889
616
+ },
607
617
  {
608
618
  "file": "src/native-fusion/source-visibility-audit.js",
609
619
  "beforeBytes": 2911,
@@ -771,8 +781,8 @@
771
781
  },
772
782
  {
773
783
  "file": "src/runtime-distribution.js",
774
- "beforeBytes": 2844,
775
- "afterBytes": 1540
784
+ "beforeBytes": 1096,
785
+ "afterBytes": 501
776
786
  },
777
787
  {
778
788
  "file": "src/schedules/personal-context.js",
@@ -831,9 +841,14 @@
831
841
  },
832
842
  {
833
843
  "file": "src/session/deletion-sync-validation.js",
834
- "beforeBytes": 1590,
844
+ "beforeBytes": 1595,
835
845
  "afterBytes": 919
836
846
  },
847
+ {
848
+ "file": "src/session/deletion-synchronizer.js",
849
+ "beforeBytes": 4469,
850
+ "afterBytes": 2310
851
+ },
837
852
  {
838
853
  "file": "src/session/handlers/agent-capabilities.js",
839
854
  "beforeBytes": 767,
@@ -846,7 +861,7 @@
846
861
  },
847
862
  {
848
863
  "file": "src/session/handlers/agent-control.js",
849
- "beforeBytes": 6699,
864
+ "beforeBytes": 6730,
850
865
  "afterBytes": 3876
851
866
  },
852
867
  {
@@ -861,17 +876,17 @@
861
876
  },
862
877
  {
863
878
  "file": "src/session/handlers/chat-adapter-config.js",
864
- "beforeBytes": 2814,
879
+ "beforeBytes": 2831,
865
880
  "afterBytes": 1159
866
881
  },
867
882
  {
868
883
  "file": "src/session/handlers/chat-context.js",
869
- "beforeBytes": 3243,
884
+ "beforeBytes": 3256,
870
885
  "afterBytes": 1986
871
886
  },
872
887
  {
873
888
  "file": "src/session/handlers/chat-events.js",
874
- "beforeBytes": 16226,
889
+ "beforeBytes": 16257,
875
890
  "afterBytes": 6965
876
891
  },
877
892
  {
@@ -881,12 +896,12 @@
881
896
  },
882
897
  {
883
898
  "file": "src/session/handlers/chat-session-lifecycle.js",
884
- "beforeBytes": 4467,
899
+ "beforeBytes": 4472,
885
900
  "afterBytes": 2119
886
901
  },
887
902
  {
888
903
  "file": "src/session/handlers/chat.js",
889
- "beforeBytes": 33158,
904
+ "beforeBytes": 33163,
890
905
  "afterBytes": 13967
891
906
  },
892
907
  {
@@ -896,7 +911,7 @@
896
911
  },
897
912
  {
898
913
  "file": "src/session/handlers/fs.js",
899
- "beforeBytes": 21946,
914
+ "beforeBytes": 21969,
900
915
  "afterBytes": 10405
901
916
  },
902
917
  {
@@ -926,17 +941,17 @@
926
941
  },
927
942
  {
928
943
  "file": "src/session/handlers/session-refresh.js",
929
- "beforeBytes": 963,
944
+ "beforeBytes": 979,
930
945
  "afterBytes": 451
931
946
  },
932
947
  {
933
948
  "file": "src/session/handlers/title.js",
934
- "beforeBytes": 3128,
949
+ "beforeBytes": 3146,
935
950
  "afterBytes": 1668
936
951
  },
937
952
  {
938
953
  "file": "src/session/handlers/tool-detail.js",
939
- "beforeBytes": 6399,
954
+ "beforeBytes": 6419,
940
955
  "afterBytes": 3357
941
956
  },
942
957
  {
@@ -961,8 +976,8 @@
961
976
  },
962
977
  {
963
978
  "file": "src/session/manager.js",
964
- "beforeBytes": 42678,
965
- "afterBytes": 22322
979
+ "beforeBytes": 39543,
980
+ "afterBytes": 20725
966
981
  },
967
982
  {
968
983
  "file": "src/session/native-cleanup-outbox.js",
@@ -981,9 +996,14 @@
981
996
  },
982
997
  {
983
998
  "file": "src/session/projection.js",
984
- "beforeBytes": 1991,
999
+ "beforeBytes": 1996,
985
1000
  "afterBytes": 966
986
1001
  },
1002
+ {
1003
+ "file": "src/session/queue-control.js",
1004
+ "beforeBytes": 11508,
1005
+ "afterBytes": 5870
1006
+ },
987
1007
  {
988
1008
  "file": "src/session/queue-helpers.js",
989
1009
  "beforeBytes": 8579,
@@ -991,7 +1011,7 @@
991
1011
  },
992
1012
  {
993
1013
  "file": "src/session/queue-message.js",
994
- "beforeBytes": 3257,
1014
+ "beforeBytes": 3270,
995
1015
  "afterBytes": 1987
996
1016
  },
997
1017
  {
@@ -1011,12 +1031,12 @@
1011
1031
  },
1012
1032
  {
1013
1033
  "file": "src/session/queue.js",
1014
- "beforeBytes": 49784,
1015
- "afterBytes": 21900
1034
+ "beforeBytes": 40411,
1035
+ "afterBytes": 17823
1016
1036
  },
1017
1037
  {
1018
1038
  "file": "src/session/queued-chat-dispatch.js",
1019
- "beforeBytes": 3176,
1039
+ "beforeBytes": 3189,
1020
1040
  "afterBytes": 1809
1021
1041
  },
1022
1042
  {
@@ -1046,17 +1066,17 @@
1046
1066
  },
1047
1067
  {
1048
1068
  "file": "src/session/tool-detail-store.js",
1049
- "beforeBytes": 2886,
1069
+ "beforeBytes": 2906,
1050
1070
  "afterBytes": 1429
1051
1071
  },
1052
1072
  {
1053
1073
  "file": "src/session/turn-trigger.js",
1054
- "beforeBytes": 106,
1074
+ "beforeBytes": 123,
1055
1075
  "afterBytes": 1
1056
1076
  },
1057
1077
  {
1058
1078
  "file": "src/session/types.js",
1059
- "beforeBytes": 159,
1079
+ "beforeBytes": 164,
1060
1080
  "afterBytes": 1
1061
1081
  },
1062
1082
  {
@@ -1076,13 +1096,13 @@
1076
1096
  },
1077
1097
  {
1078
1098
  "file": "src/upgrade/engine.js",
1079
- "beforeBytes": 16931,
1080
- "afterBytes": 7217
1099
+ "beforeBytes": 16718,
1100
+ "afterBytes": 7089
1081
1101
  },
1082
1102
  {
1083
1103
  "file": "src/upgrade/scheduler.js",
1084
- "beforeBytes": 7508,
1085
- "afterBytes": 4246
1104
+ "beforeBytes": 7326,
1105
+ "afterBytes": 4169
1086
1106
  },
1087
1107
  {
1088
1108
  "file": "src/upgrade/updater-bootstrap.js",
@@ -1091,8 +1111,8 @@
1091
1111
  },
1092
1112
  {
1093
1113
  "file": "src/upgrade/updater-launcher.js",
1094
- "beforeBytes": 10418,
1095
- "afterBytes": 5326
1114
+ "beforeBytes": 10317,
1115
+ "afterBytes": 5253
1096
1116
  },
1097
1117
  {
1098
1118
  "file": "src/upgrade/updater-protocol.js",
@@ -1,8 +1,8 @@
1
- import T from"node:os";import{desktopCommandDirectory as R}from"./runtime-distribution.js";import c from"node:path";import{spawnSync as p}from"node:child_process";import{buildAugmentedPath as g}from"./env-path.js";import{buildWindowsSystemEnv as a,resolveWindowsPowerShellPath as D}from"./windows-shell.js";const _="__SHENNIAN_AGENT_ENV_START__",u="__SHENNIAN_AGENT_ENV_END__",S=["HOME","USER","LOGNAME","LANG","LANGUAGE","LC_ALL","LC_CTYPE","TMPDIR","TMP","TEMP","TZ"],m=["SystemRoot","WINDIR","ComSpec","PATHEXT","USERPROFILE","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","TEMP","TMP","TZ"],P=["NO_COLOR","PI_CODING_AGENT_DIR"],f=["SHENNIAN_MANAGED_ROOM_CONTEXT","SHENNIAN_MANAGED_ROOM_IPC_ROOT"],I=["SHENNIAN_MANAGER_SESSION_ID","SHENNIAN_MANAGER_AGENT_SESSION_ID","SHENNIAN_MANAGER_WORKDIR","SHENNIAN_MANAGER_MODEL","SHENNIAN_MANAGER_IPC_URL","SHENNIAN_MANAGER_IPC_TOKEN"],h={codex:["OPENAI_BASE_URL","OPENAI_API_KEY"],claude:["ANTHROPIC_BASE_URL","ANTHROPIC_API_KEY"],pi:["DASHSCOPE_BASE_URL","DASHSCOPE_API_KEY"]};function G(e){return h[e]??[]}function w(e){return e==="codex"||e==="claude"||e==="pi-coding-agent"?[...f,...I]:f}function Y(e=process.platform){return["PATH",...e==="win32"?m:S,...P]}function A(e){return`'${e.replace(/'/g,"'\\''")}'`}function O(e){const n=e.indexOf(_),o=e.indexOf(u,n+_.length);if(n===-1||o===-1)return null;const t=e.slice(n+_.length,o);try{const s=JSON.parse(t),i={};for(const[E,r]of Object.entries(s))typeof r=="string"&&(i[E]=r);return i}catch{return null}}function M(){const e=process.env.SHELL?.trim()||"/bin/sh",n=[`printf ${A(_)}`,`${A(process.execPath)} -e ${A("process.stdout.write(JSON.stringify(process.env))")}`,`printf ${A(u)}`].join("; ");for(const o of[["-ilc",n],["-lc",n]]){const t=p(e,o,{env:process.env,encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0}),s=typeof t.stdout=="string"?O(t.stdout):null;if(s)return s}return null}function H(){const e=`
1
+ import T from"node:os";import c from"node:path";import{spawnSync as p}from"node:child_process";import{buildAugmentedPath as R}from"./env-path.js";import{buildWindowsSystemEnv as a,resolveWindowsPowerShellPath as g}from"./windows-shell.js";const _="__SHENNIAN_AGENT_ENV_START__",d="__SHENNIAN_AGENT_ENV_END__",S=["HOME","USER","LOGNAME","LANG","LANGUAGE","LC_ALL","LC_CTYPE","TMPDIR","TMP","TEMP","TZ"],m=["SystemRoot","WINDIR","ComSpec","PATHEXT","USERPROFILE","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","TEMP","TMP","TZ"],P=["NO_COLOR","PI_CODING_AGENT_DIR"],f=["SHENNIAN_MANAGED_ROOM_CONTEXT","SHENNIAN_MANAGED_ROOM_IPC_ROOT"],I=["SHENNIAN_MANAGER_SESSION_ID","SHENNIAN_MANAGER_AGENT_SESSION_ID","SHENNIAN_MANAGER_WORKDIR","SHENNIAN_MANAGER_MODEL","SHENNIAN_MANAGER_IPC_URL","SHENNIAN_MANAGER_IPC_TOKEN"],h={codex:["OPENAI_BASE_URL","OPENAI_API_KEY"],claude:["ANTHROPIC_BASE_URL","ANTHROPIC_API_KEY"],pi:["DASHSCOPE_BASE_URL","DASHSCOPE_API_KEY"]};function D(e){return h[e]??[]}function G(e){return e==="codex"||e==="claude"||e==="pi-coding-agent"?[...f,...I]:f}function $(e=process.platform){return["PATH",...e==="win32"?m:S,...P]}function A(e){return`'${e.replace(/'/g,"'\\''")}'`}function v(e){const n=e.indexOf(_),o=e.indexOf(d,n+_.length);if(n===-1||o===-1)return null;const t=e.slice(n+_.length,o);try{const s=JSON.parse(t),i={};for(const[E,r]of Object.entries(s))typeof r=="string"&&(i[E]=r);return i}catch{return null}}function w(){const e=process.env.SHELL?.trim()||"/bin/sh",n=[`printf ${A(_)}`,`${A(process.execPath)} -e ${A("process.stdout.write(JSON.stringify(process.env))")}`,`printf ${A(d)}`].join("; ");for(const o of[["-ilc",n],["-lc",n]]){const t=p(e,o,{env:process.env,encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0}),s=typeof t.stdout=="string"?v(t.stdout):null;if(s)return s}return null}function M(){const e=`
2
2
  $envs = @{}
3
3
  [Environment]::GetEnvironmentVariables('Machine').GetEnumerator() | ForEach-Object { $envs[$_.Key] = [string]$_.Value }
4
4
  [Environment]::GetEnvironmentVariables('User').GetEnumerator() | ForEach-Object { $envs[$_.Key] = [string]$_.Value }
5
5
  Write-Output '${_}'
6
6
  $envs | ConvertTo-Json -Compress
7
- Write-Output '${u}'
8
- `,n=p(D(),["-NoProfile","-Command",e],{env:{...process.env,...a(process.env)},encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0});return typeof n.stdout=="string"?O(n.stdout):null}function C(){return(T.platform()==="win32"?H():M())??{}}function y(e){const n={...e.daemonEnv,...e.userEnv,...e.extra};return process.platform==="win32"&&Object.assign(n,a(n)),n.PATH=x(e.daemonEnv,e.userEnv,e.extra,n),delete n.Path,delete n.path,n}function L(e={}){const n=y({daemonEnv:process.env,userEnv:C(),extra:e});return delete n.SHENNIAN_SCHEDULE_CONTEXT,v(n),n}function F(e={}){const n=L(e),o=new Set([...f,...I]);for(const t of Object.keys(n))t.startsWith("SHENNIAN_")&&!o.has(t)&&delete n[t];return n}function k(e){const n=e.daemonEnv??process.env,o=e.platform??process.platform,t={};return l(t,n,o==="win32"?m:S,o),l(t,e.providerEnv,G(e.agentType),o),l(t,e.sessionEnv,w(e.agentType),o),l(t,e.runtimeEnv,P,o),o==="win32"&&Object.assign(t,a({...n,...t})),t.PATH=b(n,t,o),v(t),delete t.Path,delete t.path,t}function v(e){delete e.ELECTRON_RUN_AS_NODE,delete e.ELECTRON_NO_ASAR,delete e.SHENNIAN_DESKTOP_CLI_SCRIPT,delete e.SHENNIAN_DESKTOP_CLI_BRIDGE,delete e.SHENNIAN_DESKTOP_CLI_COMMAND;const n=R();n&&(e.PATH=[n,...(e.PATH??"").split(c.delimiter).filter(o=>o&&o!==n)].join(c.delimiter))}function l(e,n,o,t){if(!n)return;const s=Object.entries(n);for(const i of o){const r=(t==="win32"?s.find(([N])=>N.toUpperCase()===i.toUpperCase()):s.find(([N])=>N===i))?.[1];typeof r=="string"&&r.length>0&&(e[i]=r)}}function b(e,n,o){const t=o==="win32"?c.win32.delimiter:c.posix.delimiter,s=[],i=(E,r=!1)=>{if(E)for(const N of E.split(t))!N||s.includes(N)||(r?s.unshift(N):s.push(N))};if(i(d(e)),i(c.dirname(process.execPath),!0),o==="win32"){const E=a({...e,...n}),r=E.SystemRoot??E.WINDIR??"C:\\Windows";i(c.win32.join(r,"System32")),i(c.win32.join(r,"System32","WindowsPowerShell","v1.0")),i(r)}else i("/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");return s.join(t)}function d(e){return e?.PATH??e?.Path??e?.path}function x(e,n,o,t){const s=[];for(const E of[d(e),d(n),d(o)])for(const r of(E??"").split(c.delimiter))r&&!s.includes(r)&&s.push(r);if(process.platform==="win32"){const E=t.SystemRoot||t.WINDIR||process.env.SystemRoot||process.env.WINDIR||"C:\\Windows";for(const r of[c.win32.join(E,"System32"),c.win32.join(E,"System32","WindowsPowerShell","v1.0"),c.win32.join(E)])r&&!s.includes(r)&&s.push(r)}const i=c.dirname(process.execPath);return i&&!s.includes(i)&&s.unshift(i),g({pathValue:s.join(c.delimiter),env:t})}export{f as MANAGED_AGENT_SESSION_ENV_KEYS,L as buildAgentProcessEnv,k as buildManagedAgentProcessEnv,F as buildManagedNativeFullProcessEnv,Y as getManagedAgentBaseEnvKeys,G as getManagedAgentProviderEnvKeys,w as getManagedAgentSessionEnvKeys,y as mergeAgentProcessEnv,C as readLatestUserEnv};
7
+ Write-Output '${d}'
8
+ `,n=p(g(),["-NoProfile","-Command",e],{env:{...process.env,...a(process.env)},encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1500,windowsHide:!0});return typeof n.stdout=="string"?v(n.stdout):null}function C(){return(T.platform()==="win32"?M():w())??{}}function H(e){const n={...e.daemonEnv,...e.userEnv,...e.extra};return process.platform==="win32"&&Object.assign(n,a(n)),n.PATH=b(e.daemonEnv,e.userEnv,e.extra,n),delete n.Path,delete n.path,n}function y(e={}){const n=H({daemonEnv:process.env,userEnv:C(),extra:e});return delete n.SHENNIAN_SCHEDULE_CONTEXT,O(n),n}function U(e={}){const n=y(e),o=new Set([...f,...I]);for(const t of Object.keys(n))t.startsWith("SHENNIAN_")&&!o.has(t)&&delete n[t];return n}function Y(e){const n=e.daemonEnv??process.env,o=e.platform??process.platform,t={};return l(t,n,o==="win32"?m:S,o),l(t,e.providerEnv,D(e.agentType),o),l(t,e.sessionEnv,G(e.agentType),o),l(t,e.runtimeEnv,P,o),o==="win32"&&Object.assign(t,a({...n,...t})),t.PATH=L(n,t,o),O(t),delete t.Path,delete t.path,t}function O(e){delete e.ELECTRON_RUN_AS_NODE,delete e.ELECTRON_NO_ASAR,delete e.SHENNIAN_DESKTOP_CLI_SCRIPT,delete e.SHENNIAN_DESKTOP_CLI_BRIDGE,delete e.SHENNIAN_DESKTOP_CLI_COMMAND}function l(e,n,o,t){if(!n)return;const s=Object.entries(n);for(const i of o){const r=(t==="win32"?s.find(([N])=>N.toUpperCase()===i.toUpperCase()):s.find(([N])=>N===i))?.[1];typeof r=="string"&&r.length>0&&(e[i]=r)}}function L(e,n,o){const t=o==="win32"?c.win32.delimiter:c.posix.delimiter,s=[],i=(E,r=!1)=>{if(E)for(const N of E.split(t))!N||s.includes(N)||(r?s.unshift(N):s.push(N))};if(i(u(e)),i(c.dirname(process.execPath),!0),o==="win32"){const E=a({...e,...n}),r=E.SystemRoot??E.WINDIR??"C:\\Windows";i(c.win32.join(r,"System32")),i(c.win32.join(r,"System32","WindowsPowerShell","v1.0")),i(r)}else i("/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");return s.join(t)}function u(e){return e?.PATH??e?.Path??e?.path}function b(e,n,o,t){const s=[];for(const E of[u(e),u(n),u(o)])for(const r of(E??"").split(c.delimiter))r&&!s.includes(r)&&s.push(r);if(process.platform==="win32"){const E=t.SystemRoot||t.WINDIR||process.env.SystemRoot||process.env.WINDIR||"C:\\Windows";for(const r of[c.win32.join(E,"System32"),c.win32.join(E,"System32","WindowsPowerShell","v1.0"),c.win32.join(E)])r&&!s.includes(r)&&s.push(r)}const i=c.dirname(process.execPath);return i&&!s.includes(i)&&s.unshift(i),R({pathValue:s.join(c.delimiter),env:t})}export{f as MANAGED_AGENT_SESSION_ENV_KEYS,y as buildAgentProcessEnv,Y as buildManagedAgentProcessEnv,U as buildManagedNativeFullProcessEnv,$ as getManagedAgentBaseEnvKeys,D as getManagedAgentProviderEnvKeys,G as getManagedAgentSessionEnvKeys,H as mergeAgentProcessEnv,C as readLatestUserEnv};
@@ -4,7 +4,6 @@ export type ServiceLaunchSpec = {
4
4
  command: string;
5
5
  args: string[];
6
6
  mode: ServiceLaunchMode;
7
- electronRunAsNode?: boolean;
8
7
  };
9
8
  export type DetachedLaunchSpec = {
10
9
  command: string;
@@ -17,7 +16,6 @@ export declare function resolveServiceLaunchSpec(input: {
17
16
  scriptPath: string;
18
17
  shennianCommandPath?: string | null;
19
18
  npxPath?: string | null;
20
- desktopBridgePath?: string | null;
21
19
  }): ServiceLaunchSpec;
22
20
  export declare function captureEnvForService(): Record<string, string>;
23
21
  /**
@@ -1 +1 @@
1
- import o from"node:fs";import a from"node:path";import s from"node:os";import{resolveShennianPath as i}from"../config/index.js";import{buildAugmentedPath as N}from"../env-path.js";import{getPlatform as A,SHENNIAN_DIR as m}from"./daemon-state.js";const E=new Set(["PATH","HOME","USERPROFILE","HOMEDRIVE","HOMEPATH","USERNAME","USERDOMAIN","COMPUTERNAME","USER","LOGNAME","SHELL","TMPDIR","LANG","LC_ALL","LC_CTYPE","SSH_AUTH_SOCK","XDG_CONFIG_HOME","XDG_DATA_HOME","TEMP","TMP","APPDATA","LOCALAPPDATA","ELECTRON_RUN_AS_NODE","SHENNIAN_DESKTOP_CLI_SCRIPT","SHENNIAN_DESKTOP_CLI_BRIDGE","SHENNIAN_DESKTOP_SERVER_URL","SHENNIAN_WECHAT_CHANNEL_HELPER_DIR","SHENNIAN_HOME","SHENNIAN_ACCOUNT_NAMESPACE_ID","SHENNIAN_NATIVE_FUSION_DISABLED","SHENNIAN_WECHAT_DELIVERABILITY_TRACE"]);function S(e){return E.has(e)}function t(e){const r=e.replace(/\\/g,"/").toLowerCase(),n=s.tmpdir().replace(/\\/g,"/").toLowerCase();return r.includes("/_npx/")||r.includes("/npm-cache/_npx/")||r.includes("/pnpm/dlx/")||r.startsWith(n.endsWith("/")?n:`${n}/`)}function I(e){return process.env.ELECTRON_RUN_AS_NODE==="1"&&e.desktopBridgePath&&o.existsSync(e.scriptPath)&&o.existsSync(e.desktopBridgePath)?{command:e.nodeExec,args:[e.desktopBridgePath,e.scriptPath,"run-service"],mode:"direct",electronRunAsNode:!0}:o.existsSync(e.scriptPath)&&(process.env.SHENNIAN_E2E_ISOLATED_DAEMON==="1"||!t(e.scriptPath))?{command:e.nodeExec,args:[e.scriptPath,"run-service"],mode:"direct"}:e.shennianCommandPath&&!t(e.shennianCommandPath)?{command:e.shennianCommandPath,args:["run-service"],mode:"global-shim"}:e.npxPath?{command:e.npxPath,args:["--yes","shennian","run-service"],mode:"npx"}:{command:e.nodeExec,args:[e.scriptPath,"run-service"],mode:"direct"}}function T(){const e={};for(const r of E)process.env[r]&&(e[r]=process.env[r]);if(e.HOME??=s.homedir(),e.PATH=N({pathValue:e.PATH,env:e}),e.USER??=s.userInfo().username,A()==="win32"){const r=process.env.TEMP||process.env.TMP||s.tmpdir(),n=s.homedir();e.USERPROFILE??=n;const c=a.win32.parse(n);e.HOMEDRIVE??=c.root.replace(/[\\/]$/,"")||process.env.HOMEDRIVE||"",e.HOMEPATH??=n.slice((e.HOMEDRIVE||"").length)||process.env.HOMEPATH||"",e.USERNAME??=process.env.USERNAME||s.userInfo().username,e.COMPUTERNAME??=process.env.COMPUTERNAME||"",e.TMPDIR??=r,e.TEMP??=r,e.TMP??=r}else e.TMPDIR??="/tmp";return e}function O(){o.mkdirSync(m,{recursive:!0});const e={};for(const[r,n]of Object.entries(process.env))n!==void 0&&S(r)&&(e[r]=n);o.writeFileSync(i("env.json"),JSON.stringify(e,null,2))}export{T as captureEnvForService,t as isEphemeralCliPath,S as isSafeSnapshotEnvKey,I as resolveServiceLaunchSpec,O as saveEnvSnapshot};
1
+ import s from"node:fs";import a from"node:path";import o from"node:os";import{resolveShennianPath as i}from"../config/index.js";import{buildAugmentedPath as m}from"../env-path.js";import{getPlatform as A,SHENNIAN_DIR as N}from"./daemon-state.js";const E=new Set(["PATH","HOME","USERPROFILE","HOMEDRIVE","HOMEPATH","USERNAME","USERDOMAIN","COMPUTERNAME","USER","LOGNAME","SHELL","TMPDIR","LANG","LC_ALL","LC_CTYPE","SSH_AUTH_SOCK","XDG_CONFIG_HOME","XDG_DATA_HOME","TEMP","TMP","APPDATA","LOCALAPPDATA","SHENNIAN_DESKTOP_SERVER_URL","SHENNIAN_WECHAT_CHANNEL_HELPER_DIR","SHENNIAN_HOME","SHENNIAN_ACCOUNT_NAMESPACE_ID","SHENNIAN_NATIVE_FUSION_DISABLED","SHENNIAN_WECHAT_DELIVERABILITY_TRACE"]);function P(e){return E.has(e)}function t(e){const r=e.replace(/\\/g,"/").toLowerCase(),n=o.tmpdir().replace(/\\/g,"/").toLowerCase();return r.includes("/_npx/")||r.includes("/npm-cache/_npx/")||r.includes("/pnpm/dlx/")||r.startsWith(n.endsWith("/")?n:`${n}/`)}function T(e){return s.existsSync(e.scriptPath)&&(process.env.SHENNIAN_E2E_ISOLATED_DAEMON==="1"||!t(e.scriptPath))?{command:e.nodeExec,args:[e.scriptPath,"run-service"],mode:"direct"}:e.shennianCommandPath&&!t(e.shennianCommandPath)?{command:e.shennianCommandPath,args:["run-service"],mode:"global-shim"}:e.npxPath?{command:e.npxPath,args:["--yes","shennian","run-service"],mode:"npx"}:{command:e.nodeExec,args:[e.scriptPath,"run-service"],mode:"direct"}}function d(){const e={};for(const r of E)process.env[r]&&(e[r]=process.env[r]);if(e.HOME??=o.homedir(),e.PATH=m({pathValue:e.PATH,env:e}),e.USER??=o.userInfo().username,A()==="win32"){const r=process.env.TEMP||process.env.TMP||o.tmpdir(),n=o.homedir();e.USERPROFILE??=n;const c=a.win32.parse(n);e.HOMEDRIVE??=c.root.replace(/[\\/]$/,"")||process.env.HOMEDRIVE||"",e.HOMEPATH??=n.slice((e.HOMEDRIVE||"").length)||process.env.HOMEPATH||"",e.USERNAME??=process.env.USERNAME||o.userInfo().username,e.COMPUTERNAME??=process.env.COMPUTERNAME||"",e.TMPDIR??=r,e.TEMP??=r,e.TMP??=r}else e.TMPDIR??="/tmp";return e}function I(){s.mkdirSync(N,{recursive:!0});const e={};for(const[r,n]of Object.entries(process.env))n!==void 0&&P(r)&&(e[r]=n);s.writeFileSync(i("env.json"),JSON.stringify(e,null,2))}export{d as captureEnvForService,t as isEphemeralCliPath,P as isSafeSnapshotEnvKey,T as resolveServiceLaunchSpec,I as saveEnvSnapshot};
@@ -1 +1 @@
1
- import i from"node:fs";import c from"node:path";import f from"node:os";import{execSync as y}from"node:child_process";import{randomUUID as A}from"node:crypto";import{getShennianDir as b,loadConfig as O,resolveShennianPath as p}from"../config/index.js";import{isDesktopDistribution as P}from"../runtime-distribution.js";import{findRunningWindowsDaemonProcessIds as k,inferDaemonLauncherFromCommand as D,isDaemonProcessRunning as L,isShennianRunServiceCommand as _,readWindowsProcessCommand as F}from"./daemon-process.js";const u=b(),l=p("daemon.pid"),R=p("daemon.log"),w=p("remote-access.disabled"),m=p("daemon-launcher.json");function h(){const e=f.platform();return e==="darwin"||e==="linux"||e==="win32"?e:"linux"}function C(e){const n=e.trim();if(!n)return null;if(n.startsWith("{"))try{const t=JSON.parse(n),o=Number(t.pid);return!Number.isInteger(o)||o<=0?null:{pid:o,...typeof t.instanceId=="string"?{instanceId:t.instanceId}:{},...typeof t.version=="string"?{version:t.version}:{},...t.launcher==="desktop-managed"||t.launcher==="global-cli"||t.launcher==="unknown"?{launcher:t.launcher}:{},...typeof t.startedAt=="string"?{startedAt:t.startedAt}:{},...t.adopted===!0?{adopted:!0}:{}}}catch{return null}const r=parseInt(n,10);return isNaN(r)?null:{pid:r}}function N(){try{return C(i.readFileSync(l,"utf-8"))}catch{return null}}function S(e){return L(e)}function Q(e,n=3e3){const r=Date.now();for(;Date.now()-r<n;){if(!S(e))return!0;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100)}return!S(e)}function H(){try{return i.lstatSync(w),!0}catch(e){return!(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT")}}function X(){try{i.unlinkSync(w)}catch(e){if(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT")return;throw e}}function v(){return P()||process.env.SHENNIAN_DESKTOP_CLI_SCRIPT?"desktop-managed":"global-cli"}function T(){return`${process.pid}-${Date.now()}-${A()}`}function U(e,n,r={}){i.mkdirSync(u,{recursive:!0}),i.writeFileSync(l,JSON.stringify({pid:e,instanceId:n,...r.version?{version:r.version}:{},launcher:r.launcher??v(),...r.adopted?{adopted:!0}:{},startedAt:new Date().toISOString()},null,2))}function Y(e,n){const r=N();if(!(r?.pid!==e||r.instanceId!==n))try{i.unlinkSync(l)}catch{}}function x(e,n=v(),r){i.mkdirSync(u,{recursive:!0}),i.writeFileSync(m,JSON.stringify({pid:e,launcher:n,...r?{instanceId:r}:{},updatedAt:new Date().toISOString()},null,2))}function Z(e){if(e)try{if(JSON.parse(i.readFileSync(m,"utf-8")).instanceId!==e)return}catch{return}try{i.unlinkSync(m)}catch{}}function ee(e){e&&x(e)}function $(e,n){if(!e||!n)return"unknown";try{const r=JSON.parse(i.readFileSync(m,"utf-8"));if(r.pid!==e)return"unknown";if(r.launcher==="desktop-managed"||r.launcher==="global-cli")return r.launcher}catch{}return I(e)}function I(e){if(h()==="win32"){const n=F(e);return n?D(n):"unknown"}try{const n=y(`ps -p ${e} -o command=`,{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1e3,windowsHide:!0}).replace(/\\/g,"/");return D(n)}catch{}return"unknown"}function J(e=process.pid){if(h()==="win32")return k(e);try{return y("ps -axo pid=,command=",{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1e3,windowsHide:!0}).split(/\r?\n/).map(r=>{const t=r.trim().match(/^(\d+)\s+(.+)$/);if(!t)return null;const o=Number(t[1]),d=t[2];return!Number.isInteger(o)||o===e?null:_(d)?o:null}).filter(r=>typeof r=="number")}catch{return[]}}function E(e=process.env,n=u,r=f.tmpdir(),t=c.join(f.homedir(),".shennian")){if(e.SHENNIAN_E2E_ISOLATED_DAEMON!=="1"||!e.SHENNIAN_HOME?.trim()||c.resolve(n)===c.resolve(t))return!1;const o=c.relative(c.resolve(r),c.resolve(n));return o!==""&&o!==".."&&!o.startsWith(`..${c.sep}`)&&!c.isAbsolute(o)||c.resolve(n)===c.resolve(e.SHENNIAN_HOME)}function j(e=process.env,n=u){return!E(e,n)}function ne(e=process.env,n=u){return!E(e,n)}function re(e={}){let n=N(),r=n?.pid??null,t=r!==null&&S(r),o=r!==null&&!t,d=n?.adopted===!0;const s=O();if(o&&e.cleanupStale){try{i.unlinkSync(l)}catch{}n=null,r=null,t=!1,o=!1}if(!t&&j()){const a=J()[0];if(a&&(r=a,t=!0,o=!1,d=!0,e.cleanupStale)){const g=T();U(a,g,{launcher:I(a),adopted:!0}),x(a,I(a)),n={pid:a,instanceId:g,adopted:!0}}}return{running:t,pid:r,stale:o,remoteAccessDisabled:H(),launcher:$(r,t),...t&&n?.pid===r&&n.version?{daemonVersion:n.version}:{},platform:h(),shennianDir:u,pidFile:l,logFile:R,...n?.instanceId?{instanceId:n.instanceId}:{},...d?{adopted:!0}:{},...s.machineId?{machineId:s.machineId}:{},paired:!!(s.machineToken&&s.machineId),...s.serverUrl?{serverUrl:s.serverUrl}:{}}}export{m as LAUNCHER_FILE,R as LOG_FILE,l as PID_FILE,w as REMOTE_ACCESS_DISABLED_FILE,u as SHENNIAN_DIR,Z as clearDaemonLauncher,Y as clearDaemonPidIfOwner,X as clearRemoteAccessDisabled,T as createDaemonInstanceId,J as findRunningDaemonProcessIds,v as getCurrentProcessDaemonLauncher,re as getDaemonStatus,h as getPlatform,E as isIsolatedDaemonE2eInstance,H as isRemoteAccessDisabled,S as isRunning,N as readPidRecord,ee as recordStartedDaemon,j as shouldDiscoverGlobalDaemonProcesses,ne as shouldInstallPlatformService,Q as waitForPidExitSync,x as writeDaemonLauncher,U as writeDaemonPid};
1
+ import i from"node:fs";import c from"node:path";import f from"node:os";import{execSync as g}from"node:child_process";import{randomUUID as A}from"node:crypto";import{getShennianDir as b,loadConfig as O,resolveShennianPath as p}from"../config/index.js";import{findRunningWindowsDaemonProcessIds as P,inferDaemonLauncherFromCommand as w,isDaemonProcessRunning as k,isShennianRunServiceCommand as F,readWindowsProcessCommand as L}from"./daemon-process.js";const u=b(),l=p("daemon.pid"),R=p("daemon.log"),D=p("remote-access.disabled"),m=p("daemon-launcher.json");function h(){const e=f.platform();return e==="darwin"||e==="linux"||e==="win32"?e:"linux"}function _(e){const n=e.trim();if(!n)return null;if(n.startsWith("{"))try{const t=JSON.parse(n),o=Number(t.pid);return!Number.isInteger(o)||o<=0?null:{pid:o,...typeof t.instanceId=="string"?{instanceId:t.instanceId}:{},...typeof t.version=="string"?{version:t.version}:{},...t.launcher==="desktop-managed"||t.launcher==="global-cli"||t.launcher==="unknown"?{launcher:t.launcher}:{},...typeof t.startedAt=="string"?{startedAt:t.startedAt}:{},...t.adopted===!0?{adopted:!0}:{}}}catch{return null}const r=parseInt(n,10);return isNaN(r)?null:{pid:r}}function N(){try{return _(i.readFileSync(l,"utf-8"))}catch{return null}}function S(e){return k(e)}function z(e,n=3e3){const r=Date.now();for(;Date.now()-r<n;){if(!S(e))return!0;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100)}return!S(e)}function H(){try{return i.lstatSync(D),!0}catch(e){return!(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT")}}function K(){try{i.unlinkSync(D)}catch(e){if(e&&typeof e=="object"&&"code"in e&&e.code==="ENOENT")return;throw e}}function v(){return"global-cli"}function C(){return`${process.pid}-${Date.now()}-${A()}`}function T(e,n,r={}){i.mkdirSync(u,{recursive:!0}),i.writeFileSync(l,JSON.stringify({pid:e,instanceId:n,...r.version?{version:r.version}:{},launcher:r.launcher??v(),...r.adopted?{adopted:!0}:{},startedAt:new Date().toISOString()},null,2))}function Q(e,n){const r=N();if(!(r?.pid!==e||r.instanceId!==n))try{i.unlinkSync(l)}catch{}}function x(e,n=v(),r){i.mkdirSync(u,{recursive:!0}),i.writeFileSync(m,JSON.stringify({pid:e,launcher:n,...r?{instanceId:r}:{},updatedAt:new Date().toISOString()},null,2))}function X(e){if(e)try{if(JSON.parse(i.readFileSync(m,"utf-8")).instanceId!==e)return}catch{return}try{i.unlinkSync(m)}catch{}}function Y(e){e&&x(e)}function U(e,n){if(!e||!n)return"unknown";try{const r=JSON.parse(i.readFileSync(m,"utf-8"));if(r.pid!==e)return"unknown";if(r.launcher==="desktop-managed"||r.launcher==="global-cli")return r.launcher}catch{}return I(e)}function I(e){if(h()==="win32"){const n=L(e);return n?w(n):"unknown"}try{const n=g(`ps -p ${e} -o command=`,{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1e3,windowsHide:!0}).replace(/\\/g,"/");return w(n)}catch{}return"unknown"}function $(e=process.pid){if(h()==="win32")return P(e);try{return g("ps -axo pid=,command=",{encoding:"utf-8",stdio:["ignore","pipe","ignore"],timeout:1e3,windowsHide:!0}).split(/\r?\n/).map(r=>{const t=r.trim().match(/^(\d+)\s+(.+)$/);if(!t)return null;const o=Number(t[1]),d=t[2];return!Number.isInteger(o)||o===e?null:F(d)?o:null}).filter(r=>typeof r=="number")}catch{return[]}}function E(e=process.env,n=u,r=f.tmpdir(),t=c.join(f.homedir(),".shennian")){if(e.SHENNIAN_E2E_ISOLATED_DAEMON!=="1"||!e.SHENNIAN_HOME?.trim()||c.resolve(n)===c.resolve(t))return!1;const o=c.relative(c.resolve(r),c.resolve(n));return o!==""&&o!==".."&&!o.startsWith(`..${c.sep}`)&&!c.isAbsolute(o)||c.resolve(n)===c.resolve(e.SHENNIAN_HOME)}function J(e=process.env,n=u){return!E(e,n)}function Z(e=process.env,n=u){return!E(e,n)}function ee(e={}){let n=N(),r=n?.pid??null,t=r!==null&&S(r),o=r!==null&&!t,d=n?.adopted===!0;const s=O();if(o&&e.cleanupStale){try{i.unlinkSync(l)}catch{}n=null,r=null,t=!1,o=!1}if(!t&&J()){const a=$()[0];if(a&&(r=a,t=!0,o=!1,d=!0,e.cleanupStale)){const y=C();T(a,y,{launcher:I(a),adopted:!0}),x(a,I(a)),n={pid:a,instanceId:y,adopted:!0}}}return{running:t,pid:r,stale:o,remoteAccessDisabled:H(),launcher:U(r,t),...t&&n?.pid===r&&n.version?{daemonVersion:n.version}:{},platform:h(),shennianDir:u,pidFile:l,logFile:R,...n?.instanceId?{instanceId:n.instanceId}:{},...d?{adopted:!0}:{},...s.machineId?{machineId:s.machineId}:{},paired:!!(s.machineToken&&s.machineId),...s.serverUrl?{serverUrl:s.serverUrl}:{}}}export{m as LAUNCHER_FILE,R as LOG_FILE,l as PID_FILE,D as REMOTE_ACCESS_DISABLED_FILE,u as SHENNIAN_DIR,X as clearDaemonLauncher,Q as clearDaemonPidIfOwner,K as clearRemoteAccessDisabled,C as createDaemonInstanceId,$ as findRunningDaemonProcessIds,v as getCurrentProcessDaemonLauncher,ee as getDaemonStatus,h as getPlatform,E as isIsolatedDaemonE2eInstance,H as isRemoteAccessDisabled,S as isRunning,N as readPidRecord,Y as recordStartedDaemon,J as shouldDiscoverGlobalDaemonProcesses,Z as shouldInstallPlatformService,z as waitForPidExitSync,x as writeDaemonLauncher,T as writeDaemonPid};
@@ -13,7 +13,6 @@ export declare function buildWindowsScheduledTaskXml(input: {
13
13
  userId: string;
14
14
  command: string;
15
15
  arguments: string[];
16
- desktopManaged?: boolean;
17
16
  }): string;
18
17
  export declare function buildWindowsScheduledTaskCommands(input: {
19
18
  taskName: string;
@@ -22,11 +21,9 @@ export declare function buildWindowsScheduledTaskCommands(input: {
22
21
  create: string;
23
22
  run: string;
24
23
  };
25
- /** Managed Desktop cannot promise durable autostart after a detached fallback. */
26
24
  export declare function registerWindowsScheduledTask(input: {
27
25
  taskName: string;
28
26
  xmlPath: string;
29
- desktopManaged: boolean;
30
27
  }, execute: (command: string) => void): boolean;
31
28
  export declare function buildWindowsScheduledTaskSuspendCommands(taskName: string): {
32
29
  disable: string;
@@ -1,4 +1,4 @@
1
- import l from"node:path";function d(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function f(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function r(e){return`"${e.replace(/"/g,'""')}"`}function c(e){return e.replace(/"/g,'""')}function o(e){return d(e)}function u(e){const n=l.extname(e).toLowerCase();return n===".cmd"||n===".bat"}function S(e,n){const t=i=>r(i.replace(/%/g,"%%")),a=[e.command,...e.args].map(t).join(" "),s=u(e.command)?`call ${a}`:a;return["@echo off","chcp 65001 >nul","setlocal DisableDelayedExpansion",...e.electronRunAsNode?['set "ELECTRON_RUN_AS_NODE=1"']:[],'if not defined SHENNIAN_HOME set "SHENNIAN_HOME=%~dp0."',`${s} >> ${t(n)} 2>&1`,""].join(`\r
1
+ import s from"node:path";function l(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function f(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function r(e){return`"${e.replace(/"/g,'""')}"`}function c(e){return e.replace(/"/g,'""')}function a(e){return l(e)}function d(e){const n=s.extname(e).toLowerCase();return n===".cmd"||n===".bat"}function S(e,n){const t=i=>r(i.replace(/%/g,"%%")),o=[e.command,...e.args].map(t).join(" ");return["@echo off","chcp 65001 >nul","setlocal DisableDelayedExpansion",'if not defined SHENNIAN_HOME set "SHENNIAN_HOME=%~dp0."',`${d(e.command)?`call ${o}`:o} >> ${t(n)} 2>&1`,""].join(`\r
2
2
  `)}function h(e){return['Set shell = CreateObject("WScript.Shell")',`shell.Run Chr(34) & "${c(e)}" & Chr(34), 0, False`,""].join(`\r
3
3
  `)}function I(e){const n=e.arguments.join(" ");return`<?xml version="1.0" encoding="UTF-16"?>
4
4
  <Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
@@ -6,15 +6,15 @@ import l from"node:path";function d(e){return e.replace(/&/g,"&amp;").replace(/<
6
6
  <Description>Shennian Agent Daemon</Description>
7
7
  </RegistrationInfo>
8
8
  <Triggers>
9
- ${e.desktopManaged?"":`<BootTrigger>
9
+ <BootTrigger>
10
10
  <Enabled>true</Enabled>
11
11
  <Delay>PT15S</Delay>
12
- </BootTrigger>`}
12
+ </BootTrigger>
13
13
  <LogonTrigger>
14
14
  <Enabled>true</Enabled>
15
- <UserId>${o(e.userId)}</UserId>
15
+ <UserId>${a(e.userId)}</UserId>
16
16
  </LogonTrigger>
17
- ${e.desktopManaged?"":`<EventTrigger>
17
+ <EventTrigger>
18
18
  <Enabled>true</Enabled>
19
19
  <Subscription><![CDATA[
20
20
  <QueryList>
@@ -22,12 +22,12 @@ import l from"node:path";function d(e){return e.replace(/&/g,"&amp;").replace(/<
22
22
  <Select Path="System">*[System[Provider[@Name='Microsoft-Windows-Power-Troubleshooter'] and EventID=1]]</Select>
23
23
  </Query>
24
24
  </QueryList>]]></Subscription>
25
- </EventTrigger>`}
25
+ </EventTrigger>
26
26
  </Triggers>
27
27
  <Principals>
28
28
  <Principal id="Author">
29
- <UserId>${o(e.userId)}</UserId>
30
- <LogonType>${e.desktopManaged?"InteractiveToken":"S4U"}</LogonType>
29
+ <UserId>${a(e.userId)}</UserId>
30
+ <LogonType>S4U</LogonType>
31
31
  <RunLevel>LeastPrivilege</RunLevel>
32
32
  </Principal>
33
33
  </Principals>
@@ -46,7 +46,7 @@ import l from"node:path";function d(e){return e.replace(/&/g,"&amp;").replace(/<
46
46
  <Enabled>true</Enabled>
47
47
  <Hidden>true</Hidden>
48
48
  <RunOnlyIfIdle>false</RunOnlyIfIdle>
49
- <WakeToRun>${!e.desktopManaged}</WakeToRun>
49
+ <WakeToRun>true</WakeToRun>
50
50
  <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
51
51
  <Priority>7</Priority>
52
52
  <RestartOnFailure>
@@ -56,8 +56,8 @@ import l from"node:path";function d(e){return e.replace(/&/g,"&amp;").replace(/<
56
56
  </Settings>
57
57
  <Actions Context="Author">
58
58
  <Exec>
59
- <Command>${o(e.command)}</Command>
60
- <Arguments>${o(n)}</Arguments>
59
+ <Command>${a(e.command)}</Command>
60
+ <Arguments>${a(n)}</Arguments>
61
61
  </Exec>
62
62
  </Actions>
63
- </Task>`}function m(e){return{create:`schtasks /create /tn ${r(e.taskName)} /xml ${r(e.xmlPath)} /f`,run:`schtasks /run /tn ${r(e.taskName)}`}}function b(e,n){const t=m(e);try{return n(t.create),n(t.run),!0}catch{if(e.desktopManaged)throw new Error("windows_autostart_registration_failed: Open Shennian Desktop in your normal Windows login and retry. An existing administrator-owned ShennianAgent task may require administrator-assisted migration; no background startup fallback was installed.");return!1}}function g(e){return{disable:`schtasks /change /tn ${r(e)} /disable`,end:`schtasks /end /tn ${r(e)}`}}function T(e,n){const t=g(e);for(const a of[t.disable,t.end])try{n(a)}catch{}}export{S as buildWindowsLauncherCommand,m as buildWindowsScheduledTaskCommands,g as buildWindowsScheduledTaskSuspendCommands,I as buildWindowsScheduledTaskXml,h as buildWindowsStartupVbs,d as escapeXml,u as isWindowsCmdScript,r as quoteCmdArg,f as quoteSystemdArg,b as registerWindowsScheduledTask,T as suspendWindowsScheduledTask};
63
+ </Task>`}function u(e){return{create:`schtasks /create /tn ${r(e.taskName)} /xml ${r(e.xmlPath)} /f`,run:`schtasks /run /tn ${r(e.taskName)}`}}function b(e,n){const t=u(e);try{return n(t.create),n(t.run),!0}catch{return!1}}function m(e){return{disable:`schtasks /change /tn ${r(e)} /disable`,end:`schtasks /end /tn ${r(e)}`}}function T(e,n){const t=m(e);for(const o of[t.disable,t.end])try{n(o)}catch{}}export{S as buildWindowsLauncherCommand,u as buildWindowsScheduledTaskCommands,m as buildWindowsScheduledTaskSuspendCommands,I as buildWindowsScheduledTaskXml,h as buildWindowsStartupVbs,l as escapeXml,d as isWindowsCmdScript,r as quoteCmdArg,f as quoteSystemdArg,b as registerWindowsScheduledTask,T as suspendWindowsScheduledTask};
@@ -50,6 +50,7 @@ export declare function startDaemonProcess(opts?: {
50
50
  export declare function shouldReplaceRunningDaemon(status: Pick<DaemonStatus, 'pid' | 'running' | 'adopted' | 'launcher'>, record?: {
51
51
  version?: string;
52
52
  } | null, currentVersion?: string): boolean;
53
+ export declare function getUnsupportedDaemonSourceError(status: Pick<DaemonStatus, 'pid' | 'running' | 'launcher'>): string | null;
53
54
  export declare function isAutoStartServicePresent(platform?: Platform): boolean;
54
55
  export declare function canReuseRunningDaemonForStart(status: Pick<DaemonStatus, 'pid' | 'running' | 'stale' | 'remoteAccessDisabled' | 'adopted' | 'launcher'>, opts: {
55
56
  api?: string;