@kyoofus/kyoflow 0.0.1

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 (152) hide show
  1. package/LICENSE +21 -0
  2. package/dist/.env.example +4 -0
  3. package/dist/backend/pyproject.toml +19 -0
  4. package/dist/backend/requirements.txt +2 -0
  5. package/dist/backend/src/kyoflow/__init__.py +12 -0
  6. package/dist/backend/src/kyoflow/__main__.py +88 -0
  7. package/dist/backend/src/kyoflow/__pycache__/__init__.cpython-314.pyc +0 -0
  8. package/dist/backend/src/kyoflow/__pycache__/__main__.cpython-314.pyc +0 -0
  9. package/dist/backend/src/kyoflow/__pycache__/main.cpython-314.pyc +0 -0
  10. package/dist/backend/src/kyoflow/main.py +63 -0
  11. package/dist/cli.js +178 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/postinstall.js +18 -0
  14. package/dist/postinstall.js.map +1 -0
  15. package/dist/server.js +31 -0
  16. package/dist/server.js.map +1 -0
  17. package/dist/web/client/_app/immutable/assets/0.BrmKgNLm.css +1 -0
  18. package/dist/web/client/_app/immutable/assets/0.BrmKgNLm.css.br +0 -0
  19. package/dist/web/client/_app/immutable/assets/0.BrmKgNLm.css.gz +0 -0
  20. package/dist/web/client/_app/immutable/assets/3.DVH1XF8v.css +1 -0
  21. package/dist/web/client/_app/immutable/assets/3.DVH1XF8v.css.br +0 -0
  22. package/dist/web/client/_app/immutable/assets/3.DVH1XF8v.css.gz +0 -0
  23. package/dist/web/client/_app/immutable/assets/4.zbKoyNjI.css +1 -0
  24. package/dist/web/client/_app/immutable/assets/4.zbKoyNjI.css.br +0 -0
  25. package/dist/web/client/_app/immutable/assets/4.zbKoyNjI.css.gz +0 -0
  26. package/dist/web/client/_app/immutable/assets/5.CHnq1Bst.css +1 -0
  27. package/dist/web/client/_app/immutable/assets/5.CHnq1Bst.css.br +0 -0
  28. package/dist/web/client/_app/immutable/assets/5.CHnq1Bst.css.gz +0 -0
  29. package/dist/web/client/_app/immutable/chunks/44EpIQ4d.js +1 -0
  30. package/dist/web/client/_app/immutable/chunks/44EpIQ4d.js.br +0 -0
  31. package/dist/web/client/_app/immutable/chunks/44EpIQ4d.js.gz +0 -0
  32. package/dist/web/client/_app/immutable/chunks/B09fC2bi.js +1 -0
  33. package/dist/web/client/_app/immutable/chunks/B09fC2bi.js.br +0 -0
  34. package/dist/web/client/_app/immutable/chunks/B09fC2bi.js.gz +0 -0
  35. package/dist/web/client/_app/immutable/chunks/BJ-VzAMM.js +1 -0
  36. package/dist/web/client/_app/immutable/chunks/BJ-VzAMM.js.br +0 -0
  37. package/dist/web/client/_app/immutable/chunks/BJ-VzAMM.js.gz +0 -0
  38. package/dist/web/client/_app/immutable/chunks/B_AmmRQN.js +1 -0
  39. package/dist/web/client/_app/immutable/chunks/B_AmmRQN.js.br +2 -0
  40. package/dist/web/client/_app/immutable/chunks/B_AmmRQN.js.gz +0 -0
  41. package/dist/web/client/_app/immutable/chunks/C63Z97y6.js +1 -0
  42. package/dist/web/client/_app/immutable/chunks/C63Z97y6.js.br +0 -0
  43. package/dist/web/client/_app/immutable/chunks/C63Z97y6.js.gz +0 -0
  44. package/dist/web/client/_app/immutable/chunks/C_EPgsy6.js +1 -0
  45. package/dist/web/client/_app/immutable/chunks/C_EPgsy6.js.br +0 -0
  46. package/dist/web/client/_app/immutable/chunks/C_EPgsy6.js.gz +0 -0
  47. package/dist/web/client/_app/immutable/chunks/Ck1fWG4n.js +1 -0
  48. package/dist/web/client/_app/immutable/chunks/Ck1fWG4n.js.br +0 -0
  49. package/dist/web/client/_app/immutable/chunks/Ck1fWG4n.js.gz +0 -0
  50. package/dist/web/client/_app/immutable/chunks/D8fmz15L.js +1 -0
  51. package/dist/web/client/_app/immutable/chunks/D8fmz15L.js.br +0 -0
  52. package/dist/web/client/_app/immutable/chunks/D8fmz15L.js.gz +0 -0
  53. package/dist/web/client/_app/immutable/chunks/DDNuMsfB.js +1 -0
  54. package/dist/web/client/_app/immutable/chunks/DDNuMsfB.js.br +0 -0
  55. package/dist/web/client/_app/immutable/chunks/DDNuMsfB.js.gz +0 -0
  56. package/dist/web/client/_app/immutable/chunks/Da9oKyxb.js +1 -0
  57. package/dist/web/client/_app/immutable/chunks/Da9oKyxb.js.br +0 -0
  58. package/dist/web/client/_app/immutable/chunks/Da9oKyxb.js.gz +0 -0
  59. package/dist/web/client/_app/immutable/chunks/DtmuEK64.js +1 -0
  60. package/dist/web/client/_app/immutable/chunks/DtmuEK64.js.br +0 -0
  61. package/dist/web/client/_app/immutable/chunks/DtmuEK64.js.gz +0 -0
  62. package/dist/web/client/_app/immutable/chunks/EmrU7Abi.js +298 -0
  63. package/dist/web/client/_app/immutable/chunks/EmrU7Abi.js.br +0 -0
  64. package/dist/web/client/_app/immutable/chunks/EmrU7Abi.js.gz +0 -0
  65. package/dist/web/client/_app/immutable/chunks/PPVm8Dsz.js +1 -0
  66. package/dist/web/client/_app/immutable/chunks/PPVm8Dsz.js.br +0 -0
  67. package/dist/web/client/_app/immutable/chunks/PPVm8Dsz.js.gz +0 -0
  68. package/dist/web/client/_app/immutable/chunks/ZW9ZwxRj.js +2 -0
  69. package/dist/web/client/_app/immutable/chunks/ZW9ZwxRj.js.br +0 -0
  70. package/dist/web/client/_app/immutable/chunks/ZW9ZwxRj.js.gz +0 -0
  71. package/dist/web/client/_app/immutable/chunks/b2dyOoG8.js +1 -0
  72. package/dist/web/client/_app/immutable/chunks/b2dyOoG8.js.br +0 -0
  73. package/dist/web/client/_app/immutable/chunks/b2dyOoG8.js.gz +0 -0
  74. package/dist/web/client/_app/immutable/chunks/dKdRdI5_.js +2 -0
  75. package/dist/web/client/_app/immutable/chunks/dKdRdI5_.js.br +0 -0
  76. package/dist/web/client/_app/immutable/chunks/dKdRdI5_.js.gz +0 -0
  77. package/dist/web/client/_app/immutable/chunks/z6vZsXi_.js +1 -0
  78. package/dist/web/client/_app/immutable/chunks/z6vZsXi_.js.br +0 -0
  79. package/dist/web/client/_app/immutable/chunks/z6vZsXi_.js.gz +0 -0
  80. package/dist/web/client/_app/immutable/entry/app.CY5BI3xj.js +2 -0
  81. package/dist/web/client/_app/immutable/entry/app.CY5BI3xj.js.br +0 -0
  82. package/dist/web/client/_app/immutable/entry/app.CY5BI3xj.js.gz +0 -0
  83. package/dist/web/client/_app/immutable/entry/start.DtRSN8RT.js +1 -0
  84. package/dist/web/client/_app/immutable/entry/start.DtRSN8RT.js.br +2 -0
  85. package/dist/web/client/_app/immutable/entry/start.DtRSN8RT.js.gz +0 -0
  86. package/dist/web/client/_app/immutable/nodes/0.D-FNblRd.js +1 -0
  87. package/dist/web/client/_app/immutable/nodes/0.D-FNblRd.js.br +0 -0
  88. package/dist/web/client/_app/immutable/nodes/0.D-FNblRd.js.gz +0 -0
  89. package/dist/web/client/_app/immutable/nodes/1.D4Y_4dgV.js +1 -0
  90. package/dist/web/client/_app/immutable/nodes/1.D4Y_4dgV.js.br +0 -0
  91. package/dist/web/client/_app/immutable/nodes/1.D4Y_4dgV.js.gz +0 -0
  92. package/dist/web/client/_app/immutable/nodes/2.B5eVU3OO.js +1 -0
  93. package/dist/web/client/_app/immutable/nodes/2.B5eVU3OO.js.br +0 -0
  94. package/dist/web/client/_app/immutable/nodes/2.B5eVU3OO.js.gz +0 -0
  95. package/dist/web/client/_app/immutable/nodes/3.CLx1_dgI.js +1 -0
  96. package/dist/web/client/_app/immutable/nodes/3.CLx1_dgI.js.br +0 -0
  97. package/dist/web/client/_app/immutable/nodes/3.CLx1_dgI.js.gz +0 -0
  98. package/dist/web/client/_app/immutable/nodes/4.B2lLNz3B.js +61 -0
  99. package/dist/web/client/_app/immutable/nodes/4.B2lLNz3B.js.br +0 -0
  100. package/dist/web/client/_app/immutable/nodes/4.B2lLNz3B.js.gz +0 -0
  101. package/dist/web/client/_app/immutable/nodes/5.DVjHkNQz.js +1 -0
  102. package/dist/web/client/_app/immutable/nodes/5.DVjHkNQz.js.br +0 -0
  103. package/dist/web/client/_app/immutable/nodes/5.DVjHkNQz.js.gz +0 -0
  104. package/dist/web/client/_app/version.json +1 -0
  105. package/dist/web/client/_app/version.json.br +0 -0
  106. package/dist/web/client/_app/version.json.gz +0 -0
  107. package/dist/web/client/robots.txt +3 -0
  108. package/dist/web/env.js +94 -0
  109. package/dist/web/handler.js +1435 -0
  110. package/dist/web/index.js +345 -0
  111. package/dist/web/kyoflow.mjs +21 -0
  112. package/dist/web/scripts/ecosystem.config.cjs +54 -0
  113. package/dist/web/scripts/run-node.mjs +158 -0
  114. package/dist/web/scripts/startDev.mjs +64 -0
  115. package/dist/web/server/chunks/0-CyAFthPc.js +9 -0
  116. package/dist/web/server/chunks/0-CyAFthPc.js.map +1 -0
  117. package/dist/web/server/chunks/1-DYCRQF-y.js +9 -0
  118. package/dist/web/server/chunks/1-DYCRQF-y.js.map +1 -0
  119. package/dist/web/server/chunks/2-BMUiKlN4.js +9 -0
  120. package/dist/web/server/chunks/2-BMUiKlN4.js.map +1 -0
  121. package/dist/web/server/chunks/3-BHJbC3kl.js +9 -0
  122. package/dist/web/server/chunks/3-BHJbC3kl.js.map +1 -0
  123. package/dist/web/server/chunks/4-kguK6pdz.js +9 -0
  124. package/dist/web/server/chunks/4-kguK6pdz.js.map +1 -0
  125. package/dist/web/server/chunks/5-Cg1lR31m.js +9 -0
  126. package/dist/web/server/chunks/5-Cg1lR31m.js.map +1 -0
  127. package/dist/web/server/chunks/_layout.svelte-Dk-_4d6Q.js +15 -0
  128. package/dist/web/server/chunks/_layout.svelte-Dk-_4d6Q.js.map +1 -0
  129. package/dist/web/server/chunks/_page.svelte-Clor3HA3.js +19 -0
  130. package/dist/web/server/chunks/_page.svelte-Clor3HA3.js.map +1 -0
  131. package/dist/web/server/chunks/_page.svelte-D5WvBH3m.js +6 -0
  132. package/dist/web/server/chunks/_page.svelte-D5WvBH3m.js.map +1 -0
  133. package/dist/web/server/chunks/_page.svelte-D7hhqLhW.js +90 -0
  134. package/dist/web/server/chunks/_page.svelte-D7hhqLhW.js.map +1 -0
  135. package/dist/web/server/chunks/_page.svelte-DDxnQ3X4.js +71 -0
  136. package/dist/web/server/chunks/_page.svelte-DDxnQ3X4.js.map +1 -0
  137. package/dist/web/server/chunks/context-CKR25gbz.js +90 -0
  138. package/dist/web/server/chunks/context-CKR25gbz.js.map +1 -0
  139. package/dist/web/server/chunks/error.svelte-BLEcYUzd.js +12 -0
  140. package/dist/web/server/chunks/error.svelte-BLEcYUzd.js.map +1 -0
  141. package/dist/web/server/chunks/exports-k9UzK37u.js +303 -0
  142. package/dist/web/server/chunks/exports-k9UzK37u.js.map +1 -0
  143. package/dist/web/server/chunks/index-DjKos2HY.js +1362 -0
  144. package/dist/web/server/chunks/index-DjKos2HY.js.map +1 -0
  145. package/dist/web/server/chunks/index2-CxBujh0K.js +43 -0
  146. package/dist/web/server/chunks/index2-CxBujh0K.js.map +1 -0
  147. package/dist/web/server/index.js +7832 -0
  148. package/dist/web/server/index.js.map +1 -0
  149. package/dist/web/server/manifest.js +70 -0
  150. package/dist/web/server/manifest.js.map +1 -0
  151. package/dist/web/shims.js +32 -0
  152. package/package.json +37 -0
@@ -0,0 +1,345 @@
1
+ import http from 'node:http';
2
+ import process from 'node:process';
3
+ import { handler } from './handler.js';
4
+ import { env, timeout_env } from './env.js';
5
+ import { setImmediate } from 'node:timers';
6
+ import * as qs from 'node:querystring';
7
+
8
+ /**
9
+ * @param {string|RegExp} input The route pattern
10
+ * @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
11
+ */
12
+ function parse$1(input, loose) {
13
+ if (input instanceof RegExp) return { keys:false, pattern:input };
14
+ var c, o, tmp, ext, keys=[], pattern='', arr = input.split('/');
15
+ arr[0] || arr.shift();
16
+
17
+ while (tmp = arr.shift()) {
18
+ c = tmp[0];
19
+ if (c === '*') {
20
+ keys.push(c);
21
+ pattern += tmp[1] === '?' ? '(?:/(.*))?' : '/(.*)';
22
+ } else if (c === ':') {
23
+ o = tmp.indexOf('?', 1);
24
+ ext = tmp.indexOf('.', 1);
25
+ keys.push( tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length) );
26
+ pattern += !!~o && !~ext ? '(?:/([^/]+?))?' : '/([^/]+?)';
27
+ if (!!~ext) pattern += (!!~o ? '?' : '') + '\\' + tmp.substring(ext);
28
+ } else {
29
+ pattern += '/' + tmp;
30
+ }
31
+ }
32
+
33
+ return {
34
+ keys: keys,
35
+ pattern: new RegExp('^' + pattern + (loose ? '(?=$|\/)' : '\/?$'), 'i')
36
+ };
37
+ }
38
+
39
+ const MAP = {
40
+ "": 0,
41
+ GET: 1,
42
+ HEAD: 2,
43
+ PATCH: 3,
44
+ OPTIONS: 4,
45
+ CONNECT: 5,
46
+ DELETE: 6,
47
+ TRACE: 7,
48
+ POST: 8,
49
+ PUT: 9,
50
+ };
51
+
52
+ class Trouter {
53
+ constructor() {
54
+ this.routes = [];
55
+
56
+ this.all = this.add.bind(this, '');
57
+ this.get = this.add.bind(this, 'GET');
58
+ this.head = this.add.bind(this, 'HEAD');
59
+ this.patch = this.add.bind(this, 'PATCH');
60
+ this.options = this.add.bind(this, 'OPTIONS');
61
+ this.connect = this.add.bind(this, 'CONNECT');
62
+ this.delete = this.add.bind(this, 'DELETE');
63
+ this.trace = this.add.bind(this, 'TRACE');
64
+ this.post = this.add.bind(this, 'POST');
65
+ this.put = this.add.bind(this, 'PUT');
66
+ }
67
+
68
+ use(route, ...fns) {
69
+ let handlers = [].concat.apply([], fns);
70
+ let { keys, pattern } = parse$1(route, true);
71
+ this.routes.push({ keys, pattern, method: '', handlers, midx: MAP[''] });
72
+ return this;
73
+ }
74
+
75
+ add(method, route, ...fns) {
76
+ let { keys, pattern } = parse$1(route);
77
+ let handlers = [].concat.apply([], fns);
78
+ this.routes.push({ keys, pattern, method, handlers, midx: MAP[method] });
79
+ return this;
80
+ }
81
+
82
+ find(method, url) {
83
+ let midx = MAP[method];
84
+ let isHEAD = (midx === 2);
85
+ let i=0, j=0, k, tmp, arr=this.routes;
86
+ let matches=[], params={}, handlers=[];
87
+ for (; i < arr.length; i++) {
88
+ tmp = arr[i];
89
+ if (tmp.midx === midx || tmp.midx === 0 || (isHEAD && tmp.midx===1) ) {
90
+ if (tmp.keys === false) {
91
+ matches = tmp.pattern.exec(url);
92
+ if (matches === null) continue;
93
+ if (matches.groups !== void 0) for (k in matches.groups) params[k]=matches.groups[k];
94
+ tmp.handlers.length > 1 ? (handlers=handlers.concat(tmp.handlers)) : handlers.push(tmp.handlers[0]);
95
+ } else if (tmp.keys.length > 0) {
96
+ matches = tmp.pattern.exec(url);
97
+ if (matches === null) continue;
98
+ for (j=0; j < tmp.keys.length;) params[tmp.keys[j]]=matches[++j];
99
+ tmp.handlers.length > 1 ? (handlers=handlers.concat(tmp.handlers)) : handlers.push(tmp.handlers[0]);
100
+ } else if (tmp.pattern.test(url)) {
101
+ tmp.handlers.length > 1 ? (handlers=handlers.concat(tmp.handlers)) : handlers.push(tmp.handlers[0]);
102
+ }
103
+ } // else not a match
104
+ }
105
+
106
+ return { params, handlers };
107
+ }
108
+ }
109
+
110
+ /**
111
+ * @typedef ParsedURL
112
+ * @type {import('.').ParsedURL}
113
+ */
114
+
115
+ /**
116
+ * @typedef Request
117
+ * @property {string} url
118
+ * @property {ParsedURL} _parsedUrl
119
+ */
120
+
121
+ /**
122
+ * @param {Request} req
123
+ * @returns {ParsedURL|void}
124
+ */
125
+ function parse(req) {
126
+ let raw = req.url;
127
+ if (raw == null) return;
128
+
129
+ let prev = req._parsedUrl;
130
+ if (prev && prev.raw === raw) return prev;
131
+
132
+ let pathname=raw, search='', query;
133
+
134
+ if (raw.length > 1) {
135
+ let idx = raw.indexOf('?', 1);
136
+
137
+ if (idx !== -1) {
138
+ search = raw.substring(idx);
139
+ pathname = raw.substring(0, idx);
140
+ if (search.length > 1) {
141
+ query = qs.parse(search.substring(1));
142
+ }
143
+ }
144
+ }
145
+
146
+ return req._parsedUrl = { pathname, search, query, raw };
147
+ }
148
+
149
+ function onError(err, req, res) {
150
+ let code = typeof err.status === 'number' && err.status;
151
+ code = res.statusCode = (code && code >= 100 ? code : 500);
152
+ if (typeof err === 'string' || Buffer.isBuffer(err)) res.end(err);
153
+ else res.end(err.message || http.STATUS_CODES[code]);
154
+ }
155
+
156
+ const mount = fn => fn instanceof Polka ? fn.attach : fn;
157
+
158
+ class Polka extends Trouter {
159
+ constructor(opts={}) {
160
+ super();
161
+ this.parse = parse;
162
+ this.server = opts.server;
163
+ this.handler = this.handler.bind(this);
164
+ this.onError = opts.onError || onError; // catch-all handler
165
+ this.onNoMatch = opts.onNoMatch || this.onError.bind(null, { status: 404 });
166
+ this.attach = (req, res) => setImmediate(this.handler, req, res);
167
+ }
168
+
169
+ use(base, ...fns) {
170
+ if (base === '/') {
171
+ super.use(base, fns.map(mount));
172
+ } else if (typeof base === 'function' || base instanceof Polka) {
173
+ super.use('/', [base, ...fns].map(mount));
174
+ } else {
175
+ super.use(base,
176
+ (req, _, next) => {
177
+ if (typeof base === 'string') {
178
+ let len = base.length;
179
+ base.startsWith('/') || len++;
180
+ req.url = req.url.substring(len) || '/';
181
+ req.path = req.path.substring(len) || '/';
182
+ } else {
183
+ req.url = req.url.replace(base, '') || '/';
184
+ req.path = req.path.replace(base, '') || '/';
185
+ }
186
+ if (req.url.charAt(0) !== '/') {
187
+ req.url = '/' + req.url;
188
+ }
189
+ next();
190
+ },
191
+ fns.map(mount),
192
+ (req, _, next) => {
193
+ req.path = req._parsedUrl.pathname;
194
+ req.url = req.path + req._parsedUrl.search;
195
+ next();
196
+ }
197
+ );
198
+ }
199
+ return this; // chainable
200
+ }
201
+
202
+ listen() {
203
+ (this.server = this.server || http.createServer()).on('request', this.attach);
204
+ this.server.listen.apply(this.server, arguments);
205
+ return this;
206
+ }
207
+
208
+ handler(req, res, next) {
209
+ let info = this.parse(req), path = info.pathname;
210
+ let obj = this.find(req.method, req.path=path);
211
+
212
+ req.url = path + info.search;
213
+ req.originalUrl = req.originalUrl || req.url;
214
+ req.query = info.query || {};
215
+ req.search = info.search;
216
+ req.params = obj.params;
217
+
218
+ if (path.length > 1 && path.indexOf('%', 1) !== -1) {
219
+ for (let k in req.params) {
220
+ try { req.params[k] = decodeURIComponent(req.params[k]); }
221
+ catch (e) { /* malform uri segment */ }
222
+ }
223
+ }
224
+
225
+ let i=0, arr=obj.handlers.concat(this.onNoMatch), len=arr.length;
226
+ let loop = async () => res.finished || (i < len) && arr[i++](req, res, next);
227
+ (next = next || (err => err ? this.onError(err, req, res, next) : loop().catch(next)))(); // init
228
+ }
229
+ }
230
+
231
+ function polka (opts) {
232
+ return new Polka(opts);
233
+ }
234
+
235
+ const path = env('SOCKET_PATH', false);
236
+ const host = env('HOST', '0.0.0.0');
237
+ const port = env('PORT', !path && '3000');
238
+
239
+ const shutdown_timeout = parseInt(env('SHUTDOWN_TIMEOUT', '30'));
240
+ const idle_timeout = parseInt(env('IDLE_TIMEOUT', '0'));
241
+ const listen_pid = parseInt(env('LISTEN_PID', '0'));
242
+ const listen_fds = parseInt(env('LISTEN_FDS', '0'));
243
+ // https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html
244
+ const SD_LISTEN_FDS_START = 3;
245
+
246
+ if (listen_pid !== 0 && listen_pid !== process.pid) {
247
+ throw new Error(`received LISTEN_PID ${listen_pid} but current process id is ${process.pid}`);
248
+ }
249
+ if (listen_fds > 1) {
250
+ throw new Error(
251
+ `only one socket is allowed for socket activation, but LISTEN_FDS was set to ${listen_fds}`
252
+ );
253
+ }
254
+
255
+ const socket_activation = listen_pid === process.pid && listen_fds === 1;
256
+
257
+ let requests = 0;
258
+ /** @type {NodeJS.Timeout | void} */
259
+ let shutdown_timeout_id;
260
+ /** @type {NodeJS.Timeout | void} */
261
+ let idle_timeout_id;
262
+
263
+ // Initialize the HTTP server here so that we can set properties before starting to listen.
264
+ // Otherwise, polka delays creating the server until listen() is called. Settings these
265
+ // properties after the server has started listening could lead to race conditions.
266
+ const httpServer = http.createServer();
267
+
268
+ const keep_alive_timeout = timeout_env('KEEP_ALIVE_TIMEOUT');
269
+ if (keep_alive_timeout !== undefined) {
270
+ // Convert the keep-alive timeout from seconds to milliseconds (the unit Node.js expects).
271
+ httpServer.keepAliveTimeout = keep_alive_timeout * 1000;
272
+ }
273
+
274
+ const headers_timeout = timeout_env('HEADERS_TIMEOUT');
275
+ if (headers_timeout !== undefined) {
276
+ // Convert the headers timeout from seconds to milliseconds (the unit Node.js expects).
277
+ httpServer.headersTimeout = headers_timeout * 1000;
278
+ }
279
+
280
+ const server = polka({ server: httpServer }).use(handler);
281
+
282
+ if (socket_activation) {
283
+ server.listen({ fd: SD_LISTEN_FDS_START }, () => {
284
+ console.log(`Listening on file descriptor ${SD_LISTEN_FDS_START}`);
285
+ });
286
+ } else {
287
+ server.listen({ path, host, port }, () => {
288
+ console.log(`Listening on ${path || `http://${host}:${port}`}`);
289
+ });
290
+ }
291
+
292
+ /** @param {'SIGINT' | 'SIGTERM' | 'IDLE'} reason */
293
+ function graceful_shutdown(reason) {
294
+ if (shutdown_timeout_id) return;
295
+
296
+ // If a connection was opened with a keep-alive header close() will wait for the connection to
297
+ // time out rather than close it even if it is not handling any requests, so call this first
298
+ httpServer.closeIdleConnections();
299
+
300
+ httpServer.close((error) => {
301
+ // occurs if the server is already closed
302
+ if (error) return;
303
+
304
+ if (shutdown_timeout_id) {
305
+ clearTimeout(shutdown_timeout_id);
306
+ }
307
+ if (idle_timeout_id) {
308
+ clearTimeout(idle_timeout_id);
309
+ }
310
+
311
+ // @ts-expect-error custom events cannot be typed
312
+ process.emit('sveltekit:shutdown', reason);
313
+ });
314
+
315
+ shutdown_timeout_id = setTimeout(() => httpServer.closeAllConnections(), shutdown_timeout * 1000);
316
+ }
317
+
318
+ httpServer.on(
319
+ 'request',
320
+ /** @param {import('node:http').IncomingMessage} req */
321
+ (req) => {
322
+ requests++;
323
+
324
+ if (socket_activation && idle_timeout_id) {
325
+ idle_timeout_id = clearTimeout(idle_timeout_id);
326
+ }
327
+
328
+ req.on('close', () => {
329
+ requests--;
330
+
331
+ if (shutdown_timeout_id) {
332
+ // close connections as soon as they become idle, so they don't accept new requests
333
+ httpServer.closeIdleConnections();
334
+ }
335
+ if (requests === 0 && socket_activation && idle_timeout) {
336
+ idle_timeout_id = setTimeout(() => graceful_shutdown('IDLE'), idle_timeout * 1000);
337
+ }
338
+ });
339
+ }
340
+ );
341
+
342
+ process.on('SIGTERM', graceful_shutdown);
343
+ process.on('SIGINT', graceful_shutdown);
344
+
345
+ export { host, path, port, server };
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+
3
+ // 개발환경에서는 아래 명령어로 실행
4
+ // node ./kyoflow.mjs
5
+
6
+
7
+ import { execSync } from 'child_process';
8
+ import { dirname, resolve } from 'path';
9
+ import { fileURLToPath } from 'url';
10
+
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const ecosystemConfig = resolve(__dirname, 'scripts', 'ecosystem.config.cjs');
13
+
14
+ try {
15
+ execSync(`pm2 start ${ecosystemConfig} --env development --no-daemon`, {
16
+ cwd: __dirname,
17
+ stdio: 'inherit',
18
+ });
19
+ } catch (e) {
20
+ process.exit(e.status ?? 1);
21
+ }
@@ -0,0 +1,54 @@
1
+
2
+ console.log('ecosystem config loaded');
3
+ console.log('Current Directory:', process.cwd());
4
+
5
+
6
+ // pm2 start ./scripts/ecosystem.config.cjs --env production
7
+ // or
8
+ // # --no-daemon 이 모드는 PM2를 “백그라운드 데몬”으로 돌리지 않고,터미널에 그대로 붙여둡니다.
9
+ // pm2 start ./scripts/ecosystem.config.cjs --env development --no-daemon
10
+
11
+ // import path from 'path';
12
+ const cwd = process.cwd();
13
+
14
+ module.exports = {
15
+ apps : [{
16
+ name: 'kyoflow',
17
+ cwd: cwd,
18
+ script: './build/index.js',
19
+ // Watch and Restart app when files change
20
+ // watch: '.', // 개발 환경에서는 watch 사용하지 말 것
21
+ //클러스터로 인스턴스 띄울 개수 지정
22
+ exec_mode: 'cluster', // 운영 시
23
+ // exec_mode: 'fork', // 개발시
24
+ instances: 2, // 개발시
25
+ //특정 인스턴스를 죽여도 자동재시작 되지 않게 함.
26
+ autorestart: false,
27
+ // log 설정
28
+ // out_file: `${cwd}/logs/pm2-out.log`,
29
+ // error_file: `${cwd}/logs/pm2-error.log`,
30
+ // out_file과 error_file을 합친 파일
31
+ log_file: `${cwd}/logs/pm2-kyoflow.log`,
32
+ // 여러 인스턴스가 실행될 때 로그를 하나로 합침
33
+ merge_logs: true,
34
+ log_date_format: 'YYYY-MM-DD HH:mm Z',
35
+ // --env production 또는 --env development 로 실행 가능
36
+ env: {
37
+ SVELTE_ADAPTER_TYPE: 'node',
38
+ SVELTE_APP_BASE_PATH: cwd
39
+ },
40
+ env_production: {
41
+ APP_ENV: 'production',
42
+ HOST: '0.0.0.0',
43
+ PORT: process.env.PORT
44
+ },
45
+ env_development: {
46
+ APP_ENV: 'development',
47
+ HOST: '0.0.0.0',
48
+ PORT: process.env.PORT
49
+ }
50
+ },
51
+
52
+ ],
53
+
54
+ };
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import process from "node:process";
6
+
7
+ const args = process.argv.slice(2);
8
+ const env = { ...process.env };
9
+ const cwd = process.cwd();
10
+ const compiler = "tsdown";
11
+ const compilerArgs = ["exec", compiler, "--no-clean"];
12
+
13
+ const distRoot = path.join(cwd, "dist");
14
+ const distEntry = path.join(distRoot, "/entry.js");
15
+ const buildStampPath = path.join(distRoot, ".buildstamp");
16
+ const srcRoot = path.join(cwd, "src");
17
+ const configFiles = [path.join(cwd, "tsconfig.json"), path.join(cwd, "package.json")];
18
+
19
+ const statMtime = (filePath) => {
20
+ try {
21
+ return fs.statSync(filePath).mtimeMs;
22
+ } catch {
23
+ return null;
24
+ }
25
+ };
26
+
27
+ const isExcludedSource = (filePath) => {
28
+ const relativePath = path.relative(srcRoot, filePath);
29
+ if (relativePath.startsWith("..")) {
30
+ return false;
31
+ }
32
+ return (
33
+ relativePath.endsWith(".test.ts") ||
34
+ relativePath.endsWith(".test.tsx") ||
35
+ relativePath.endsWith(`test-helpers.ts`)
36
+ );
37
+ };
38
+
39
+ const findLatestMtime = (dirPath, shouldSkip) => {
40
+ let latest = null;
41
+ const queue = [dirPath];
42
+ while (queue.length > 0) {
43
+ const current = queue.pop();
44
+ if (!current) {
45
+ continue;
46
+ }
47
+ let entries = [];
48
+ try {
49
+ entries = fs.readdirSync(current, { withFileTypes: true });
50
+ } catch {
51
+ continue;
52
+ }
53
+ for (const entry of entries) {
54
+ const fullPath = path.join(current, entry.name);
55
+ if (entry.isDirectory()) {
56
+ queue.push(fullPath);
57
+ continue;
58
+ }
59
+ if (!entry.isFile()) {
60
+ continue;
61
+ }
62
+ if (shouldSkip?.(fullPath)) {
63
+ continue;
64
+ }
65
+ const mtime = statMtime(fullPath);
66
+ if (mtime == null) {
67
+ continue;
68
+ }
69
+ if (latest == null || mtime > latest) {
70
+ latest = mtime;
71
+ }
72
+ }
73
+ }
74
+ return latest;
75
+ };
76
+
77
+ const shouldBuild = () => {
78
+ if (env.OPENCLAW_FORCE_BUILD === "1") {
79
+ return true;
80
+ }
81
+ const stampMtime = statMtime(buildStampPath);
82
+ if (stampMtime == null) {
83
+ return true;
84
+ }
85
+ if (statMtime(distEntry) == null) {
86
+ return true;
87
+ }
88
+
89
+ for (const filePath of configFiles) {
90
+ const mtime = statMtime(filePath);
91
+ if (mtime != null && mtime > stampMtime) {
92
+ return true;
93
+ }
94
+ }
95
+
96
+ const srcMtime = findLatestMtime(srcRoot, isExcludedSource);
97
+ if (srcMtime != null && srcMtime > stampMtime) {
98
+ return true;
99
+ }
100
+ return false;
101
+ };
102
+
103
+ const logRunner = (message) => {
104
+ if (env.OPENCLAW_RUNNER_LOG === "0") {
105
+ return;
106
+ }
107
+ process.stderr.write(`[openclaw] ${message}\n`);
108
+ };
109
+
110
+ const runNode = () => {
111
+ const nodeProcess = spawn(process.execPath, ["openclaw.mjs", ...args], {
112
+ cwd,
113
+ env,
114
+ stdio: "inherit",
115
+ });
116
+
117
+ nodeProcess.on("exit", (exitCode, exitSignal) => {
118
+ if (exitSignal) {
119
+ process.exit(1);
120
+ }
121
+ process.exit(exitCode ?? 1);
122
+ });
123
+ };
124
+
125
+ const writeBuildStamp = () => {
126
+ try {
127
+ fs.mkdirSync(distRoot, { recursive: true });
128
+ fs.writeFileSync(buildStampPath, `${Date.now()}\n`);
129
+ } catch (error) {
130
+ // Best-effort stamp; still allow the runner to start.
131
+ logRunner(`Failed to write build stamp: ${error?.message ?? "unknown error"}`);
132
+ }
133
+ };
134
+
135
+ if (!shouldBuild()) {
136
+ runNode();
137
+ } else {
138
+ logRunner("Building TypeScript (dist is stale).");
139
+ const buildCmd = process.platform === "win32" ? "cmd.exe" : "pnpm";
140
+ const buildArgs =
141
+ process.platform === "win32" ? ["/d", "/s", "/c", "pnpm", ...compilerArgs] : compilerArgs;
142
+ const build = spawn(buildCmd, buildArgs, {
143
+ cwd,
144
+ env,
145
+ stdio: "inherit",
146
+ });
147
+
148
+ build.on("exit", (code, signal) => {
149
+ if (signal) {
150
+ process.exit(1);
151
+ }
152
+ if (code !== 0 && code !== null) {
153
+ process.exit(code);
154
+ }
155
+ writeBuildStamp();
156
+ runNode();
157
+ });
158
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Vite dev 서버 실행 스크립트
3
+ */
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname, join } from 'path';
6
+ // import.meta.url은 현재 실행 중인 **JavaScript 모듈의 절대 경로(URL)**를 나타내는 읽기 전용 속성입니다.
7
+ // import.meta.url
8
+ console.log('import.meta.url:', import.meta.url);
9
+ // 1. 현재 파일의 URL을 가져옵니다. (ESM 방식)
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ // 2. 현재 파일이 있는 디렉터리 경로를 가져옵니다.
12
+ const __dirname = dirname(__filename);
13
+ // 3. 현재 파일을 기준으로 프로젝트 루트를 찾습니다.
14
+ // (빌드 구조에 따라 '..'의 개수가 달라질 수 있습니다.)
15
+ const svelteAppBasePath = join(__dirname, '..');
16
+ console.log('프로젝트 루트:', svelteAppBasePath);
17
+
18
+ // Vite dev 서버 실행
19
+ import { spawn } from 'child_process';
20
+
21
+ // 커맨드 라인 인자에서 mode 파라미터 추출 (예: --mode development)
22
+ const args = process.argv.slice(2);
23
+ const modeIndex = args.indexOf('--mode');
24
+ const mode = modeIndex !== -1 && args[modeIndex + 1] ? args[modeIndex + 1] : 'development';
25
+
26
+ console.log(`Vite dev 서버를 시작합니다 (mode: ${mode})...`);
27
+ // 환경 변수 설정
28
+ // 윈도우인지 리눅스인지 확인
29
+ const isWindows = process.platform === 'win32';
30
+ const isLinux = process.platform === 'linux';
31
+
32
+ if (isWindows) {
33
+ console.log('운영 체제: Windows');
34
+ } else if (isLinux) {
35
+ console.log('운영 체제: Linux');
36
+ } else {
37
+ console.log('운영 체제: 알 수 없음');
38
+ }
39
+
40
+ // shell:true이면 spawn('npm run dev')와 같이 해야 보안 이슈가 없음
41
+ // 아래와 같이 실행하면 보안 경고가 발생. deprecated 됨
42
+ // Vite dev 명령 실행
43
+ const viteProcess = spawn('npm', ['run', `dev:${mode}`], {
44
+ cwd: svelteAppBasePath, // 현재 작업 디렉터리 지정
45
+ stdio: 'inherit', // 부모 프로세스의 입출력을 그대로 사용
46
+ shell: true, // shell을 통해 실행 (예: 'npm run build' 같은 명령어 가능)
47
+ detached: false, // true이면 부모 종료 후에도 자식 프로세스 유지
48
+ env: { // 환경변수 전달
49
+ ...process.env, // 기존 환경변수 유지
50
+ APP_BASE_PATH: svelteAppBasePath, // buildRoot를 환경변수로 설정
51
+ APP_ENV: mode, // mode도 환경변수로 설정
52
+ SVELTE_ADAPTER_TYPE: 'node' // 예시: 추가 커스텀 환경변수
53
+ }
54
+ });
55
+
56
+ viteProcess.on('error', (error) => {
57
+ console.error('Vite dev 서버 시작 중 오류 발생:', error);
58
+ process.exit(1);
59
+ });
60
+
61
+ viteProcess.on('exit', (code) => {
62
+ console.log(`Vite dev 서버가 종료되었습니다 (코드: ${code})`);
63
+ process.exit(code);
64
+ });
@@ -0,0 +1,9 @@
1
+ const index = 0;
2
+ let component_cache;
3
+ const component = async () => component_cache ??= (await import('./_layout.svelte-Dk-_4d6Q.js')).default;
4
+ const imports = ["_app/immutable/nodes/0.D-FNblRd.js","_app/immutable/chunks/D8fmz15L.js","_app/immutable/chunks/DtmuEK64.js","_app/immutable/chunks/Da9oKyxb.js","_app/immutable/chunks/BJ-VzAMM.js","_app/immutable/chunks/C63Z97y6.js"];
5
+ const stylesheets = ["_app/immutable/assets/0.BrmKgNLm.css"];
6
+ const fonts = [];
7
+
8
+ export { component, fonts, imports, index, stylesheets };
9
+ //# sourceMappingURL=0-CyAFthPc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0-CyAFthPc.js","sources":["../../../.svelte-kit/adapter-node/nodes/0.js"],"sourcesContent":["\n\nexport const index = 0;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/pages/_layout.svelte.js')).default;\nexport const imports = [\"_app/immutable/nodes/0.D-FNblRd.js\",\"_app/immutable/chunks/D8fmz15L.js\",\"_app/immutable/chunks/DtmuEK64.js\",\"_app/immutable/chunks/Da9oKyxb.js\",\"_app/immutable/chunks/BJ-VzAMM.js\",\"_app/immutable/chunks/C63Z97y6.js\"];\nexport const stylesheets = [\"_app/immutable/assets/0.BrmKgNLm.css\"];\nexport const fonts = [];\n"],"names":[],"mappings":"AAEY,MAAC,KAAK,GAAG;AACrB,IAAI,eAAe;AACP,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,8BAAoC,CAAC,EAAE;AAClG,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC;AACpO,MAAC,WAAW,GAAG,CAAC,sCAAsC;AACtD,MAAC,KAAK,GAAG;;;;"}
@@ -0,0 +1,9 @@
1
+ const index = 1;
2
+ let component_cache;
3
+ const component = async () => component_cache ??= (await import('./error.svelte-BLEcYUzd.js')).default;
4
+ const imports = ["_app/immutable/nodes/1.D4Y_4dgV.js","_app/immutable/chunks/D8fmz15L.js","_app/immutable/chunks/DtmuEK64.js","_app/immutable/chunks/B_AmmRQN.js","_app/immutable/chunks/ZW9ZwxRj.js","_app/immutable/chunks/44EpIQ4d.js","_app/immutable/chunks/z6vZsXi_.js","_app/immutable/chunks/B09fC2bi.js","_app/immutable/chunks/DDNuMsfB.js"];
5
+ const stylesheets = [];
6
+ const fonts = [];
7
+
8
+ export { component, fonts, imports, index, stylesheets };
9
+ //# sourceMappingURL=1-DYCRQF-y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1-DYCRQF-y.js","sources":["../../../.svelte-kit/adapter-node/nodes/1.js"],"sourcesContent":["\n\nexport const index = 1;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/fallbacks/error.svelte.js')).default;\nexport const imports = [\"_app/immutable/nodes/1.D4Y_4dgV.js\",\"_app/immutable/chunks/D8fmz15L.js\",\"_app/immutable/chunks/DtmuEK64.js\",\"_app/immutable/chunks/B_AmmRQN.js\",\"_app/immutable/chunks/ZW9ZwxRj.js\",\"_app/immutable/chunks/44EpIQ4d.js\",\"_app/immutable/chunks/z6vZsXi_.js\",\"_app/immutable/chunks/B09fC2bi.js\",\"_app/immutable/chunks/DDNuMsfB.js\"];\nexport const stylesheets = [];\nexport const fonts = [];\n"],"names":[],"mappings":"AAEY,MAAC,KAAK,GAAG;AACrB,IAAI,eAAe;AACP,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,4BAAsC,CAAC,EAAE;AACpG,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC;AAChV,MAAC,WAAW,GAAG;AACf,MAAC,KAAK,GAAG;;;;"}
@@ -0,0 +1,9 @@
1
+ const index = 2;
2
+ let component_cache;
3
+ const component = async () => component_cache ??= (await import('./_page.svelte-D5WvBH3m.js')).default;
4
+ const imports = ["_app/immutable/nodes/2.B5eVU3OO.js","_app/immutable/chunks/D8fmz15L.js","_app/immutable/chunks/DtmuEK64.js","_app/immutable/chunks/B_AmmRQN.js"];
5
+ const stylesheets = [];
6
+ const fonts = [];
7
+
8
+ export { component, fonts, imports, index, stylesheets };
9
+ //# sourceMappingURL=2-BMUiKlN4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2-BMUiKlN4.js","sources":["../../../.svelte-kit/adapter-node/nodes/2.js"],"sourcesContent":["\n\nexport const index = 2;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/pages/_page.svelte.js')).default;\nexport const imports = [\"_app/immutable/nodes/2.B5eVU3OO.js\",\"_app/immutable/chunks/D8fmz15L.js\",\"_app/immutable/chunks/DtmuEK64.js\",\"_app/immutable/chunks/B_AmmRQN.js\"];\nexport const stylesheets = [];\nexport const fonts = [];\n"],"names":[],"mappings":"AAEY,MAAC,KAAK,GAAG;AACrB,IAAI,eAAe;AACP,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,4BAAkC,CAAC,EAAE;AAChG,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC;AAC5J,MAAC,WAAW,GAAG;AACf,MAAC,KAAK,GAAG;;;;"}