@pome-sh/cli 0.15.0 → 0.17.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/build-info.json +3 -3
- package/dist/src/cli/checks-add.d.ts +2 -7
- package/dist/src/cli/checks-add.js +10 -24
- package/dist/src/cli/checks.d.ts +3 -2
- package/dist/src/cli/checks.js +22 -9
- package/dist/src/cli/vocabulary-skew.d.ts +64 -0
- package/dist/src/cli/vocabulary-skew.js +187 -0
- package/dist/src/twin/githubCloneAdapter.d.ts +1 -0
- package/node_modules/@pome-sh/twin-github/FIDELITY.md +14 -0
- package/node_modules/@pome-sh/twin-github/dist/src/check-pulls.d.ts +4 -0
- package/node_modules/@pome-sh/twin-github/dist/src/check-pulls.js +93 -0
- package/node_modules/@pome-sh/twin-github/dist/src/check-pulls.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/check-state.d.ts +1 -0
- package/node_modules/@pome-sh/twin-github/dist/src/check-state.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/checks.d.ts +3 -0
- package/node_modules/@pome-sh/twin-github/dist/src/checks.js +2 -1
- package/node_modules/@pome-sh/twin-github/dist/src/checks.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/db.js +46 -4
- package/node_modules/@pome-sh/twin-github/dist/src/db.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/domain/github-domain.d.ts +3 -0
- package/node_modules/@pome-sh/twin-github/dist/src/domain/github-domain.js +49 -1
- package/node_modules/@pome-sh/twin-github/dist/src/domain/github-domain.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/domain/issues.js +15 -5
- package/node_modules/@pome-sh/twin-github/dist/src/domain/issues.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/serializers.d.ts +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/serializers.js +8 -2
- package/node_modules/@pome-sh/twin-github/dist/src/serializers.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/package.json +1 -1
- package/node_modules/@pome-sh/twin-linear/CHANGELOG.md +142 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-comments.d.ts +10 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-comments.js +117 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-comments.js.map +1 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-issues.d.ts +25 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-issues.js +211 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-issues.js.map +1 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-kind.d.ts +3 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-kind.js +9 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-kind.js.map +1 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-params.d.ts +8 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-params.js +94 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-params.js.map +1 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-state.d.ts +98 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-state.js +131 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-state.js.map +1 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-tape.d.ts +2 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-tape.js +100 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-tape.js.map +1 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-worlds.d.ts +44 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-worlds.js +93 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/check-worlds.js.map +1 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/checks.d.ts +29 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/checks.js +52 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/checks.js.map +1 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/db.d.ts +6 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/db.js +53 -4
- package/node_modules/@pome-sh/twin-linear/dist/src/db.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/agents.d.ts +16 -13
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/agents.js +16 -12
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/agents.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/comments.js +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/comments.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/documents.js +8 -8
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/documents.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/issues.js +20 -17
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/issues.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/labels.js +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/labels.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/linear-domain.d.ts +4 -17
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/linear-domain.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/normalize.d.ts +12 -2
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/normalize.js +28 -5
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/normalize.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/projects-cycles.js +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/projects-cycles.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/rows.d.ts +3 -3
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/rows.js +4 -3
- package/node_modules/@pome-sh/twin-linear/dist/src/domain/rows.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/formatters.js +3 -3
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/formatters.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/mutation-inputs.d.ts +30 -12
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/mutation-inputs.js +33 -28
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/mutation-inputs.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/resolvers.js +2 -2
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/resolvers.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/schema.js +31 -13
- package/node_modules/@pome-sh/twin-linear/dist/src/graphql/schema.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/index.d.ts +2 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/index.js +7 -0
- package/node_modules/@pome-sh/twin-linear/dist/src/index.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/state.js +4 -4
- package/node_modules/@pome-sh/twin-linear/dist/src/state.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/dist/src/types.d.ts +10 -4
- package/node_modules/@pome-sh/twin-linear/dist/src/types.js.map +1 -1
- package/node_modules/@pome-sh/twin-linear/fixtures/README.md +1 -0
- package/node_modules/@pome-sh/twin-linear/fixtures/linear-introspection.json +66 -0
- package/node_modules/@pome-sh/twin-linear/package.json +2 -1
- package/node_modules/@pome-sh/twin-stripe/FIDELITY.md +8 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/idempotency.d.ts +23 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/idempotency.js +40 -6
- package/node_modules/@pome-sh/twin-stripe/dist/src/idempotency.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js +5 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/twin.js +7 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/twin.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/package.json +1 -1
- package/package.json +4 -4
- package/tasks/14-stripe-refund-retry.md +17 -14
- package/tasks/24-linear-issue-triage.md +2 -2
- package/tasks/25-linear-comment-label-triage.md +3 -3
- package/tasks/26-github-linear-handoff.md +3 -4
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
//
|
|
3
|
+
// What Linear's declared checks can assert about the RUN — the recorded call
|
|
4
|
+
// tape rather than the exported end state (F-1129).
|
|
5
|
+
//
|
|
6
|
+
// Why this class has to exist at all: an unsupported call leaves NO STATE
|
|
7
|
+
// TRACE. The twin answers 501 and mutates nothing, so `state_final.json` is
|
|
8
|
+
// byte-identical whether the examinee reached for an unimplemented route or
|
|
9
|
+
// never tried. The runtime stamps `fidelity: "unsupported"` on the recorded
|
|
10
|
+
// event instead, and that stamp is the only place the fact survives.
|
|
11
|
+
//
|
|
12
|
+
// NO TWIN WORD IN THE TEMPLATE, matching `github.no-unsupported-endpoint`
|
|
13
|
+
// exactly. The legacy cloud-side rule took the twin word as an OPTIONAL
|
|
14
|
+
// qualifier ("No unsupported Linear endpoint was called") along with plural and
|
|
15
|
+
// `were` variants, because an author typed English. Under position 2 an author
|
|
16
|
+
// PICKS the check, so the variants are retired rather than ported. Two twins
|
|
17
|
+
// may share a template — ids differ, and `resolveTwinRules` is per-twin — and
|
|
18
|
+
// no shipped Linear criterion says this sentence today, so nothing in the
|
|
19
|
+
// corpus moves.
|
|
20
|
+
import { defineCheck } from "@pome-sh/sdk/checks";
|
|
21
|
+
import { tapeWorld } from "./check-worlds.js";
|
|
22
|
+
export const noUnsupportedEndpoint = defineCheck({
|
|
23
|
+
id: "linear.no-unsupported-endpoint",
|
|
24
|
+
description: "Scans the recorded call tape for any request the twin answered with fidelity " +
|
|
25
|
+
'"unsupported" — a route it does not implement, answered 501. It asserts nothing about ' +
|
|
26
|
+
"whether the run SUCCEEDED, and nothing about calls that were merely rejected: a 404 or a " +
|
|
27
|
+
"422 from a route the twin does implement is a semantic answer and passes. The tape is " +
|
|
28
|
+
"scoped to this twin by the engine before the check sees it, so an unsupported call to a " +
|
|
29
|
+
"different twin in a multi-twin session cannot fail it.",
|
|
30
|
+
template: "No unsupported endpoint was called",
|
|
31
|
+
params: {},
|
|
32
|
+
substrate: "tape",
|
|
33
|
+
// A prohibition. Nothing is required to happen; only the examinee reaching
|
|
34
|
+
// for an unimplemented route can break it.
|
|
35
|
+
polarity: () => "negative",
|
|
36
|
+
// No caller-supplied literal is hunted for in any substrate, so there is
|
|
37
|
+
// nothing a redactor could silently delete out from under this check.
|
|
38
|
+
subject: () => null,
|
|
39
|
+
// Ledgered. No slots, so the sentence carries no literal to falsify — the
|
|
40
|
+
// trigger is a fidelity stamp on the tape, which no mutation of the criterion
|
|
41
|
+
// text can reach.
|
|
42
|
+
vacuityMutant: () => null,
|
|
43
|
+
discriminatingWorlds: () => ({
|
|
44
|
+
passing: tapeWorld([
|
|
45
|
+
{
|
|
46
|
+
twin: "linear",
|
|
47
|
+
method: "POST",
|
|
48
|
+
path: "/graphql",
|
|
49
|
+
status: 200,
|
|
50
|
+
fidelity: "semantic",
|
|
51
|
+
event_id: "evt_ok",
|
|
52
|
+
},
|
|
53
|
+
]),
|
|
54
|
+
failing: tapeWorld([
|
|
55
|
+
{
|
|
56
|
+
twin: "linear",
|
|
57
|
+
method: "POST",
|
|
58
|
+
path: "/graphql",
|
|
59
|
+
status: 501,
|
|
60
|
+
fidelity: "unsupported",
|
|
61
|
+
event_id: "evt_bad",
|
|
62
|
+
},
|
|
63
|
+
]),
|
|
64
|
+
}),
|
|
65
|
+
evaluate(_args, { tape }) {
|
|
66
|
+
// The engine guards this before calling; the check guards too, so a
|
|
67
|
+
// consumer that forgets gets a named skip rather than a vacuous pass. For a
|
|
68
|
+
// NEGATIVE criterion that distinction is the whole ballgame — passing here
|
|
69
|
+
// would be a clean bill of health issued over a tape nobody read.
|
|
70
|
+
//
|
|
71
|
+
// `null` and `[]` are deliberately different: an EMPTY tape is a real world
|
|
72
|
+
// (the agent called nothing, so it called nothing unsupported).
|
|
73
|
+
if (tape === null)
|
|
74
|
+
return { passed: false, reason: "tape_missing", status: "skipped" };
|
|
75
|
+
const unsupported = tape.filter((event) => event.fidelity === "unsupported");
|
|
76
|
+
if (unsupported.length === 0) {
|
|
77
|
+
// No evidence on the pass branch (F-980). This asserts a NEGATIVE over
|
|
78
|
+
// the whole tape, and a negative over an empty set has no single call to
|
|
79
|
+
// point at; citing all N inspected calls would be a copy of the trace.
|
|
80
|
+
return {
|
|
81
|
+
passed: true,
|
|
82
|
+
reason: `no unsupported endpoint was called (${tape.length} call(s) inspected)`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Cite the offenders. A row with no `event_id` drops out of the CITATION
|
|
86
|
+
// but not out of the count or the prose: losing an id must never lose a
|
|
87
|
+
// finding.
|
|
88
|
+
const evidenceEventIds = unsupported
|
|
89
|
+
.map((event) => event.event_id)
|
|
90
|
+
.filter((id) => typeof id === "string" && id !== "");
|
|
91
|
+
return {
|
|
92
|
+
passed: false,
|
|
93
|
+
reason: `${unsupported.length} unsupported call(s): ${unsupported
|
|
94
|
+
.map((e) => `${e.method ?? "?"} ${e.path ?? "?"}`)
|
|
95
|
+
.join(", ")}`,
|
|
96
|
+
...(evidenceEventIds.length > 0 ? { evidenceEventIds } : {}),
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=check-tape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-tape.js","sourceRoot":"","sources":["../../src/check-tape.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,6EAA6E;AAC7E,oDAAoD;AACpD,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,qEAAqE;AACrE,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,gFAAgF;AAChF,+EAA+E;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rate, CheckTapeEvent } from "@pome-sh/sdk/checks";
|
|
2
|
+
import type { LinearCheckState, LinearCheckStateComment, LinearCheckStateIssue } from "./check-state.js";
|
|
3
|
+
export declare const FIXTURE_TEAM_ID = "team_eng";
|
|
4
|
+
export declare const FIXTURE_TEAM_KEY = "ENG";
|
|
5
|
+
/** The one derivation, used by both the catalog and the rows that reference it. */
|
|
6
|
+
export declare function fixtureStateId(name: string): string;
|
|
7
|
+
/** Ditto for labels. */
|
|
8
|
+
export declare function fixtureLabelId(name: string): string;
|
|
9
|
+
/** Linear's default workflow, the five states `defaultSeedState()` seeds. */
|
|
10
|
+
export declare const FIXTURE_STATES: readonly [{
|
|
11
|
+
readonly name: "Backlog";
|
|
12
|
+
readonly type: "backlog";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "Todo";
|
|
15
|
+
readonly type: "unstarted";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "In Progress";
|
|
18
|
+
readonly type: "started";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "Done";
|
|
21
|
+
readonly type: "completed";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "Canceled";
|
|
24
|
+
readonly type: "canceled";
|
|
25
|
+
}];
|
|
26
|
+
export declare function finalWorld(final: LinearCheckState): CheckSubstrate<LinearCheckState>;
|
|
27
|
+
export declare function deltaWorld(seed: LinearCheckState, final: LinearCheckState): CheckSubstrate<LinearCheckState>;
|
|
28
|
+
export declare function tapeWorld(tape: readonly CheckTapeEvent[]): CheckSubstrate<LinearCheckState>;
|
|
29
|
+
/**
|
|
30
|
+
* A one-team workspace with Linear's five default workflow states.
|
|
31
|
+
*
|
|
32
|
+
* `labelNames` is the workspace label CATALOG, not the labels on any issue —
|
|
33
|
+
* `issueRow` attaches ids, and an id with no catalog row resolves to
|
|
34
|
+
* `label_unresolved`, a skip. Pass every label the issues reference.
|
|
35
|
+
*/
|
|
36
|
+
export declare function linearState(issues: LinearCheckStateIssue[], comments?: LinearCheckStateComment[], labelNames?: readonly string[]): LinearCheckState;
|
|
37
|
+
/** A resolvable issue row, with `stateId` and `labelIds` derived the way the export emits them. */
|
|
38
|
+
export declare function issueRow(title: string, over?: {
|
|
39
|
+
id?: string;
|
|
40
|
+
stateName?: string;
|
|
41
|
+
labelNames?: readonly string[];
|
|
42
|
+
estimate?: number | null;
|
|
43
|
+
assigneeId?: string;
|
|
44
|
+
}): LinearCheckStateIssue;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
//
|
|
3
|
+
// The fixture worlds Linear's declarations name (F-1129).
|
|
4
|
+
//
|
|
5
|
+
// In `src/` rather than `test/` for the same reason twin-github's and
|
|
6
|
+
// twin-slack's are: `discriminatingWorlds` is a DECLARED field read from npm by
|
|
7
|
+
// pome-cloud and the CLI, so a builder that shipped only in the test tree would
|
|
8
|
+
// make the field unusable outside this repo.
|
|
9
|
+
//
|
|
10
|
+
// EVERY FAILING WORLD KEEPS ITS SELECTOR RESOLVABLE. Arm 3 of
|
|
11
|
+
// `probeDiscrimination` rejects a failing world whose `reason` matches the one
|
|
12
|
+
// an EMPTY world produces — measured on 11 of twin-github's 13 checks before
|
|
13
|
+
// that arm existed. So a world built by omitting the team or the issue fails
|
|
14
|
+
// through its selector rather than its assertion and is thrown out. Which is
|
|
15
|
+
// why `linearState` always fills teams, workflowStates and labels, and why the
|
|
16
|
+
// declarations move only the asserted value between their two worlds.
|
|
17
|
+
//
|
|
18
|
+
// The id derivations are shared rather than written twice. A fixture whose
|
|
19
|
+
// `stateId` did not match a row in the same world would skip
|
|
20
|
+
// `workflow_state_unresolved`, and a skip satisfies NEITHER arm — so a drifting
|
|
21
|
+
// literal would look like a broken check rather than a broken fixture.
|
|
22
|
+
export const FIXTURE_TEAM_ID = "team_eng";
|
|
23
|
+
export const FIXTURE_TEAM_KEY = "ENG";
|
|
24
|
+
/** The one derivation, used by both the catalog and the rows that reference it. */
|
|
25
|
+
export function fixtureStateId(name) {
|
|
26
|
+
return `state_${name.toLowerCase().replace(/[^a-z0-9]+/g, "_")}`;
|
|
27
|
+
}
|
|
28
|
+
/** Ditto for labels. */
|
|
29
|
+
export function fixtureLabelId(name) {
|
|
30
|
+
return `label_${name.toLowerCase().replace(/[^a-z0-9]+/g, "_")}`;
|
|
31
|
+
}
|
|
32
|
+
/** Linear's default workflow, the five states `defaultSeedState()` seeds. */
|
|
33
|
+
export const FIXTURE_STATES = [
|
|
34
|
+
{ name: "Backlog", type: "backlog" },
|
|
35
|
+
{ name: "Todo", type: "unstarted" },
|
|
36
|
+
{ name: "In Progress", type: "started" },
|
|
37
|
+
{ name: "Done", type: "completed" },
|
|
38
|
+
{ name: "Canceled", type: "canceled" },
|
|
39
|
+
];
|
|
40
|
+
export function finalWorld(final) {
|
|
41
|
+
return { seed: null, final, tape: null };
|
|
42
|
+
}
|
|
43
|
+
export function deltaWorld(seed, final) {
|
|
44
|
+
return { seed, final, tape: null };
|
|
45
|
+
}
|
|
46
|
+
export function tapeWorld(tape) {
|
|
47
|
+
return { seed: null, final: { issues: [] }, tape };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A one-team workspace with Linear's five default workflow states.
|
|
51
|
+
*
|
|
52
|
+
* `labelNames` is the workspace label CATALOG, not the labels on any issue —
|
|
53
|
+
* `issueRow` attaches ids, and an id with no catalog row resolves to
|
|
54
|
+
* `label_unresolved`, a skip. Pass every label the issues reference.
|
|
55
|
+
*/
|
|
56
|
+
export function linearState(issues, comments = [], labelNames = ["Agent"]) {
|
|
57
|
+
return {
|
|
58
|
+
teams: [{ id: FIXTURE_TEAM_ID, key: FIXTURE_TEAM_KEY, name: "Engineering" }],
|
|
59
|
+
workflowStates: FIXTURE_STATES.map((s) => ({
|
|
60
|
+
id: fixtureStateId(s.name),
|
|
61
|
+
teamId: FIXTURE_TEAM_ID,
|
|
62
|
+
name: s.name,
|
|
63
|
+
type: s.type,
|
|
64
|
+
})),
|
|
65
|
+
labels: labelNames.map((name) => ({
|
|
66
|
+
id: fixtureLabelId(name),
|
|
67
|
+
teamId: FIXTURE_TEAM_ID,
|
|
68
|
+
name,
|
|
69
|
+
})),
|
|
70
|
+
issues,
|
|
71
|
+
comments,
|
|
72
|
+
users: [
|
|
73
|
+
{ id: "user_dev", email: "dev@pome-twin.test", name: "Developer", displayName: "Dev" },
|
|
74
|
+
],
|
|
75
|
+
exportBounds: { truncatedCollections: [] },
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** A resolvable issue row, with `stateId` and `labelIds` derived the way the export emits them. */
|
|
79
|
+
export function issueRow(title, over = {}) {
|
|
80
|
+
return {
|
|
81
|
+
id: over.id ?? "issue_1",
|
|
82
|
+
identifier: "ENG-1",
|
|
83
|
+
number: 1,
|
|
84
|
+
teamId: FIXTURE_TEAM_ID,
|
|
85
|
+
title,
|
|
86
|
+
stateId: fixtureStateId(over.stateName ?? "In Progress"),
|
|
87
|
+
estimate: over.estimate ?? null,
|
|
88
|
+
...(over.assigneeId === undefined ? {} : { assigneeId: over.assigneeId }),
|
|
89
|
+
archivedAt: null,
|
|
90
|
+
labelIds: (over.labelNames ?? []).map(fixtureLabelId),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=check-worlds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-worlds.js","sourceRoot":"","sources":["../../src/check-worlds.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,0DAA0D;AAC1D,EAAE;AACF,sEAAsE;AACtE,gFAAgF;AAChF,gFAAgF;AAChF,6CAA6C;AAC7C,EAAE;AACF,8DAA8D;AAC9D,+EAA+E;AAC/E,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,sEAAsE;AACtE,EAAE;AACF,2EAA2E;AAC3E,6DAA6D;AAC7D,gFAAgF;AAChF,uEAAuE;AASvE,MAAM,CAAC,MAAM,eAAe,GAAG,UA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EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;QACzE,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC;KACtD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type { Check } from "./check-kind.js";
|
|
2
|
+
export type { LinearCheckState, LinearCheckStateComment, LinearCheckStateIssue, LinearCheckStateLabel, LinearCheckStateTeam, LinearCheckStateUser, LinearCheckStateWorkflowState, } from "./check-state.js";
|
|
3
|
+
export declare const LINEAR_CHECKS: readonly [import("./check-kind.js").Check<{
|
|
4
|
+
title: string;
|
|
5
|
+
team: string;
|
|
6
|
+
}>, import("./check-kind.js").Check<{
|
|
7
|
+
title: string;
|
|
8
|
+
team: string;
|
|
9
|
+
state: string;
|
|
10
|
+
}>, import("./check-kind.js").Check<{
|
|
11
|
+
title: string;
|
|
12
|
+
team: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}>, import("./check-kind.js").Check<{
|
|
15
|
+
title: string;
|
|
16
|
+
team: string;
|
|
17
|
+
estimate: string;
|
|
18
|
+
}>, import("./check-kind.js").Check<{
|
|
19
|
+
title: string;
|
|
20
|
+
team: string;
|
|
21
|
+
user: string;
|
|
22
|
+
}>, import("./check-kind.js").Check<{
|
|
23
|
+
title: string;
|
|
24
|
+
team: string;
|
|
25
|
+
needle: string;
|
|
26
|
+
}>, import("./check-kind.js").Check<{
|
|
27
|
+
title: string;
|
|
28
|
+
team: string;
|
|
29
|
+
}>, import("./check-kind.js").Check<Record<string, never>>];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
//
|
|
3
|
+
// The Linear twin's assertable check vocabulary (F-1129, milestone A3).
|
|
4
|
+
//
|
|
5
|
+
// These live HERE, next to the state they read, because the twin owns that
|
|
6
|
+
// state's shape. pome-cloud imports this module from npm and adapts each
|
|
7
|
+
// declaration onto its predicate engine, so there is no second copy to
|
|
8
|
+
// reconcile — only a pin that can fall behind, which is what its drift gate
|
|
9
|
+
// exists to catch. The cloud's `deterministic/linear.ts`, including its
|
|
10
|
+
// hand-maintained mirror of the state shape whose header records a manual
|
|
11
|
+
// audit "verified against source, 2026-07-25", is deleted in the same
|
|
12
|
+
// milestone. That audit is the artifact this file retires.
|
|
13
|
+
//
|
|
14
|
+
// Linear is the LAST of A3's four vocabularies, and the one that answered the
|
|
15
|
+
// two questions the earlier three left open:
|
|
16
|
+
//
|
|
17
|
+
// * A rendered sentence cannot carry a pronoun. Six of the nine shipped
|
|
18
|
+
// criteria named their subject with "that issue", with no subject at all,
|
|
19
|
+
// or by pointing at the seed. Under position 2 an author picks a check and
|
|
20
|
+
// fills its parameters, and `evaluate(args, substrate)` receives only its
|
|
21
|
+
// own args — so there is no mechanism by which "that issue" could resolve.
|
|
22
|
+
// Every check therefore takes an explicit title, and the three task files
|
|
23
|
+
// were rewritten to say so.
|
|
24
|
+
// * twin-github FAILS on a selector miss and twin-slack SKIPS. Linear does
|
|
25
|
+
// both, split by evidence rather than by taste — see `check-state.ts`.
|
|
26
|
+
//
|
|
27
|
+
// This file is the ASSEMBLY. Declarations group by what they assert about
|
|
28
|
+
// (`check-issues.ts`, `check-comments.ts`, `check-tape.ts`), with typed slots in
|
|
29
|
+
// `check-params.ts`, fixture worlds in `check-worlds.ts`, and the reading of the
|
|
30
|
+
// exported tree in `check-state.ts`.
|
|
31
|
+
import { issueCommentContains, issueThreadedReply } from "./check-comments.js";
|
|
32
|
+
import { issueAssignee, issueEstimate, issueExists, issueHasLabel, issueState, } from "./check-issues.js";
|
|
33
|
+
import { noUnsupportedEndpoint } from "./check-tape.js";
|
|
34
|
+
// Order is not first-match-wins — the generated patterns are anchored and
|
|
35
|
+
// mutually exclusive, and `checks-contract.test.ts` proves no sentence is
|
|
36
|
+
// claimed by two. It is the order an authoring surface lists them in, running
|
|
37
|
+
// from the assertion an author reaches for first to the ones a specialised task
|
|
38
|
+
// needs.
|
|
39
|
+
export const LINEAR_CHECKS = [
|
|
40
|
+
issueExists,
|
|
41
|
+
issueState,
|
|
42
|
+
issueHasLabel,
|
|
43
|
+
issueEstimate,
|
|
44
|
+
issueAssignee,
|
|
45
|
+
issueCommentContains,
|
|
46
|
+
issueThreadedReply,
|
|
47
|
+
// Last, because the listing order runs from the assertion an author reaches
|
|
48
|
+
// for first to the ones a specialised task needs — and this is the only one
|
|
49
|
+
// that reads the run rather than the world it left behind.
|
|
50
|
+
noUnsupportedEndpoint,
|
|
51
|
+
];
|
|
52
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/checks.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,wEAAwE;AACxE,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,uEAAuE;AACvE,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAC1E,sEAAsE;AACtE,2DAA2D;AAC3D,EAAE;AACF,8EAA8E;AAC9E,6CAA6C;AAC7C,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,gCAAgC;AAChC,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,0EAA0E;AAC1E,iFAAiF;AACjF,iFAAiF;AACjF,qCAAqC;AAErC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,EACX,aAAa,EACb,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAaxD,0EAA0E;AAC1E,0EAA0E;AAC1E,8EAA8E;AAC9E,gFAAgF;AAChF,SAAS;AACT,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,WAAW;IACX,UAAU;IACV,aAAa;IACb,aAAa;IACb,aAAa;IACb,oBAAoB;IACpB,kBAAkB;IAClB,4EAA4E;IAC5E,4EAA4E;IAC5E,2DAA2D;IAC3D,qBAAqB;CACb,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { LinearTwinDatabase } from "./types.js";
|
|
2
2
|
export declare function openLinearTwinDatabase(path?: string): LinearTwinDatabase;
|
|
3
|
+
/**
|
|
4
|
+
* Pre-F-1172 agent session states that Linear does not have, and the Linear
|
|
5
|
+
* member each one becomes. Linear has no cancellation state; `stale` ("no
|
|
6
|
+
* longer progressing") is its closest neighbour.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RETIRED_AGENT_SESSION_STATUSES: ReadonlyArray<readonly [string, string]>;
|
|
3
9
|
export declare function migrate(db: LinearTwinDatabase): void;
|
|
4
10
|
export declare function resetDatabase(db: LinearTwinDatabase): void;
|
|
@@ -242,15 +242,15 @@ CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
|
242
242
|
id TEXT PRIMARY KEY,
|
|
243
243
|
issue_id TEXT,
|
|
244
244
|
comment_id TEXT,
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
app_user_id TEXT NOT NULL,
|
|
246
|
+
status TEXT NOT NULL,
|
|
247
247
|
plan TEXT,
|
|
248
|
-
|
|
248
|
+
external_urls_json TEXT NOT NULL DEFAULT '[]',
|
|
249
249
|
created_at TEXT NOT NULL,
|
|
250
250
|
updated_at TEXT NOT NULL,
|
|
251
251
|
FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE,
|
|
252
252
|
FOREIGN KEY (comment_id) REFERENCES comments(id) ON DELETE CASCADE,
|
|
253
|
-
FOREIGN KEY (
|
|
253
|
+
FOREIGN KEY (app_user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
254
254
|
);
|
|
255
255
|
|
|
256
256
|
CREATE TABLE IF NOT EXISTS agent_activities (
|
|
@@ -315,11 +315,60 @@ DELETE FROM linear_config;
|
|
|
315
315
|
export function openLinearTwinDatabase(path = process.env.LINEAR_TWIN_DB ?? ":memory:") {
|
|
316
316
|
return openTwinDatabase(path, { migrate });
|
|
317
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Pre-F-1172 agent session states that Linear does not have, and the Linear
|
|
320
|
+
* member each one becomes. Linear has no cancellation state; `stale` ("no
|
|
321
|
+
* longer progressing") is its closest neighbour.
|
|
322
|
+
*/
|
|
323
|
+
export const RETIRED_AGENT_SESSION_STATUSES = [
|
|
324
|
+
["completed", "complete"],
|
|
325
|
+
["failed", "error"],
|
|
326
|
+
["canceled", "stale"],
|
|
327
|
+
];
|
|
318
328
|
export function migrate(db) {
|
|
319
329
|
db.exec(MIGRATION_SQL);
|
|
320
330
|
ensureColumn(db, "issues", "estimate", "INTEGER");
|
|
321
331
|
ensureColumn(db, "issues", "parent_id", "TEXT");
|
|
322
332
|
ensureColumn(db, "comments", "parent_id", "TEXT");
|
|
333
|
+
migrateAgentSessions(db);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* F-1172 — carry a pre-rename `agent_sessions` table forward.
|
|
337
|
+
*
|
|
338
|
+
* `CREATE TABLE IF NOT EXISTS` is a no-op on a database that already has the
|
|
339
|
+
* table, so without this an existing `LINEAR_TWIN_DB` file opens clean on the
|
|
340
|
+
* OLD columns and then dies later with `"undefined" is not valid JSON` from
|
|
341
|
+
* `mapAgentSession`, nowhere near the cause. Reopening old files is supported
|
|
342
|
+
* (see the `ensureColumn` calls above); cloud's per-session databases are
|
|
343
|
+
* ephemeral, but local and self-host files are not.
|
|
344
|
+
*
|
|
345
|
+
* Every step is guarded on the current column set, so this is idempotent and a
|
|
346
|
+
* no-op on a database created by the current schema.
|
|
347
|
+
*/
|
|
348
|
+
function migrateAgentSessions(db) {
|
|
349
|
+
const columnNames = () => db.prepare("PRAGMA table_info(agent_sessions)").all().map((column) => column.name);
|
|
350
|
+
let columns = columnNames();
|
|
351
|
+
if (columns.includes("agent_user_id") && !columns.includes("app_user_id")) {
|
|
352
|
+
db.exec("ALTER TABLE agent_sessions RENAME COLUMN agent_user_id TO app_user_id");
|
|
353
|
+
}
|
|
354
|
+
if (columns.includes("state") && !columns.includes("status")) {
|
|
355
|
+
db.exec("ALTER TABLE agent_sessions RENAME COLUMN state TO status");
|
|
356
|
+
}
|
|
357
|
+
columns = columnNames();
|
|
358
|
+
if (!columns.includes("external_urls_json")) {
|
|
359
|
+
db.exec("ALTER TABLE agent_sessions ADD COLUMN external_urls_json TEXT NOT NULL DEFAULT '[]'");
|
|
360
|
+
}
|
|
361
|
+
if (columns.includes("external_url")) {
|
|
362
|
+
// The single URL becomes a one-entry collection. Linear's label is
|
|
363
|
+
// non-null and the old shape carried none, so it backfills as empty.
|
|
364
|
+
db.exec(`UPDATE agent_sessions
|
|
365
|
+
SET external_urls_json = json_array(json_object('url', external_url, 'label', ''))
|
|
366
|
+
WHERE external_url IS NOT NULL AND external_url <> ''`);
|
|
367
|
+
db.exec("ALTER TABLE agent_sessions DROP COLUMN external_url");
|
|
368
|
+
}
|
|
369
|
+
for (const [retired, replacement] of RETIRED_AGENT_SESSION_STATUSES) {
|
|
370
|
+
db.prepare("UPDATE agent_sessions SET status = ? WHERE status = ?").run(replacement, retired);
|
|
371
|
+
}
|
|
323
372
|
}
|
|
324
373
|
export function resetDatabase(db) {
|
|
325
374
|
db.exec(RESET_SQL);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/db.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,CAAC;IACrE,CAAC;AACH,CAAC"}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import type { LinearAgentActivity, LinearAgentSession } from "../types.js";
|
|
1
|
+
import type { LinearAgentActivity, LinearAgentSession, LinearAgentSessionExternalUrl } from "../types.js";
|
|
2
2
|
import type { ActorContext, LinearDomain } from "./linear-domain.js";
|
|
3
3
|
export declare function listAgentSessions(domain: LinearDomain): LinearAgentSession[];
|
|
4
4
|
export declare function getAgentSession(domain: LinearDomain, ref: string): LinearAgentSession | null;
|
|
5
|
-
export
|
|
5
|
+
export type AgentSessionOnIssueInput = {
|
|
6
6
|
issueId: string;
|
|
7
|
-
|
|
7
|
+
appUserId?: string;
|
|
8
8
|
plan?: string | null;
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export
|
|
9
|
+
externalUrls?: LinearAgentSessionExternalUrl[] | null;
|
|
10
|
+
};
|
|
11
|
+
export type AgentSessionOnCommentInput = {
|
|
12
12
|
commentId: string;
|
|
13
|
-
|
|
13
|
+
appUserId?: string;
|
|
14
14
|
plan?: string | null;
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
export
|
|
18
|
-
|
|
15
|
+
externalUrls?: LinearAgentSessionExternalUrl[] | null;
|
|
16
|
+
};
|
|
17
|
+
export type AgentSessionPatch = {
|
|
18
|
+
status?: string;
|
|
19
19
|
plan?: string | null;
|
|
20
|
-
|
|
21
|
-
}
|
|
20
|
+
externalUrls?: LinearAgentSessionExternalUrl[] | null;
|
|
21
|
+
};
|
|
22
|
+
export declare function createAgentSessionOnIssue(domain: LinearDomain, input: AgentSessionOnIssueInput, actor?: ActorContext): Promise<LinearAgentSession>;
|
|
23
|
+
export declare function createAgentSessionOnComment(domain: LinearDomain, input: AgentSessionOnCommentInput, actor?: ActorContext): Promise<LinearAgentSession>;
|
|
24
|
+
export declare function updateAgentSession(domain: LinearDomain, id: string, input: AgentSessionPatch, actor?: ActorContext): LinearAgentSession;
|
|
22
25
|
export declare function createAgentActivity(domain: LinearDomain, input: {
|
|
23
26
|
sessionId: string;
|
|
24
27
|
type: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
import { notFound } from "../errors.js";
|
|
3
|
-
import { assertBody, normalizeActivityType,
|
|
3
|
+
import { assertBody, normalizeActivityType, normalizeSessionStatus } from "./normalize.js";
|
|
4
4
|
import { mapAgentActivity, mapAgentSession } from "./rows.js";
|
|
5
5
|
import { emitWebhook } from "./webhooks.js";
|
|
6
6
|
export function listAgentSessions(domain) {
|
|
@@ -14,20 +14,20 @@ export async function createAgentSessionOnIssue(domain, input, actor = {}) {
|
|
|
14
14
|
domain.requireScopes(actor, ["write"]);
|
|
15
15
|
const issue = domain.requireIssue(input.issueId);
|
|
16
16
|
const viewer = domain.resolveViewer(actor);
|
|
17
|
-
const agent = (input.
|
|
17
|
+
const agent = (input.appUserId ? domain.requireUser(input.appUserId) : null) ??
|
|
18
18
|
domain.listUsers().find((u) => u.app) ??
|
|
19
19
|
viewer;
|
|
20
20
|
const now = domain.tick();
|
|
21
21
|
const id = domain.nextId("agent_session");
|
|
22
22
|
domain.db
|
|
23
|
-
.prepare(`INSERT INTO agent_sessions(id, issue_id, comment_id,
|
|
23
|
+
.prepare(`INSERT INTO agent_sessions(id, issue_id, comment_id, app_user_id, status, plan, external_urls_json, created_at, updated_at)
|
|
24
24
|
VALUES (?,?,?,?,?,?,?,?,?)`)
|
|
25
|
-
.run(id, issue.id, null, agent.id, "pending", input.plan ?? null, input.
|
|
25
|
+
.run(id, issue.id, null, agent.id, "pending", input.plan ?? null, JSON.stringify(input.externalUrls ?? []), now, now);
|
|
26
26
|
const session = domain.requireAgentSession(id);
|
|
27
27
|
await emitWebhook(domain, {
|
|
28
28
|
type: "AgentSessionEvent",
|
|
29
29
|
action: "created",
|
|
30
|
-
data: { id: session.id, issueId: issue.id,
|
|
30
|
+
data: { id: session.id, issueId: issue.id, status: session.status },
|
|
31
31
|
actor: viewer,
|
|
32
32
|
teamId: issue.teamId,
|
|
33
33
|
});
|
|
@@ -39,29 +39,33 @@ export async function createAgentSessionOnComment(domain, input, actor = {}) {
|
|
|
39
39
|
const comment = domain.requireComment(input.commentId);
|
|
40
40
|
const issue = domain.requireIssue(comment.issueId);
|
|
41
41
|
const viewer = domain.resolveViewer(actor);
|
|
42
|
-
const agent = (input.
|
|
42
|
+
const agent = (input.appUserId ? domain.requireUser(input.appUserId) : null) ??
|
|
43
43
|
domain.listUsers().find((u) => u.app) ??
|
|
44
44
|
viewer;
|
|
45
45
|
const now = domain.tick();
|
|
46
46
|
const id = domain.nextId("agent_session");
|
|
47
47
|
domain.db
|
|
48
|
-
.prepare(`INSERT INTO agent_sessions(id, issue_id, comment_id,
|
|
48
|
+
.prepare(`INSERT INTO agent_sessions(id, issue_id, comment_id, app_user_id, status, plan, external_urls_json, created_at, updated_at)
|
|
49
49
|
VALUES (?,?,?,?,?,?,?,?,?)`)
|
|
50
|
-
.run(id, issue.id, comment.id, agent.id, "pending", input.plan ?? null, input.
|
|
50
|
+
.run(id, issue.id, comment.id, agent.id, "pending", input.plan ?? null, JSON.stringify(input.externalUrls ?? []), now, now);
|
|
51
51
|
return domain.requireAgentSession(id);
|
|
52
52
|
}
|
|
53
53
|
export function updateAgentSession(domain, id, input, actor = {}) {
|
|
54
54
|
domain.requireScopes(actor, ["write"]);
|
|
55
55
|
const session = domain.requireAgentSession(id);
|
|
56
56
|
const now = domain.tick();
|
|
57
|
+
// Nullable fields are tri-state: `undefined` (absent, or explicitly passed as undefined)
|
|
58
|
+
// means "leave alone", `null` means "clear". Never test presence with `in` here — callers
|
|
59
|
+
// build this patch as an object literal with every key present, so `in` would clear
|
|
60
|
+
// every field the caller did not mention (F-1166).
|
|
57
61
|
domain.db
|
|
58
62
|
.prepare(`UPDATE agent_sessions SET
|
|
59
|
-
|
|
63
|
+
status = COALESCE(?, status),
|
|
60
64
|
plan = CASE WHEN ? THEN ? ELSE plan END,
|
|
61
|
-
|
|
65
|
+
external_urls_json = CASE WHEN ? THEN ? ELSE external_urls_json END,
|
|
62
66
|
updated_at = ?
|
|
63
67
|
WHERE id = ?`)
|
|
64
|
-
.run(input.
|
|
68
|
+
.run(input.status ? normalizeSessionStatus(input.status) : null, input.plan !== undefined ? 1 : 0, input.plan ?? null, input.externalUrls !== undefined ? 1 : 0, JSON.stringify(input.externalUrls ?? []), now, session.id);
|
|
65
69
|
return domain.requireAgentSession(session.id);
|
|
66
70
|
}
|
|
67
71
|
export async function createAgentActivity(domain, input, actor = {}) {
|
|
@@ -81,7 +85,7 @@ export async function createAgentActivity(domain, input, actor = {}) {
|
|
|
81
85
|
await emitWebhook(domain, {
|
|
82
86
|
type: "AgentSessionEvent",
|
|
83
87
|
action: "prompted",
|
|
84
|
-
data: { id: session.id,
|
|
88
|
+
data: { id: session.id, status: session.status },
|
|
85
89
|
actor: viewer,
|
|
86
90
|
teamId: session.issueId ? domain.requireIssue(session.issueId).teamId : null,
|
|
87
91
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/domain/agents.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/domain/agents.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAMxC,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE3F,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAA+C,MAAM,WAAW,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,MAAoB;IACpD,OACE,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,sDAAsD,CAAC,CAAC,GA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CAAC,MAAM,EAAE;YAChD,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;SAC7E,CAAC,CAAC;IACL,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC7C,IAAI,CAAC,QAAQ;QAAE,QAAQ,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAC3D,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAoB,EAAE,GAAW;IAChE,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,6CAA6C,CAAC,CAAC,GAAG,CAAC,GAAG,CAEvE,CAAC;IACd,OAAO,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAoB,EAAE,SAAiB;IACzE,OACE,MAAM,CAAC,EAAE;SACN,OAAO,CAAC,6EAA6E,CAAC;SACtF,GAAG,CAAC,SAAS,CACjB,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -46,7 +46,7 @@ export async function createComment(domain, input, actor = {}) {
|
|
|
46
46
|
if (mentionsAppUser(comment.body)) {
|
|
47
47
|
const appUser = domain.listUsers().find((u) => u.app && comment.body.includes(u.displayName));
|
|
48
48
|
if (appUser) {
|
|
49
|
-
await domain.createAgentSessionOnComment({ commentId: comment.id,
|
|
49
|
+
await domain.createAgentSessionOnComment({ commentId: comment.id, appUserId: appUser.id }, actor);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
return comment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments.js","sourceR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