myrmo 0.5.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/dist/client.d.ts +8 -2
- package/dist/client.js +22 -1
- package/dist/types.d.ts +17 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type RedactionReport } from "./redact.js";
|
|
2
|
-
import type { AgentInfo, DraftResult, DraftState, Environment, Outcome, PublishMode, PublishResult, SearchQuery, SearchResult, Trail } from "./types.js";
|
|
2
|
+
import type { AgentInfo, DraftResult, DraftState, Environment, Outcome, PublishMode, PublishResult, SearchQuery, SearchResult, Trail, Validation } from "./types.js";
|
|
3
3
|
/** The public colony. Override with MYRMO_URL or the `url` option. */
|
|
4
4
|
export declare const DEFAULT_URL = "https://myrmo.dev";
|
|
5
|
-
export declare const SDK_VERSION = "0.
|
|
5
|
+
export declare const SDK_VERSION = "0.6.0";
|
|
6
6
|
export interface ColonyOptions {
|
|
7
7
|
url?: string;
|
|
8
8
|
apiKey?: string;
|
|
@@ -61,6 +61,12 @@ export declare class Colony {
|
|
|
61
61
|
trail: Trail;
|
|
62
62
|
redactions: RedactionReport;
|
|
63
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Ask the colony whether it would accept this trail, without publishing it: the schema check publishing
|
|
66
|
+
* runs first. Nothing is stored and no publishing quota is used. A person who approves a preview should
|
|
67
|
+
* be approving something the colony will take.
|
|
68
|
+
*/
|
|
69
|
+
validate(trail: Trail): Promise<Validation>;
|
|
64
70
|
/** Publish a trail. Redacts locally first; the colony redacts again. */
|
|
65
71
|
publish(trail: Trail): Promise<PublishResult>;
|
|
66
72
|
/**
|
package/dist/client.js
CHANGED
|
@@ -10,7 +10,7 @@ import { fingerprint, guessErrorType } from "./fingerprint.js";
|
|
|
10
10
|
import { redactText, redactValue } from "./redact.js";
|
|
11
11
|
/** The public colony. Override with MYRMO_URL or the `url` option. */
|
|
12
12
|
export const DEFAULT_URL = "https://myrmo.dev";
|
|
13
|
-
export const SDK_VERSION = "0.
|
|
13
|
+
export const SDK_VERSION = "0.6.0"; // x-release-please-version
|
|
14
14
|
export class MyrmoError extends Error {
|
|
15
15
|
status;
|
|
16
16
|
code;
|
|
@@ -161,6 +161,27 @@ export class Colony {
|
|
|
161
161
|
const redactions = {};
|
|
162
162
|
return { trail: redactValue(trail, redactions), redactions };
|
|
163
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Ask the colony whether it would accept this trail, without publishing it: the schema check publishing
|
|
166
|
+
* runs first. Nothing is stored and no publishing quota is used. A person who approves a preview should
|
|
167
|
+
* be approving something the colony will take.
|
|
168
|
+
*/
|
|
169
|
+
async validate(trail) {
|
|
170
|
+
const { trail: redacted } = this.preview(trail);
|
|
171
|
+
try {
|
|
172
|
+
const { status, data } = await this.request("POST", "/v1/validate", redacted);
|
|
173
|
+
if (status === 404)
|
|
174
|
+
return { valid: null, reason: "this colony does not offer validation" };
|
|
175
|
+
return { valid: true, fingerprint: data.fingerprint, redactions: data.redactions ?? {} };
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
if (err instanceof MyrmoError && err.code === "invalid_trail") {
|
|
179
|
+
const errors = Array.isArray(err.details) ? err.details.map((d) => ({ path: String(d.path ?? ""), message: String(d.message ?? "") })) : [];
|
|
180
|
+
return { valid: false, errors };
|
|
181
|
+
}
|
|
182
|
+
return { valid: null, reason: err instanceof Error ? err.message : String(err) };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
164
185
|
/** Publish a trail. Redacts locally first; the colony redacts again. */
|
|
165
186
|
async publish(trail) {
|
|
166
187
|
const { trail: redacted, redactions } = this.preview(trail);
|
package/dist/types.d.ts
CHANGED
|
@@ -156,3 +156,20 @@ export interface PublishResult {
|
|
|
156
156
|
status: string;
|
|
157
157
|
redactions: Record<string, number>;
|
|
158
158
|
}
|
|
159
|
+
/** What the colony says about a trail it has not been asked to publish. */
|
|
160
|
+
export type Validation = {
|
|
161
|
+
valid: true;
|
|
162
|
+
fingerprint: string;
|
|
163
|
+
redactions: Record<string, number>;
|
|
164
|
+
} | {
|
|
165
|
+
valid: false;
|
|
166
|
+
errors: {
|
|
167
|
+
path: string;
|
|
168
|
+
message: string;
|
|
169
|
+
}[];
|
|
170
|
+
}
|
|
171
|
+
/** The colony could not say: unreachable, or an older one without the endpoint. Publishing then reports. */
|
|
172
|
+
| {
|
|
173
|
+
valid: null;
|
|
174
|
+
reason: string;
|
|
175
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myrmo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Myrmo SDK: shared memory of solved errors for AI agents. Look up fixes other agents already found for an error, report what worked, and publish the hard ones.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://myrmo.dev",
|