@mmon-co/ncept-default-theory 1.1.0 → 3.0.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/LICENSE +105 -21
- package/README.md +6 -5
- package/dist/chat.d.ts +1 -1
- package/dist/chat.js +39 -9
- package/dist/event.js +14 -8
- package/dist/implementation.d.ts +33 -24
- package/dist/implementation.js +3 -2
- package/dist/index.d.ts +41 -31
- package/dist/index.js +2 -1
- package/dist/migrations.d.ts +23 -0
- package/dist/migrations.js +152 -0
- package/dist/opening.d.ts +1 -1
- package/dist/opening.js +2 -2
- package/dist/outcomes.d.ts +9 -24
- package/dist/outcomes.js +16 -47
- package/dist/path.d.ts +3 -1
- package/dist/path.js +14 -10
- package/dist/release.d.ts +1 -1
- package/dist/release.js +1 -1
- package/dist/schedules.d.ts +51 -0
- package/dist/schedules.js +170 -0
- package/dist/skills/sources.d.ts +6 -6
- package/dist/skills/sources.js +6 -6
- package/dist/state.d.ts +3 -21
- package/dist/state.js +20 -80
- package/dist/tags.d.ts +1 -0
- package/dist/tags.js +7 -8
- package/dist/tools.js +7 -15
- package/package.json +15 -4
package/LICENSE
CHANGED
|
@@ -1,21 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 mmon Co.
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Default Theory
|
|
2
2
|
|
|
3
|
-
`@mmon-co/ncept-default-theory` implements Core's `Theory` interface. It depends on `@mmon-co/ncept-core` through public exports, just as a third-party Theory does; Core does not depend on it. The web Application selects it explicitly.
|
|
3
|
+
`@mmon-co/ncept-default-theory` implements Core's `Theory` interface. It depends on `@mmon-co/ncept-core` through public exports, just as a third-party Theory does; Core does not depend on it. The web Application selects it explicitly. Node retention schedules, acquisition, Mission futures, tutor Programs and pedagogical Skills live here. Hosts supply persistence, model calls and their own mechanics.
|
|
4
4
|
|
|
5
5
|
## Use
|
|
6
6
|
|
|
7
|
-
Import `defaultTheory` and `DEFAULT_THEORY_REQUIREMENT` from `@mmon-co/ncept-default-theory`. The executable
|
|
7
|
+
Import `defaultTheory` and `DEFAULT_THEORY_REQUIREMENT` from `@mmon-co/ncept-default-theory`. The executable has identity `default`, a semver version with build metadata, and a new-Profile range pinned to its current minor. Version 1.4 migrates boolean `pedagogy:review` metadata to tagged schedules on live Patch heads. `fsrs` schedules memory checks, `interval` checks a maintained state or capability after its named number of days, and `never` skips Review. An unset milestone uses `never`; other unset Nodes use `fsrs`.
|
|
8
8
|
|
|
9
9
|
The root exports the implementation's public operations and types. Focused exports are `@mmon-co/ncept-default-theory/path`, `/state`, `/messages` and `/outcomes`.
|
|
10
10
|
|
|
@@ -22,13 +22,13 @@ The Skills' Markdown is the source. `build-skills.ts` embeds it in Git-ignored `
|
|
|
22
22
|
|
|
23
23
|
`npm pack --dry-run` from this directory runs `prepack`, rebuilding Core and this package. The archive contains only `dist/`, this README, `LICENSE` and its manifest. Its Core dependency is a registry semver range, not a workspace-only reference.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Licensed under the Functional Source License 1.1 with Apache-2.0 as its future licence; see [LICENSE](LICENSE). You may use, change and redistribute this package for anything except offering others a commercial product or service that substitutes for it or does substantially the same thing; that includes selling a Theory derived from it. A learner may run it on their own machine, with or without a paid teacher, and a teacher may use it in their own work; hosting it for paying students is such a service. Each version becomes Apache-2.0 two years after it is made available. Versions up to 2.0.0 were published under MIT and remain so. A Theory written against Core's `Theory` interface without this package's code is not a derived work and takes whatever licence its author chooses. For other terms, write to yz@mmon.co.
|
|
26
26
|
|
|
27
27
|
## Stored-output version guard
|
|
28
28
|
|
|
29
29
|
`bun test packages/default-theory/test/stored-output.test.ts` compares a fixed graph and observation log with `test/snapshots/stored-output.<major>.<minor>.json`. The ordinary test suite and pre-integration gate run it too. It records tag membership on Nodes, Edges and the learner at several evidence prefixes and clocks, the `pedagogy:` keys those operations read, and observation payloads emitted by recording tools and outcome/day events. It does not record captions, rankings, readings, paths, prompts or build metadata. Like any fixture, it detects changes exercised by that graph and log, not every possible policy change.
|
|
30
30
|
|
|
31
|
-
A mismatch requires a minor (mechanical migration) or major (non-mechanical migration) bump to `DEFAULT_THEORY_REF` and the corresponding forward data migration. Changed criteria for applying the same tags count as stored-data changes, not patches. Generate the new version's snapshot after making that change. If the diff changes no stored data, refresh the existing snapshot instead:
|
|
31
|
+
A mismatch requires a minor (mechanical migration) or major (non-mechanical migration) bump to `DEFAULT_THEORY_REF` and the corresponding forward data migration. Changed criteria for applying the same tags count as stored-data changes, not patches; when nothing stored changes shape, the step declares no rewrite (`{ from, to }`), and hosts move each Profile's pin and discard its derived state without reading it. Generate the new version's snapshot after making that change. If the diff changes no stored data, refresh the existing snapshot instead:
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
34
|
UPDATE_DEFAULT_THEORY_STORED_OUTPUT=1 bun test packages/default-theory/test/stored-output.test.ts
|
|
@@ -45,7 +45,6 @@ Core's `Observation` envelope carries identity, time, scope, support and the pro
|
|
|
45
45
|
| Payload | Public type and guard from `@mmon-co/ncept-default-theory/outcomes` | Captured evidence |
|
|
46
46
|
| --- | --- | --- |
|
|
47
47
|
| `completion` | `CompletionOutcome`, `isCompletionOutcome` | Playground and scope, exact Node provenance, complete/incomplete and optional validity boundary |
|
|
48
|
-
| `recall` | `RecallOutcome`, `isRecallOutcome` | Card content and Nodes at retrieval, learner answer and recall grade |
|
|
49
48
|
| `quiz` | `QuizOutcome`, `isQuizOutcome` | Questions, choices and correct answers, selected/skipped responses and comments |
|
|
50
49
|
| `attempt` | `AttemptOutcome`, `isAttemptOutcome` | Problem and grading contract at opening, response, assessment, help and exact revision |
|
|
51
50
|
|
|
@@ -71,4 +70,6 @@ Record payload types are exported from `@mmon-co/ncept-default-theory/state` and
|
|
|
71
70
|
|
|
72
71
|
Public guards include `isDemonstration`, `isRetrievalOpenerDemonstration`, `isLapse`, `isGrade`, `isReviewPass`, `isFeatureUse`, `isTeaching`, `isClaim`, `isRetraction`, `isHoming` and `isMemory`. `isDefaultObservation` checks producing-Theory attribution only; it is not a payload validator. `MemorySummaryPayload` and `Interpretation` have exported types but no standalone public guards. Other Theories choose which kinds they understand and preserve unread observations when exchanging a Profile.
|
|
73
72
|
|
|
73
|
+
Queued repetitions emit `attempt` too; their four ratings and latency belong to the queue's scheduling history. Version 1.1 migrates historical recall captures to Problems, freezing the former front/back unaided rule as observed assistance. Existing Demonstrations retain their identities, attribution and readings.
|
|
74
|
+
|
|
74
75
|
Observation-contract changes follow the Theory's semver and forward-migration rules: a patch needs no dependent-data migration, a minor permits a mechanical migration, and a major requires a non-mechanical one. This extraction preserves the existing payloads and validators unchanged.
|
package/dist/chat.d.ts
CHANGED
package/dist/chat.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { renderSpeech } from "@mmon-co/ncept-core/theory/speaker";
|
|
2
2
|
/* eslint-disable require-yield -- Chat setup is a zero-effect synchronous Program. */
|
|
3
|
-
import { lastMetadataContribution, metadataSetsForEntity, NODE_CRITERION_PROPERTY, NODE_LABEL_PROPERTY, PEDAGOGY_OPENING_PROPERTY, PEDAGOGY_FIRST_MESSAGE_PROPERTY, nodeCascadedProperty, } from "@mmon-co/ncept-core/patch";
|
|
3
|
+
import { provenanceOf, lastMetadataContribution, metadataSetsForEntity, NODE_CRITERION_PROPERTY, NODE_LABEL_PROPERTY, PEDAGOGY_OPENING_PROPERTY, PEDAGOGY_FIRST_MESSAGE_PROPERTY, nodeCascadedProperty, } from "@mmon-co/ncept-core/patch";
|
|
4
4
|
import { CATALOG_MODE_TOOLS, CATALOG_MODE_TITLES, CATALOG_MODE_METADATA_KEYS } from "./catalog-contract.js";
|
|
5
5
|
import { isDefaultObservation, isMemory, memoryDefault } from "./state.js";
|
|
6
6
|
import { skillBody, skillResources, skillsForMode, tutorSystemPrompt } from "./skills.js";
|
|
7
7
|
import { catalogToolsForMode } from "./catalog.js";
|
|
8
8
|
import { evaluationContext, evaluateWatchedReply } from "./evaluation.js";
|
|
9
9
|
import { lessonOpening, openingLanguage } from "./opening.js";
|
|
10
|
+
import { nodeReviewSchedule } from "./path.js";
|
|
10
11
|
const COMMON_CONCEPT_PATCH_PROPERTY = "app:common-concept";
|
|
11
12
|
const RAISE_WHEN_PROPERTY = "pedagogy:raise-when";
|
|
12
|
-
const
|
|
13
|
+
const DOCS_URL_PROPERTY = "app:docs-url";
|
|
13
14
|
function metadataValue(ctx, node, property) {
|
|
14
15
|
const candidates = metadataSetsForEntity(ctx.graph, { kind: "node", id: node }).flatMap((set) => {
|
|
15
16
|
if (!(property in set.properties))
|
|
16
17
|
return [];
|
|
17
|
-
const source = ctx.graph.provenance.metadataProperties
|
|
18
|
+
const source = provenanceOf(ctx.graph.provenance.metadataProperties, set.id)?.[property]?.at(-1);
|
|
18
19
|
if (source === undefined)
|
|
19
20
|
throw new Error(`Missing provenance for ${property} on ${node}`);
|
|
20
21
|
return [{ value: set.properties[property], source }];
|
|
@@ -25,7 +26,7 @@ function officialDocuments(ctx) {
|
|
|
25
26
|
const officialPatches = new Set(ctx.graph.patchOrder.flatMap(({ identity }) => ctx.graph.patchMetadata[identity]?.properties[COMMON_CONCEPT_PATCH_PROPERTY] === true ? [identity] : []));
|
|
26
27
|
return ctx.graph.nodes.flatMap(({ id }) => {
|
|
27
28
|
if (!id.startsWith("node-mmon-") ||
|
|
28
|
-
!ctx.graph.provenance.nodes
|
|
29
|
+
!provenanceOf(ctx.graph.provenance.nodes, id)?.some(({ patch }) => officialPatches.has(patch.identity)))
|
|
29
30
|
return [];
|
|
30
31
|
const label = metadataValue(ctx, id, NODE_LABEL_PROPERTY);
|
|
31
32
|
const summary = metadataValue(ctx, id, NODE_CRITERION_PROPERTY);
|
|
@@ -46,6 +47,18 @@ function officialDocuments(ctx) {
|
|
|
46
47
|
];
|
|
47
48
|
});
|
|
48
49
|
}
|
|
50
|
+
function docsUrl(ctx, node) {
|
|
51
|
+
const url = metadataValue(ctx, node, DOCS_URL_PROPERTY);
|
|
52
|
+
return typeof url === "string" && url.trim() !== "" ? url : undefined;
|
|
53
|
+
}
|
|
54
|
+
function linkedDocuments(ctx, documents, messages) {
|
|
55
|
+
// The label also recognizes links kept in memory from before the public docs.
|
|
56
|
+
const labels = new Set(messages.flatMap((text) => [...text.matchAll(/(?<!!)\[([^\]]+)\]\(\s*[^\s)]+[^)]*\)/g)].map((match) => match[1])));
|
|
57
|
+
return documents.filter(({ node, label }) => {
|
|
58
|
+
const url = docsUrl(ctx, node);
|
|
59
|
+
return labels.has(label) || (url !== undefined && messages.some((text) => text.includes(url)));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
49
62
|
/** Exclude Document links already carried by tutor text, in this conversation or a closed Session. */
|
|
50
63
|
function recommendableAffordances(ctx, documents) {
|
|
51
64
|
const told = [
|
|
@@ -54,15 +67,17 @@ function recommendableAffordances(ctx, documents) {
|
|
|
54
67
|
? observation.payload.entries.filter(({ speaker }) => speaker.kind === "tutor").map(({ text }) => text)
|
|
55
68
|
: []),
|
|
56
69
|
];
|
|
70
|
+
const offered = new Set(linkedDocuments(ctx, documents, told).map(({ node }) => node));
|
|
57
71
|
return documents.flatMap((document) => {
|
|
58
72
|
const state = ctx.state.nodes[document.node];
|
|
59
73
|
const raiseWhen = metadataValue(ctx, document.node, RAISE_WHEN_PROPERTY);
|
|
60
|
-
const documentUrl =
|
|
61
|
-
if (
|
|
74
|
+
const documentUrl = docsUrl(ctx, document.node);
|
|
75
|
+
if (documentUrl === undefined ||
|
|
76
|
+
state === undefined ||
|
|
62
77
|
state.featureUses.length !== 0 ||
|
|
63
78
|
typeof raiseWhen !== "string" ||
|
|
64
79
|
raiseWhen.trim() === "" ||
|
|
65
|
-
|
|
80
|
+
offered.has(document.node))
|
|
66
81
|
return [];
|
|
67
82
|
return [{ ...document, raiseWhen, documentUrl }];
|
|
68
83
|
});
|
|
@@ -128,18 +143,33 @@ function* setup(ctx, mode) {
|
|
|
128
143
|
if (!ctx.graph.nodes.some(({ id }) => id === node))
|
|
129
144
|
throw new Error(`Missing Node ${node}`);
|
|
130
145
|
const prompt = tutorSystemPrompt(mode);
|
|
146
|
+
const offered = linkedDocuments(ctx, officialDocuments(ctx), ctx.tutorMessages ?? []);
|
|
147
|
+
const entry = ctx.entry;
|
|
148
|
+
const intervalNodes = entry?.kind === "review"
|
|
149
|
+
? entry.nodes.filter((node) => nodeReviewSchedule(ctx.graph, node).kind === "interval")
|
|
150
|
+
: [];
|
|
131
151
|
return {
|
|
132
152
|
prompt,
|
|
133
153
|
context: [
|
|
134
154
|
...evaluationContext(ctx),
|
|
135
155
|
tutorOpening(ctx),
|
|
156
|
+
...(offered.length
|
|
157
|
+
? [
|
|
158
|
+
`Application help already offered in this Session (once-only asides):\n${JSON.stringify(offered)}\nKeep subsequent replies on the learner's task unless they ask for more application help.`,
|
|
159
|
+
]
|
|
160
|
+
: []),
|
|
136
161
|
ctx.about.length
|
|
137
162
|
? `This Session is attached to ${ctx.about.join(", ")}. Current Node memory (other Sessions' spans and Records; use theory {name:'memory',input:{node}} for more):\n\n${scopedMemory(ctx) || "(none)"}`
|
|
138
163
|
: "This Session is attached to no Nodes; name Nodes explicitly where a tool needs them.",
|
|
139
164
|
...(ctx.entry === undefined ? [] : [`Session opening (host-resolved facts):\n${JSON.stringify(ctx.entry)}`]),
|
|
140
165
|
...(ctx.missions?.length ? [`Current Missions (context data):\n${JSON.stringify(ctx.missions)}`] : []),
|
|
141
|
-
...(
|
|
142
|
-
? [
|
|
166
|
+
...(entry?.kind === "review"
|
|
167
|
+
? [
|
|
168
|
+
`Current Review (frozen batch; check retention, not teach):\n${JSON.stringify({
|
|
169
|
+
...entry,
|
|
170
|
+
...(intervalNodes.length > 0 ? { intervalNodes } : {}),
|
|
171
|
+
})}`,
|
|
172
|
+
]
|
|
143
173
|
: []),
|
|
144
174
|
...(ctx.lesson === undefined
|
|
145
175
|
? []
|
package/dist/event.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { renderSpeech } from "@mmon-co/ncept-core/theory/speaker";
|
|
2
2
|
import { judge, isObservationId, read, write, } from "@mmon-co/ncept-core/observations";
|
|
3
3
|
import { isNodeId, sameExactPatchRef } from "@mmon-co/ncept-core/patch";
|
|
4
|
-
import { isAttemptOutcome, isQuizOutcome,
|
|
4
|
+
import { isAttemptOutcome, isQuizOutcome, practiceAttempts, problemAttempts } from "./outcomes.js";
|
|
5
5
|
import { stateDefault, homeDefaultRecords, isCompletionOutcome, projectGraphChange, homingCandidates, expandNodeMemory, isGrade, nodeDayEvidence, defaultNodeCompletion, completionNodeRef, } from "./state.js";
|
|
6
6
|
/** Entries after a Node's last summary; exactly eight remain verbatim. */
|
|
7
7
|
const MEMORY_COMPACTION_THRESHOLD = 8;
|
|
@@ -287,7 +287,7 @@ export function* event(input, ctx) {
|
|
|
287
287
|
}
|
|
288
288
|
if (object(payload) && payload.kind === "completion")
|
|
289
289
|
throw new Error("Invalid completion outcome");
|
|
290
|
-
if (!
|
|
290
|
+
if (!isQuizOutcome(payload) && !isAttemptOutcome(payload)) {
|
|
291
291
|
if (typeof input.payload === "object" &&
|
|
292
292
|
input.payload !== null &&
|
|
293
293
|
"kind" in input.payload &&
|
|
@@ -366,20 +366,26 @@ export function* event(input, ctx) {
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
const current = stateDefault(ctx.graph, yield* read.observations({}), ctx.now);
|
|
369
|
+
const summaries = new Map();
|
|
369
370
|
for (const node of new Set(input.about)) {
|
|
370
371
|
const memory = current.memories[node];
|
|
371
372
|
if (memory === undefined ||
|
|
372
373
|
memory.entries.filter((entry) => entry.kind === "entry").length <= MEMORY_COMPACTION_THRESHOLD)
|
|
373
374
|
continue;
|
|
374
|
-
const
|
|
375
|
+
const renderedText = memory.entries
|
|
375
376
|
.map((entry) => entry.kind === "summary"
|
|
376
377
|
? `[summary through ${expandNodeMemory(memory, entry).at(-1)?.position}; Material sources ${JSON.stringify(entry.materialSources)}] quoted derivative: ${JSON.stringify(entry.text)}`
|
|
377
378
|
: `[${entry.at}] ${renderSpeech(entry.speaker, entry.text)}`)
|
|
378
|
-
.join("\n\n")
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
379
|
+
.join("\n\n");
|
|
380
|
+
let text = summaries.get(renderedText);
|
|
381
|
+
if (text === undefined) {
|
|
382
|
+
text = yield* judge(SUMMARIZE, renderedText, { type: "string" }, (raw) => {
|
|
383
|
+
if (typeof raw !== "string")
|
|
384
|
+
throw new Error("Memory summary must be a string");
|
|
385
|
+
return raw;
|
|
386
|
+
});
|
|
387
|
+
summaries.set(renderedText, text);
|
|
388
|
+
}
|
|
383
389
|
const sources = [...new Set(memory.originals.map((entry) => entry.observation))];
|
|
384
390
|
const dependencies = [
|
|
385
391
|
...new Set(memory.originals.flatMap((entry) => [
|
package/dist/implementation.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describeDefaultObservation } from "./history.js";
|
|
2
2
|
import { event } from "./event.js";
|
|
3
|
-
import { isAttemptOutcome, isQuizOutcome
|
|
3
|
+
import { isAttemptOutcome, isQuizOutcome } from "./outcomes.js";
|
|
4
4
|
import { initDefaultState, isCompletionOutcome } from "./state.js";
|
|
5
5
|
import { projectDefault } from "./tags.js";
|
|
6
6
|
import { pathDefault } from "./path.js";
|
|
@@ -8,7 +8,17 @@ import { progressDefault, estimateDefault, prepareEstimateDefault } from "./read
|
|
|
8
8
|
/** The single default implementation assembly. */
|
|
9
9
|
export declare const implementation: {
|
|
10
10
|
id: "default";
|
|
11
|
-
version: "1.
|
|
11
|
+
version: "1.4.0";
|
|
12
|
+
migrations: readonly Readonly<{
|
|
13
|
+
from: import("@mmon-co/ncept-core/theory").TheoryDataVersion;
|
|
14
|
+
to: import("@mmon-co/ncept-core/theory").TheoryDataVersion;
|
|
15
|
+
migratePatch?(content: import("@mmon-co/ncept-core").PatchContent, graphs?: {
|
|
16
|
+
basesChanged: boolean;
|
|
17
|
+
resolve: (candidate?: import("@mmon-co/ncept-core").PatchContent) => import("@mmon-co/ncept-core").ResolvedGraph;
|
|
18
|
+
}): import("@mmon-co/ncept-core").PatchContent;
|
|
19
|
+
migrate?(profile: import("@mmon-co/ncept-core").Profile): import("@mmon-co/ncept-core").Profile;
|
|
20
|
+
migrateOutcome?(payload: unknown, profile: import("@mmon-co/ncept-core").Profile): unknown;
|
|
21
|
+
}>[];
|
|
12
22
|
initState: typeof initDefaultState;
|
|
13
23
|
project: typeof projectDefault;
|
|
14
24
|
progress: typeof progressDefault;
|
|
@@ -19,13 +29,12 @@ export declare const implementation: {
|
|
|
19
29
|
tags: readonly [...string[], "item-outcomes", "instability", "unused", "coarse", "lesson-split", "self-report", "edge-contradiction", "homeless"];
|
|
20
30
|
outcomes: {
|
|
21
31
|
completion: typeof isCompletionOutcome;
|
|
22
|
-
recall: typeof isRecallOutcome;
|
|
23
32
|
quiz: typeof isQuizOutcome;
|
|
24
33
|
attempt: typeof isAttemptOutcome;
|
|
25
34
|
};
|
|
26
35
|
chat: {
|
|
27
|
-
open: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>, mode?: "empty" | "charting" | "authoring" | "lesson") => import("@mmon-co/ncept-core
|
|
28
|
-
turn: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>, mode?: "empty" | "charting" | "authoring" | "lesson") => import("@mmon-co/ncept-core
|
|
36
|
+
open: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>, mode?: "empty" | "charting" | "authoring" | "lesson") => import("@mmon-co/ncept-core").Program<import("@mmon-co/ncept-core/theory").ChatSetup<import("./state.js").DefaultState>>;
|
|
37
|
+
turn: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>, mode?: "empty" | "charting" | "authoring" | "lesson") => import("@mmon-co/ncept-core").Program<import("@mmon-co/ncept-core/theory").ChatSetup<import("./state.js").DefaultState>>;
|
|
29
38
|
reply: typeof import("./evaluation.js").evaluateWatchedReply;
|
|
30
39
|
};
|
|
31
40
|
modes: {
|
|
@@ -41,15 +50,15 @@ export declare const implementation: {
|
|
|
41
50
|
mode: string;
|
|
42
51
|
then: "here";
|
|
43
52
|
}[];
|
|
44
|
-
setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core
|
|
53
|
+
setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core").Program<Readonly<{
|
|
45
54
|
prompt: string;
|
|
46
55
|
context?: string;
|
|
47
56
|
tools: readonly Readonly<{
|
|
48
57
|
name: string;
|
|
49
58
|
description: string;
|
|
50
|
-
schema: import("@mmon-co/ncept-core
|
|
59
|
+
schema: import("@mmon-co/ncept-core").JsonSchema;
|
|
51
60
|
members?: readonly Readonly</*elided*/ any>[] | undefined;
|
|
52
|
-
run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core
|
|
61
|
+
run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core").Program<unknown>;
|
|
53
62
|
}>[];
|
|
54
63
|
skills: readonly Readonly<{
|
|
55
64
|
name: string;
|
|
@@ -68,7 +77,7 @@ export declare const implementation: {
|
|
|
68
77
|
}[];
|
|
69
78
|
entry: {
|
|
70
79
|
required: false;
|
|
71
|
-
kinds: ("mission" | "checkpoint" | "
|
|
80
|
+
kinds: ("mission" | "checkpoint" | "target" | "goal")[];
|
|
72
81
|
};
|
|
73
82
|
capabilities: readonly import("@mmon-co/ncept-core/theory").HostCapability[];
|
|
74
83
|
switches: {
|
|
@@ -78,15 +87,15 @@ export declare const implementation: {
|
|
|
78
87
|
kind: "brief";
|
|
79
88
|
};
|
|
80
89
|
}[];
|
|
81
|
-
setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core
|
|
90
|
+
setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core").Program<Readonly<{
|
|
82
91
|
prompt: string;
|
|
83
92
|
context?: string;
|
|
84
93
|
tools: readonly Readonly<{
|
|
85
94
|
name: string;
|
|
86
95
|
description: string;
|
|
87
|
-
schema: import("@mmon-co/ncept-core
|
|
96
|
+
schema: import("@mmon-co/ncept-core").JsonSchema;
|
|
88
97
|
members?: readonly Readonly</*elided*/ any>[] | undefined;
|
|
89
|
-
run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core
|
|
98
|
+
run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core").Program<unknown>;
|
|
90
99
|
}>[];
|
|
91
100
|
skills: readonly Readonly<{
|
|
92
101
|
name: string;
|
|
@@ -105,15 +114,15 @@ export declare const implementation: {
|
|
|
105
114
|
};
|
|
106
115
|
capabilities: readonly import("@mmon-co/ncept-core/theory").HostCapability[];
|
|
107
116
|
switches: never[];
|
|
108
|
-
setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core
|
|
117
|
+
setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core").Program<Readonly<{
|
|
109
118
|
prompt: string;
|
|
110
119
|
context?: string;
|
|
111
120
|
tools: readonly Readonly<{
|
|
112
121
|
name: string;
|
|
113
122
|
description: string;
|
|
114
|
-
schema: import("@mmon-co/ncept-core
|
|
123
|
+
schema: import("@mmon-co/ncept-core").JsonSchema;
|
|
115
124
|
members?: readonly Readonly</*elided*/ any>[] | undefined;
|
|
116
|
-
run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core
|
|
125
|
+
run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core").Program<unknown>;
|
|
117
126
|
}>[];
|
|
118
127
|
skills: readonly Readonly<{
|
|
119
128
|
name: string;
|
|
@@ -147,15 +156,15 @@ export declare const implementation: {
|
|
|
147
156
|
focus: string;
|
|
148
157
|
};
|
|
149
158
|
})[];
|
|
150
|
-
setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core
|
|
159
|
+
setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core").Program<Readonly<{
|
|
151
160
|
prompt: string;
|
|
152
161
|
context?: string;
|
|
153
162
|
tools: readonly Readonly<{
|
|
154
163
|
name: string;
|
|
155
164
|
description: string;
|
|
156
|
-
schema: import("@mmon-co/ncept-core
|
|
165
|
+
schema: import("@mmon-co/ncept-core").JsonSchema;
|
|
157
166
|
members?: readonly Readonly</*elided*/ any>[] | undefined;
|
|
158
|
-
run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core
|
|
167
|
+
run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core").Program<unknown>;
|
|
159
168
|
}>[];
|
|
160
169
|
skills: readonly Readonly<{
|
|
161
170
|
name: string;
|
|
@@ -166,16 +175,16 @@ export declare const implementation: {
|
|
|
166
175
|
}>>;
|
|
167
176
|
};
|
|
168
177
|
};
|
|
169
|
-
noEventHook: (input: import("@mmon-co/ncept-core
|
|
178
|
+
noEventHook: (input: import("@mmon-co/ncept-core").PlatformEvent) => input is {
|
|
170
179
|
readonly kind: "surface.open";
|
|
171
|
-
readonly surface: import("@mmon-co/ncept-core
|
|
180
|
+
readonly surface: import("@mmon-co/ncept-core").SurfaceId;
|
|
172
181
|
readonly format: string;
|
|
173
|
-
readonly about: readonly import("@mmon-co/ncept-core
|
|
182
|
+
readonly about: readonly import("@mmon-co/ncept-core").NodeId[];
|
|
174
183
|
} | {
|
|
175
184
|
readonly kind: "object.put";
|
|
176
|
-
readonly object: import("@mmon-co/ncept-core
|
|
177
|
-
readonly meta: import("@mmon-co/ncept-core
|
|
178
|
-
readonly surface?: import("@mmon-co/ncept-core
|
|
185
|
+
readonly object: import("@mmon-co/ncept-core").ObjectId;
|
|
186
|
+
readonly meta: import("@mmon-co/ncept-core").ObjectMeta;
|
|
187
|
+
readonly surface?: import("@mmon-co/ncept-core").SurfaceId;
|
|
179
188
|
} | {
|
|
180
189
|
readonly kind: "mission";
|
|
181
190
|
readonly text: string;
|
package/dist/implementation.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { migrations } from "./migrations.js";
|
|
1
2
|
import { chat, modes } from "./chat.js";
|
|
2
3
|
import { describeDefaultObservation } from "./history.js";
|
|
3
4
|
import { event } from "./event.js";
|
|
4
|
-
import { isAttemptOutcome, isQuizOutcome
|
|
5
|
+
import { isAttemptOutcome, isQuizOutcome } from "./outcomes.js";
|
|
5
6
|
import { DEFAULT_THEORY_REF, initDefaultState, isCompletionOutcome } from "./state.js";
|
|
6
7
|
import { defaultTags, projectDefault } from "./tags.js";
|
|
7
8
|
import { pathDefault } from "./path.js";
|
|
@@ -10,6 +11,7 @@ import { progressDefault, estimateDefault, prepareEstimateDefault } from "./read
|
|
|
10
11
|
export const implementation = {
|
|
11
12
|
id: DEFAULT_THEORY_REF.theory,
|
|
12
13
|
version: DEFAULT_THEORY_REF.version,
|
|
14
|
+
migrations,
|
|
13
15
|
initState: initDefaultState,
|
|
14
16
|
project: projectDefault,
|
|
15
17
|
progress: progressDefault,
|
|
@@ -20,7 +22,6 @@ export const implementation = {
|
|
|
20
22
|
tags: defaultTags,
|
|
21
23
|
outcomes: {
|
|
22
24
|
completion: isCompletionOutcome,
|
|
23
|
-
recall: isRecallOutcome,
|
|
24
25
|
quiz: isQuizOutcome,
|
|
25
26
|
attempt: isAttemptOutcome,
|
|
26
27
|
},
|