@maiaos/cli 0.1.0-canary.69 → 0.1.0-canary.70
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.
|
@@ -25,6 +25,7 @@ export declare const connectLocalNode: CliNodeConnector;
|
|
|
25
25
|
export declare const holdsSessionCredential: Effect.Effect<boolean>;
|
|
26
26
|
export declare const discoveryUnavailable: (failure: NodeDiscoveryFailure, profile: string | undefined) => ProtocolError;
|
|
27
27
|
export declare const discoveryError: (error: unknown) => ProtocolError | undefined;
|
|
28
|
+
export declare const nodeAnswerOf: (error: unknown) => ProtocolError | undefined;
|
|
28
29
|
export declare const operationError: (error: unknown) => ProtocolError;
|
|
29
30
|
export declare const outcomeCanBeAmbiguous: (error: unknown) => boolean;
|
|
30
31
|
export declare const invalidNodeInput: <TValue>(schemaError?: unknown) => Effect.Effect<CliNodeResult<TValue>>;
|
|
@@ -88,12 +88,15 @@ const SESSION_CREDENTIAL_VARIABLE = "MAIA_SESSION_CREDENTIAL", SESSION_NODE_ORIG
|
|
|
88
88
|
return LOCAL_OUTCOME_UNKNOWN_ERROR;
|
|
89
89
|
if (code === "saturated")
|
|
90
90
|
return LOCAL_SATURATED_ERROR;
|
|
91
|
+
}, nodeAnswerOf = (error) => {
|
|
92
|
+
const remoteError = error instanceof Error && "remoteError" in error ? error.remoteError : void 0, parsed = protocolErrorSchema.safeParse(remoteError);
|
|
93
|
+
return parsed.success ? parsed.data : void 0;
|
|
91
94
|
}, operationError = (error) => {
|
|
92
95
|
if (error instanceof CliLocalNodeError)
|
|
93
96
|
return error.error;
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
return
|
|
97
|
+
const answer = nodeAnswerOf(error);
|
|
98
|
+
if (answer !== void 0)
|
|
99
|
+
return answer;
|
|
97
100
|
const clientErrorCode = maiaClientErrorCode(error);
|
|
98
101
|
if (clientErrorCode === "invalid_request")
|
|
99
102
|
return {
|
|
@@ -138,8 +141,8 @@ const SESSION_CREDENTIAL_VARIABLE = "MAIA_SESSION_CREDENTIAL", SESSION_NODE_ORIG
|
|
|
138
141
|
ok: !1,
|
|
139
142
|
...recovery !== void 0 && outcomeCanBeAmbiguous(error) ? { recovery } : {}
|
|
140
143
|
}), completeOperation = (program, recovery) => program.pipe(Effect.map((value) => ({ ok: !0, value })), Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.interrupt : Effect.succeed(failedOperation(Cause.squash(cause), recovery)))), discoveryOptionsOf = (source) => source === void 0 ? cliDiscoveryOptions : Effect.isEffect(source) ? source : Effect.succeed(source), isBriefSaturation = (error) => {
|
|
141
|
-
const
|
|
142
|
-
return
|
|
144
|
+
const answer = nodeAnswerOf(error);
|
|
145
|
+
return answer !== void 0 ? answer.code === "saturated" && answer.saturation === "admission" : maiaClientErrorCode(error) === "saturated";
|
|
143
146
|
}, SATURATION_RETRY = Schedule.exponential("100 millis").pipe(Schedule.jittered), SATURATION_RETRIES = 4, DEADLINE_MARGIN_NANOS = 500000000n, endingBefore = (deadlineAt) => Schedule.fromStep(Effect.map(Schedule.toStep(SATURATION_RETRY), (step) => (now, input) => Effect.flatMap(step(now, input), ([output, backoff]) => Effect.flatMap(Clock.monotonicTimeNanos, (current) => current + Duration.toNanosUnsafe(backoff) + DEADLINE_MARGIN_NANOS >= deadlineAt ? Cause.done(output) : Effect.succeed([output, backoff]))))), retryBriefSaturation = (attempt, deadlineAt) => Effect.retry(attempt, {
|
|
144
147
|
schedule: deadlineAt === void 0 ? SATURATION_RETRY : endingBefore(deadlineAt),
|
|
145
148
|
times: SATURATION_RETRIES,
|
|
@@ -195,6 +198,7 @@ export {
|
|
|
195
198
|
isBriefSaturation,
|
|
196
199
|
makeCliNodeOperations,
|
|
197
200
|
newCliIdentifier,
|
|
201
|
+
nodeAnswerOf,
|
|
198
202
|
operationError,
|
|
199
203
|
outcomeCanBeAmbiguous,
|
|
200
204
|
retryBriefSaturation,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { type CliNodeCall, makeCallClient } from "./call.js";
|
|
2
|
-
export { changeAtRevision, type CliMutationRecovery, type CliNodeBinding, type CliNodeConnection, type CliNodeConnector, type CliNodeEffect, type CliNodeOperations, type CliNodeOperationsOptions, type CliNodeResult, commandIdentifier, connectLocalNode, discoveryError, discoveryOptionsFor, fillCommandIdentifier, holdsSessionCredential, invalidNodeInput, makeCliNodeOperations, newCliIdentifier, operationError, outcomeCanBeAmbiguous, type ParameterSchema, retryBriefSaturation, revisionOrCurrent, runLazyNodeDependency, } from "./client.js";
|
|
2
|
+
export { changeAtRevision, type CliMutationRecovery, type CliNodeBinding, type CliNodeConnection, type CliNodeConnector, type CliNodeEffect, type CliNodeOperations, type CliNodeOperationsOptions, type CliNodeResult, commandIdentifier, connectLocalNode, discoveryError, discoveryOptionsFor, fillCommandIdentifier, holdsSessionCredential, invalidNodeInput, makeCliNodeOperations, newCliIdentifier, nodeAnswerOf, operationError, outcomeCanBeAmbiguous, type ParameterSchema, retryBriefSaturation, revisionOrCurrent, runLazyNodeDependency, } from "./client.js";
|
|
3
3
|
export { repeatBoundedWait } from "./wait.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/local-node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { makeCallClient } from "./call.js";
|
|
2
|
-
export { changeAtRevision, commandIdentifier, connectLocalNode, discoveryError, discoveryOptionsFor, fillCommandIdentifier, holdsSessionCredential, invalidNodeInput, makeCliNodeOperations, newCliIdentifier, operationError, outcomeCanBeAmbiguous, retryBriefSaturation, revisionOrCurrent, runLazyNodeDependency, } from "./client.js";
|
|
2
|
+
export { changeAtRevision, commandIdentifier, connectLocalNode, discoveryError, discoveryOptionsFor, fillCommandIdentifier, holdsSessionCredential, invalidNodeInput, makeCliNodeOperations, newCliIdentifier, nodeAnswerOf, operationError, outcomeCanBeAmbiguous, retryBriefSaturation, revisionOrCurrent, runLazyNodeDependency, } from "./client.js";
|
|
3
3
|
export { repeatBoundedWait } from "./wait.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/session/client.js
CHANGED
|
@@ -2,11 +2,34 @@ import { MAX_SESSION_WAIT_MILLISECONDS, sessionCreateParametersSchema, sessionEv
|
|
|
2
2
|
import * as Crypto from "effect/Crypto";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import { makeRelocateClient } from "../execution/index.js";
|
|
5
|
-
import { commandIdentifier, repeatBoundedWait, } from "../local-node/index.js";
|
|
5
|
+
import { commandIdentifier, nodeAnswerOf, repeatBoundedWait, } from "../local-node/index.js";
|
|
6
6
|
import { makeAgentPermissionCliClient } from "./agent-permission.js";
|
|
7
7
|
import { makeAttachClient } from "./attach-client.js";
|
|
8
8
|
import { makeCodingSessionClient } from "./coding-client.js";
|
|
9
9
|
import { toWorktreeRequest } from "./creation/index.js";
|
|
10
|
+
const keepingWords = (client, said) => {
|
|
11
|
+
const keep = (commandId, step) => Effect.tapError(step, (error) => Effect.sync(() => {
|
|
12
|
+
const answer = nodeAnswerOf(error);
|
|
13
|
+
if (answer !== undefined)
|
|
14
|
+
said.set(commandId, answer.message);
|
|
15
|
+
}));
|
|
16
|
+
return {
|
|
17
|
+
createSession: (parameters, options) => keep(parameters.commandId, client.createSession(parameters, options)),
|
|
18
|
+
listWorkspaces: (parameters, options) => client.listWorkspaces(parameters, options),
|
|
19
|
+
sendTurn: (parameters, options) => keep(parameters.commandId, client.sendTurn(parameters, options)),
|
|
20
|
+
showSession: (parameters, options) => client.showSession(parameters, options),
|
|
21
|
+
startSession: (parameters, options) => keep(parameters.commandId, client.startSession(parameters, options)),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const withWords = (outcome, said) => {
|
|
25
|
+
const { error } = outcome;
|
|
26
|
+
const message = error?.message === undefined && error?.commandId !== undefined
|
|
27
|
+
? said.get(error.commandId)
|
|
28
|
+
: undefined;
|
|
29
|
+
return error === undefined || message === undefined
|
|
30
|
+
? outcome
|
|
31
|
+
: { ...outcome, error: { ...error, message } };
|
|
32
|
+
};
|
|
10
33
|
export const makeSessionClient = (node) => {
|
|
11
34
|
const createSession = (input) => {
|
|
12
35
|
const { baseRef, branch, commandId: requestedCommandId, ...selection } = input;
|
|
@@ -96,7 +119,10 @@ export const makeSessionClient = (node) => {
|
|
|
96
119
|
};
|
|
97
120
|
const withSdk = (operation) => Effect.flatMap(Crypto.Crypto, (crypto) => node.runNodeClientOperation((client) => Effect.promise(() => import("@maiaos/sdk/node/effect")).pipe(Effect.flatMap((sdk) => operation(sdk, client)), Effect.provideService(Crypto.Crypto, crypto))));
|
|
98
121
|
const planSessions = (input) => withSdk((sdk, client) => sdk.planSessionCreationEffect(client, input));
|
|
99
|
-
const runSessions = (plan, options) => withSdk((sdk, client) =>
|
|
122
|
+
const runSessions = (plan, options) => withSdk((sdk, client) => {
|
|
123
|
+
const said = new Map();
|
|
124
|
+
return Effect.map(sdk.createSessionsEffect(keepingWords(client, said), plan, options), (outcomes) => outcomes.map((outcome) => withWords(outcome, said)));
|
|
125
|
+
});
|
|
100
126
|
const awaitSessionRunning = (input) => withSdk((sdk, client) => sdk.awaitSessionRunningEffect(client, input.sessionId, input.deadlineMilliseconds));
|
|
101
127
|
return {
|
|
102
128
|
acknowledgeAttachedSessionDelivery,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maiaos/cli",
|
|
3
|
-
"version": "0.1.0-canary.
|
|
3
|
+
"version": "0.1.0-canary.70",
|
|
4
4
|
"description": "The maia CLI and MCP server: start, drive, observe and stop swarms of Claude Code and Codex agents from a terminal, a script or another agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maia",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@earendil-works/pi-tui": "1.0.0",
|
|
67
67
|
"@effect/platform-node-shared": "4.0.0",
|
|
68
|
-
"@maiaos/agent": "0.1.0-canary.
|
|
69
|
-
"@maiaos/client-core": "0.1.0-canary.
|
|
70
|
-
"@maiaos/sdk": "0.1.0-canary.
|
|
68
|
+
"@maiaos/agent": "0.1.0-canary.70",
|
|
69
|
+
"@maiaos/client-core": "0.1.0-canary.70",
|
|
70
|
+
"@maiaos/sdk": "0.1.0-canary.70",
|
|
71
71
|
"effect": "4.0.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|