@fungi.computer/corral 0.0.1 → 0.1.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 +7 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -6
- package/docs/api/README.md +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ import { attachCorral } from "@fungi.computer/corral";
|
|
|
34
34
|
|
|
35
35
|
const scope = await Effect.runPromise(Scope.make());
|
|
36
36
|
await Effect.runPromise(
|
|
37
|
-
attachCorral(Stream.fromIterable(["idle", "working"]), {
|
|
37
|
+
attachCorral(Stream.fromIterable([{ state: "idle" }, { state: "working" }]), {
|
|
38
38
|
environment: {
|
|
39
39
|
HERDR_ENV: "1",
|
|
40
40
|
HERDR_SOCKET_PATH: "/path/to/herdr.sock",
|
|
@@ -60,10 +60,11 @@ default entry borrows an AsyncIterable with an independent sliding latest-value
|
|
|
60
60
|
subscription per iterator and a detach signal. `attachCorral` accepts an Effect
|
|
61
61
|
stream, including a stream with typed `Error` failures. Source and socket errors
|
|
62
62
|
reach `onError`; closing the scope still releases the pane report. Fungi borrows
|
|
63
|
-
its existing Session observation and command interaction store.
|
|
64
|
-
question or browser hand-off reports `blocked`.
|
|
65
|
-
current activity.
|
|
66
|
-
|
|
63
|
+
its existing Session observation and command interaction store. An open agent
|
|
64
|
+
question, a pending command question or a browser hand-off reports `blocked`.
|
|
65
|
+
Answering it restores the current activity. An agent question may add its short
|
|
66
|
+
header to the blocked message; question bodies, answer choices, answers and
|
|
67
|
+
credentials are never included in reports.
|
|
67
68
|
|
|
68
69
|
Herdr derives `done` when an unseen background turn returns to `idle`. It owns
|
|
69
70
|
whether the user has seen that completion. Corral never guesses completion from
|
|
@@ -72,7 +73,7 @@ an unavailable observation.
|
|
|
72
73
|
`attachCorral` needs an Effect scope. When that scope closes, Corral cancels its
|
|
73
74
|
reporter, closes any in-flight socket, and releases the current pane report. It
|
|
74
75
|
sends `pane.report_agent` and `pane.release_agent` over Herdr's API socket with
|
|
75
|
-
the `fungi:
|
|
76
|
+
the `fungi:agent:v1` source and `fungi` agent label. A monotone timestamp
|
|
76
77
|
sequence orders reports across attachments and process restarts.
|
|
77
78
|
|
|
78
79
|
## API reference
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function attachCorral(activity: Stream.Stream<CorralActivity, Err
|
|
|
22
22
|
declare const extension: Readonly<{
|
|
23
23
|
protocol: "shiitake.client/v1";
|
|
24
24
|
id: ExtensionId;
|
|
25
|
-
|
|
25
|
+
promptPresentation?: "footer";
|
|
26
26
|
attach?: (context: import("@fungi.computer/shiitake/client-entry").ClientExtensionContextV1) => Effect.Effect<void, Error, Scope.Scope>;
|
|
27
27
|
contribute?: (slot: import("@fungi.computer/shiitake/extensions").ExtensionSlotV0 | undefined) => import("@fungi.computer/shiitake/client-entry").ClientContributionV1;
|
|
28
28
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ExtensionId, } from "@fungi.computer/shiitake/extensions";
|
|
|
7
7
|
import * as Stream from "effect/Stream";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
|
-
const source = "fungi:
|
|
10
|
+
const source = "fungi:agent:v1";
|
|
11
11
|
let reportSequence = Date.now() * 1000;
|
|
12
12
|
const decodeResponse = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Union([
|
|
13
13
|
Schema.Struct({ id: Schema.String, result: Schema.Unknown }),
|
|
@@ -20,19 +20,23 @@ function nextSequence() {
|
|
|
20
20
|
reportSequence = Math.max(reportSequence + 1, Date.now() * 1000);
|
|
21
21
|
return reportSequence;
|
|
22
22
|
}
|
|
23
|
-
function request(endpoint, pane,
|
|
23
|
+
function request(endpoint, pane, activity) {
|
|
24
|
+
const state = activity?.state;
|
|
24
25
|
const seq = nextSequence();
|
|
25
26
|
const id = `${source}:${String(seq)}`;
|
|
26
27
|
const params = {
|
|
27
28
|
pane_id: pane,
|
|
28
29
|
source,
|
|
29
|
-
agent: "
|
|
30
|
+
agent: "fungi",
|
|
30
31
|
seq,
|
|
31
32
|
};
|
|
32
33
|
if (state !== undefined)
|
|
33
34
|
params.state = state;
|
|
34
35
|
if (state === "blocked")
|
|
35
|
-
params.message =
|
|
36
|
+
params.message =
|
|
37
|
+
activity?.header === undefined
|
|
38
|
+
? "Waiting for your response"
|
|
39
|
+
: `Waiting for your response: ${activity.header}`;
|
|
36
40
|
const body = {
|
|
37
41
|
id,
|
|
38
42
|
method: state === undefined ? "pane.release_agent" : "pane.report_agent",
|
|
@@ -74,12 +78,12 @@ export function attachCorral(activity, options) {
|
|
|
74
78
|
const endpoint = process.platform === "win32"
|
|
75
79
|
? `\\\\.\\pipe\\${HERDR_SOCKET_PATH}`
|
|
76
80
|
: HERDR_SOCKET_PATH;
|
|
77
|
-
const send = (
|
|
81
|
+
const send = (activity) => request(endpoint, HERDR_PANE_ID, activity).pipe(Effect.catch((cause) => Effect.sync(() => {
|
|
78
82
|
options.onError(cause);
|
|
79
83
|
})));
|
|
80
84
|
return Effect.gen(function* () {
|
|
81
85
|
yield* Effect.acquireRelease(Effect.void, () => send(undefined));
|
|
82
|
-
yield* activity.pipe(Stream.
|
|
86
|
+
yield* activity.pipe(Stream.changesWith((a, b) => a.state === b.state && a.header === b.header), Stream.runForEach(send), Effect.catch((cause) => Effect.sync(() => {
|
|
83
87
|
options.onError(cause);
|
|
84
88
|
})), Effect.forkScoped);
|
|
85
89
|
});
|
package/docs/api/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Activity supplied by the client; blocked means a human response is pending.
|
|
|
38
38
|
const default: Readonly<{
|
|
39
39
|
protocol: "shiitake.client/v1";
|
|
40
40
|
id: string & Brand<"ExtensionId">;
|
|
41
|
-
|
|
41
|
+
promptPresentation?: "footer";
|
|
42
42
|
attach?: (context) => Effect<void, Error, Scope>;
|
|
43
43
|
contribute?: (slot) => object;
|
|
44
44
|
}>;
|
|
@@ -60,7 +60,7 @@ Attach to borrowed activity; never opens a Session watch or starts Herdr.
|
|
|
60
60
|
|
|
61
61
|
| Parameter | Type |
|
|
62
62
|
| ---------- | ------------------------------------------------------------------------------------------------------------- |
|
|
63
|
-
| `activity` | `Stream`\<`
|
|
63
|
+
| `activity` | `Stream`\<`Readonly`\<\{ `state`: `ClientActivityStateV0`; `header?`: `string`; \}\>, `Error`\> |
|
|
64
64
|
| `options` | `Readonly`\<\{ `environment`: [`CorralEnvironment`](#corralenvironment); `onError`: (`cause`) => `void`; \}\> |
|
|
65
65
|
|
|
66
66
|
#### Returns
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/corral",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Optional Herdr activity reporting for Shiitake clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"effect": "4.0.2",
|
|
21
|
-
"@fungi.computer/shiitake": "0.
|
|
21
|
+
"@fungi.computer/shiitake": "0.3.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "24.13.3",
|