@r_masseater/masseater-utils 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index-CeVmiNfF.d.mts +41 -0
- package/dist/node-main.d.mts +3 -17
- package/dist/node-main.mjs +2 -42
- package/dist/node-main.mjs.map +1 -1
- package/dist/plugin-kit.d.mts +9 -9636
- package/dist/plugin-kit.mjs +45 -29396
- package/dist/plugin-kit.mjs.map +1 -1
- package/dist/run-main-BD4uT8sr.mjs +45 -0
- package/dist/run-main-BD4uT8sr.mjs.map +1 -0
- package/package.json +1 -1
- package/skills/read-hook-input/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -22,12 +22,12 @@ vp add @r_masseater/masseater-utils
|
|
|
22
22
|
|
|
23
23
|
## Install what a subpath needs
|
|
24
24
|
|
|
25
|
-
Install the peer dependencies of the subpath you import, and nothing else. A subpath that needs no extra package
|
|
25
|
+
Install the peer dependencies of the subpath you import, and nothing else. A subpath that needs no extra package installs this package alone.
|
|
26
26
|
|
|
27
27
|
| Subpath | Install besides this package |
|
|
28
28
|
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
29
|
| `skerm` | `react` |
|
|
30
|
-
| `plugin-kit` |
|
|
30
|
+
| `plugin-kit` | `effect` and `@effect/platform-node` |
|
|
31
31
|
| `model-server` | Nothing. The server installs its inference runtime into the user's cache folder with `npm` on the first call. |
|
|
32
32
|
| `node-main` | `effect` and `@effect/platform-node` |
|
|
33
33
|
| `github-workflow` | `effect` |
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Effect, Layer, Runtime, Schema, Stdio } from "effect";
|
|
2
|
+
import { NodeServices } from "@effect/platform-node/NodeServices";
|
|
3
|
+
import { HttpClient } from "effect/http";
|
|
4
|
+
/** @internal */
|
|
5
|
+
type Platform = NodeServices | HttpClient.HttpClient;
|
|
6
|
+
/** @internal */
|
|
7
|
+
type Run<Provided> = <Success, Failure>(program: Effect.Effect<Success, Failure, Platform | Provided>) => void;
|
|
8
|
+
declare const runWithTracingAnd: <Provided, LayerFailure>({ serviceName, services }: Readonly<{
|
|
9
|
+
serviceName: string;
|
|
10
|
+
services: Layer.Layer<Provided, LayerFailure, Platform>;
|
|
11
|
+
}>) => Run<Provided>;
|
|
12
|
+
declare const runWithTracing: (serviceName: string) => Run<never>;
|
|
13
|
+
/** @internal */
|
|
14
|
+
declare const runMainWith: typeof runWithTracingAnd;
|
|
15
|
+
/** @internal */
|
|
16
|
+
declare const runMain: typeof runWithTracing;
|
|
17
|
+
declare const HookBlocked_base: Schema.Class<HookBlocked, Schema.TaggedStruct<"HookBlocked", {
|
|
18
|
+
readonly reason: Schema.String;
|
|
19
|
+
}>, import("effect/Cause").YieldableError & {
|
|
20
|
+
readonly brand: unique symbol;
|
|
21
|
+
}>;
|
|
22
|
+
/** @internal */
|
|
23
|
+
declare class HookBlocked extends HookBlocked_base {
|
|
24
|
+
readonly [Runtime.errorExitCode] = 2;
|
|
25
|
+
readonly [Runtime.errorReported] = false;
|
|
26
|
+
}
|
|
27
|
+
/** @internal */
|
|
28
|
+
declare const blockHook: (reason: string) => Effect.Effect<never, HookBlocked>;
|
|
29
|
+
/** @internal */
|
|
30
|
+
declare const readHookInput: <Codec extends Schema.Top>(schema: Codec) => Effect.Effect<Codec["Type"], Schema.SchemaError, Stdio.Stdio | Codec["DecodingServices"]>;
|
|
31
|
+
/** @internal */
|
|
32
|
+
declare const writeHookOutput: <Codec extends Schema.Top>(schema: Codec) => (value: Codec["Type"]) => Effect.Effect<void, never, Stdio.Stdio | Codec["EncodingServices"]>;
|
|
33
|
+
/** @internal */
|
|
34
|
+
declare const runHookWith: <Provided, LayerFailure>({ serviceName, services }: Readonly<{
|
|
35
|
+
serviceName: string;
|
|
36
|
+
services: Layer.Layer<Provided, LayerFailure, Platform>;
|
|
37
|
+
}>) => Run<Provided>;
|
|
38
|
+
/** @internal */
|
|
39
|
+
declare const runHook: (serviceName: string) => Run<never>;
|
|
40
|
+
export { readHookInput as a, runMainWith as c, blockHook as i, runHookWith as n, writeHookOutput as o, HookBlocked as r, runMain as s, runHook as t };
|
|
41
|
+
//# sourceMappingURL=index-CeVmiNfF.d.mts.map
|
package/dist/node-main.d.mts
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { HttpClient } from "effect/http";
|
|
1
|
+
import { c as runMainWith, s as runMain } from "./index-CeVmiNfF.mjs";
|
|
2
|
+
import { Effect, Option } from "effect";
|
|
4
3
|
export declare const whileParentAlive: (parentPid: Option.Option<string>) => <Value, Failure, Requirements>(program: Effect.Effect<Value, Failure, Requirements>) => Effect.Effect<void, Failure, Requirements>;
|
|
5
|
-
|
|
6
|
-
type Platform = NodeServices | HttpClient.HttpClient;
|
|
7
|
-
/** @internal */
|
|
8
|
-
type Run<Provided> = <Success, Failure>(program: Effect.Effect<Success, Failure, Platform | Provided>) => void;
|
|
9
|
-
declare const runWithTracingAnd: <Provided, LayerFailure>({ serviceName, services }: Readonly<{
|
|
10
|
-
serviceName: string;
|
|
11
|
-
services: Layer.Layer<Provided, LayerFailure, Platform>;
|
|
12
|
-
}>) => Run<Provided>;
|
|
13
|
-
declare const runWithTracing: (serviceName: string) => Run<never>;
|
|
14
|
-
/** @internal */
|
|
15
|
-
export declare const runMainWith: typeof runWithTracingAnd;
|
|
16
|
-
/** @internal */
|
|
17
|
-
export declare const runMain: typeof runWithTracing;
|
|
18
|
-
export {};
|
|
4
|
+
export { runMain, runMainWith };
|
|
19
5
|
//# sourceMappingURL=node-main.d.mts.map
|
package/dist/node-main.mjs
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import { runMain as runMain$1 } from "@effect/platform-node/NodeRuntime";
|
|
4
|
-
import { layer } from "@effect/platform-node/NodeServices";
|
|
5
|
-
import { FetchHttpClient } from "effect/http";
|
|
6
|
-
import { Otlp, OtlpSerialization } from "effect/observability";
|
|
1
|
+
import { n as runMainWith, t as runMain } from "./run-main-BD4uT8sr.mjs";
|
|
2
|
+
import { Duration, Effect, Option, Schedule, pipe } from "effect";
|
|
7
3
|
// src/features/watch-parent/model/parent-process.ts
|
|
8
4
|
const PARENT_CHECK_INTERVAL = Duration.fromInputUnsafe("2 seconds");
|
|
9
5
|
const SIGNAL_PROBE = 0;
|
|
@@ -19,42 +15,6 @@ const untilExits = (pid) => Effect.sync(() => isAlive(pid)).pipe(Effect.repeat({
|
|
|
19
15
|
while: (alive) => alive
|
|
20
16
|
}), Effect.asVoid);
|
|
21
17
|
const whileParentAlive = (parentPid) => (program) => Effect.raceFirst(Effect.asVoid(program), pipe(parentPid, Option.map((pid) => untilExits(globalThis.Number(pid))), Option.getOrElse(() => Effect.never)));
|
|
22
|
-
// src/features/run-main/model/report.ts
|
|
23
|
-
const TAG = "_tag";
|
|
24
|
-
const fieldsOf = (failure) => pipe(Option.liftPredicate(failure, Predicate.isObject), Option.map((object) => Record.toEntries({ ...object })), Option.getOrElse(() => []), Array.flatMap(([key, value]) => pipe(Option.liftPredicate(value, Predicate.isString), Option.filter(() => key !== TAG), Option.map((text) => `${key}: ${text}`), Option.toArray)), Array.join(", "));
|
|
25
|
-
const describedOf = (reason, name) => pipe(Option.liftPredicate(reason, Cause.isFailReason), Option.map((failed) => fieldsOf(failed.error)), Option.filter(String.isNonEmpty), Option.match({
|
|
26
|
-
onNone: () => name,
|
|
27
|
-
onSome: (fields) => `${name} (${fields})`
|
|
28
|
-
}));
|
|
29
|
-
const linesOf = (serviceName) => (reason) => pipe(Cause.prettyErrors(Cause.fromReasons([reason])), Array.map((error) => {
|
|
30
|
-
if (String.isEmpty(error.message)) return `${serviceName}: ${describedOf(reason, error.name)}`;
|
|
31
|
-
if (Cause.isDieReason(reason)) return `${serviceName}: ${error.name}: ${error.message}`;
|
|
32
|
-
return `${serviceName}: ${error.message}`;
|
|
33
|
-
}));
|
|
34
|
-
/** @internal */
|
|
35
|
-
const reportOf = (serviceName) => (cause) => {
|
|
36
|
-
if (Cause.hasInterruptsOnly(cause) || !cause.pipe(Cause.squash, Runtime.getErrorReported)) return [];
|
|
37
|
-
return pipe(cause.reasons, Array.filter((reason) => !Cause.isInterruptReason(reason)), Array.flatMap(linesOf(serviceName)));
|
|
38
|
-
};
|
|
39
|
-
// src/features/run-main/model/run-main.ts
|
|
40
|
-
const platform = Layer.mergeAll(layer, FetchHttpClient.layer);
|
|
41
|
-
const runWithTracingAnd = ({ serviceName, services }) => (program) => {
|
|
42
|
-
const tracing = Otlp.layerFromConfig({ resource: { serviceName } }).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));
|
|
43
|
-
const provided = Layer.provideMerge(services, platform);
|
|
44
|
-
const report = reportOf(serviceName);
|
|
45
|
-
runMain$1(Layer.mergeAll(tracing, provided).pipe(Layer.build, Effect.flatMap((context) => Effect.provideContext(program, context)), Effect.scoped, Effect.ensuring(flushUsage), Effect.tapCause((cause) => Effect.forEach(report(cause), (line) => Console.error(line), {
|
|
46
|
-
concurrency: 1,
|
|
47
|
-
discard: true
|
|
48
|
-
}))), { disableErrorReporting: true });
|
|
49
|
-
};
|
|
50
|
-
const runWithTracing = (serviceName) => runWithTracingAnd({
|
|
51
|
-
serviceName,
|
|
52
|
-
services: Layer.empty
|
|
53
|
-
});
|
|
54
|
-
/** @internal */
|
|
55
|
-
const runMainWith = runWithTracingAnd;
|
|
56
|
-
/** @internal */
|
|
57
|
-
const runMain = runWithTracing;
|
|
58
18
|
export { runMain, runMainWith, whileParentAlive };
|
|
59
19
|
|
|
60
20
|
//# sourceMappingURL=node-main.mjs.map
|
package/dist/node-main.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-main.mjs","names":[
|
|
1
|
+
{"version":3,"file":"node-main.mjs","names":[],"sources":["../src/features/watch-parent/model/parent-process.ts"],"sourcesContent":["import { Duration, Effect, Option, Schedule, pipe } from \"effect\";\n\nconst PARENT_CHECK_INTERVAL = Duration.fromInputUnsafe(\"2 seconds\");\nconst SIGNAL_PROBE = 0;\n\nconst isAlive = (pid: number): boolean => {\n try {\n return globalThis.process.kill(pid, SIGNAL_PROBE);\n } catch {\n return false;\n }\n};\n\nconst untilExits = (pid: number): Effect.Effect<void> =>\n Effect.sync(() => isAlive(pid)).pipe(\n Effect.repeat({ schedule: Schedule.spaced(PARENT_CHECK_INTERVAL), while: (alive) => alive }),\n Effect.asVoid,\n );\n\nexport const whileParentAlive =\n (parentPid: Option.Option<string>) =>\n <Value, Failure, Requirements>(\n program: Effect.Effect<Value, Failure, Requirements>,\n ): Effect.Effect<void, Failure, Requirements> =>\n Effect.raceFirst(\n Effect.asVoid(program),\n pipe(\n parentPid,\n Option.map((pid) => untilExits(globalThis.Number(pid))),\n Option.getOrElse(() => Effect.never),\n ),\n );\n"],"mappings":";;;AAEA,MAAM,wBAAwB,SAAS,gBAAgB,WAAW;AAClE,MAAM,eAAe;AAErB,MAAM,WAAW,QAAyB;CACxC,IAAI;EACF,OAAO,WAAW,QAAQ,KAAK,KAAK,YAAY;CAClD,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAM,cAAc,QAClB,OAAO,WAAW,QAAQ,GAAG,CAAC,CAAC,CAAC,KAC9B,OAAO,OAAO;CAAE,UAAU,SAAS,OAAO,qBAAqB;CAAG,QAAQ,UAAU;AAAM,CAAC,GAC3F,OAAO,MACT;AAEF,MAAa,oBACV,eAEC,YAEA,OAAO,UACL,OAAO,OAAO,OAAO,GACrB,KACE,WACA,OAAO,KAAK,QAAQ,WAAW,WAAW,OAAO,GAAG,CAAC,CAAC,GACtD,OAAO,gBAAgB,OAAO,KAAK,CACrC,CACF"}
|