Package net.thevpc.naru.impl.engine
Class NaruSessionImpl
java.lang.Object
net.thevpc.naru.impl.engine.NaruSessionImpl
- All Implemented Interfaces:
NaruSession,net.thevpc.nuts.elem.NToElement
-
Constructor Summary
ConstructorsConstructorDescriptionNaruSessionImpl(NaruAgent agent, net.thevpc.nuts.io.NPath projectDir, NaruInteraction interaction, boolean configureDefaults, NaruSessionListener sessionListener, Predicate<NaruDirective> directiveFilter, Predicate<NaruTool> toolFilter, Predicate<NaruToolTag> tagFilter) -
Method Summary
Modifier and TypeMethodDescriptionvoid_reportUsing(net.thevpc.nuts.io.NPath source) voidaddModelAlias(String alias, NaruModelConfig model) voidaddSessionListener(NaruSessionListener listener) voidaddUsageListener(NaruSessionUsageListener listener) agent()copy()voiddeliverInput(String line) Pushes a line of user input into the session.eventLog()net.thevpc.nuts.util.NOptional<NaruModelConfig>net.thevpc.nuts.util.NOptional<NaruModelConfig>findModel(NaruModelConfig keyOrName) net.thevpc.nuts.util.NOptional<NaruModelConfig>findModelAlias(String alias) net.thevpc.nuts.util.NOptional<NaruTask>findTask(long tid) long[]findTaskIdsByParent(long taskId) voidvoidfireChangedTask(long id) voidfireModelCallUsage(NaruModelKey model, long promptTokens, long completionTokens, long cacheWriteTokens, long cacheReadTokens, net.thevpc.nuts.time.NDuration duration) Announces a completed model call to every usage listener.longforegroundTaskId(long taskId) net.thevpc.nuts.util.NOptional<net.thevpc.nuts.elem.NElement>getProjectEnv(String key) intlongnet.thevpc.nuts.util.NOptional<Object>getSessionEnv(String key) booleanbooleanList<net.thevpc.nuts.io.NPath>listOverridablePaths(net.thevpc.nuts.io.NPath publicPath, net.thevpc.nuts.io.NPath privatePath, Predicate<String> nameFilter) net.thevpc.nuts.util.NOptional<NaruModelConfig>loadModelConfig(String modelName) voidlog(NaruLogMode mode, net.thevpc.nuts.text.NMsg s) voidlogStream(NaruLogMode mode, net.thevpc.nuts.text.NMsg fragment, boolean end) name()newTask(NaruTaskSpec taskBuilder) voidonInputRequested(NaruTask task) Called by the scheduler when a task becomes BLOCKED_ON_INPUT.voidonTaskStatusChanged(NaruTask task, NaruTaskStatus oldStatus, NaruTaskStatus newStatus) Dispatches a task status transition to session listeners.voidonTerminated(long tid) net.thevpc.nuts.io.NPathregistry()reload()voidremoveModelAlias(String alias) voidremoveSessionListener(NaruSessionListener listener) voidremoveUsageListener(NaruSessionUsageListener listener) voidreset(boolean preserveIdentity) net.thevpc.nuts.util.NOptional<NaruRoutine>routines()run()run(NaruTaskSpec spec) save()voidsaveModelConfig(String modelName, NaruModelConfig config) setListedModels(List<NaruModelKey> models) voidsetProjectEnv(String key, net.thevpc.nuts.elem.NElement value, NaruVisibility visibility) setSchedulerThreadCount(int schedulerThreadCount) setSchedulerThrottleDelayMs(long schedulerThrottleDelayMs) setSessionEnv(String key, Object value) setVisibility(NaruVisibility visibility) setWorkingDir(net.thevpc.nuts.io.NPath workingDir) start()stop()systemPrompt(String systemPrompt) tasks()throttleDelay(long ms) net.thevpc.nuts.elem.NElementunsetSessionEnv(String key) uuid()waitFor()net.thevpc.nuts.io.NPath
-
Constructor Details
-
NaruSessionImpl
public NaruSessionImpl(NaruAgent agent, net.thevpc.nuts.io.NPath projectDir, NaruInteraction interaction, boolean configureDefaults, NaruSessionListener sessionListener, Predicate<NaruDirective> directiveFilter, Predicate<NaruTool> toolFilter, Predicate<NaruToolTag> tagFilter)
-
-
Method Details
-
throttleDelay
- Specified by:
throttleDelayin interfaceNaruSession
-
getSchedulerThreadCount
public int getSchedulerThreadCount() -
setSchedulerThreadCount
-
getSchedulerThrottleDelayMs
public long getSchedulerThrottleDelayMs() -
setSchedulerThrottleDelayMs
-
scheduler
- Specified by:
schedulerin interfaceNaruSession
-
getVisibility
- Specified by:
getVisibilityin interfaceNaruSession
-
setVisibility
- Specified by:
setVisibilityin interfaceNaruSession
-
unsetSessionEnv
- Specified by:
unsetSessionEnvin interfaceNaruSession
-
tasks
- Specified by:
tasksin interfaceNaruSession
-
newTask
- Specified by:
newTaskin interfaceNaruSession
-
run
- Specified by:
runin interfaceNaruSession
-
run
- Specified by:
runin interfaceNaruSession
-
runCallbackExecutor
-
findTask
- Specified by:
findTaskin interfaceNaruSession
-
setSessionEnv
- Specified by:
setSessionEnvin interfaceNaruSession
-
getSessionEnv
- Specified by:
getSessionEnvin interfaceNaruSession
-
getProjectEnv
- Specified by:
getProjectEnvin interfaceNaruSession
-
setProjectEnv
public void setProjectEnv(String key, net.thevpc.nuts.elem.NElement value, NaruVisibility visibility) - Specified by:
setProjectEnvin interfaceNaruSession
-
name
- Specified by:
namein interfaceNaruSession
-
setName
- Specified by:
setNamein interfaceNaruSession
-
modelAliases
- Specified by:
modelAliasesin interfaceNaruSession
-
reversedModelAliases
- Specified by:
reversedModelAliasesin interfaceNaruSession
-
findModel
-
findModel
- Specified by:
findModelin interfaceNaruSession
-
listedModels
- Specified by:
listedModelsin interfaceNaruSession
-
setListedModels
- Specified by:
setListedModelsin interfaceNaruSession
-
removeModelAlias
- Specified by:
removeModelAliasin interfaceNaruSession
-
addModelAlias
- Specified by:
addModelAliasin interfaceNaruSession
-
findModelAlias
- Specified by:
findModelAliasin interfaceNaruSession
-
creationInstant
- Specified by:
creationInstantin interfaceNaruSession
-
modificationInstant
- Specified by:
modificationInstantin interfaceNaruSession
-
uuid
- Specified by:
uuidin interfaceNaruSession
-
fireChanged
public void fireChanged() -
copy
- Specified by:
copyin interfaceNaruSession
-
reset
- Specified by:
resetin interfaceNaruSession
-
saveSnapshot
- Specified by:
saveSnapshotin interfaceNaruSession
-
save
- Specified by:
savein interfaceNaruSession
-
load
- Specified by:
loadin interfaceNaruSession
-
reload
- Specified by:
reloadin interfaceNaruSession
-
restoreSnapshot
- Specified by:
restoreSnapshotin interfaceNaruSession
-
toElement
public net.thevpc.nuts.elem.NElement toElement()- Specified by:
toElementin interfaceNaruSession- Specified by:
toElementin interfacenet.thevpc.nuts.elem.NToElement
-
deliverInput
Pushes a line of user input into the session. This is how a headless host answers a question: it hands the text over whenever it arrives, from any thread, and the task that asked resumes.- Specified by:
deliverInputin interfaceNaruSession
-
onInputRequested
Called by the scheduler when a task becomes BLOCKED_ON_INPUT. The question is handed to the interaction, which decides whether that means blocking a terminal thread or pushing it to a browser. -
log
- Specified by:
login interfaceNaruSession
-
logStream
- Specified by:
logStreamin interfaceNaruSession
-
_reportUsing
public void _reportUsing(net.thevpc.nuts.io.NPath source) -
listOverridablePaths
-
workingDir
public net.thevpc.nuts.io.NPath workingDir()- Specified by:
workingDirin interfaceNaruSession
-
setWorkingDir
- Specified by:
setWorkingDirin interfaceNaruSession
-
projectDir
public net.thevpc.nuts.io.NPath projectDir()- Specified by:
projectDirin interfaceNaruSession
-
terminate
- Specified by:
terminatein interfaceNaruSession
-
hasMoreStatements
public boolean hasMoreStatements()- Specified by:
hasMoreStatementsin interfaceNaruSession
-
agent
- Specified by:
agentin interfaceNaruSession
-
sessionStoreManager
- Specified by:
sessionStoreManagerin interfaceNaruSession
-
registry
- Specified by:
registryin interfaceNaruSession
-
foregroundTaskId
public long foregroundTaskId()- Specified by:
foregroundTaskIdin interfaceNaruSession
-
foregroundTaskId
- Specified by:
foregroundTaskIdin interfaceNaruSession
-
start
- Specified by:
startin interfaceNaruSession
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceNaruSession
-
stop
- Specified by:
stopin interfaceNaruSession
-
addSessionListener
- Specified by:
addSessionListenerin interfaceNaruSession
-
addUsageListener
- Specified by:
addUsageListenerin interfaceNaruSession
-
removeUsageListener
- Specified by:
removeUsageListenerin interfaceNaruSession
-
fireModelCallUsage
public void fireModelCallUsage(NaruModelKey model, long promptTokens, long completionTokens, long cacheWriteTokens, long cacheReadTokens, net.thevpc.nuts.time.NDuration duration) Announces a completed model call to every usage listener.A listener that throws is skipped rather than allowed to fail the call it is only observing: metering and rate-limit reporting are side channels, and a broken one must not cost the user their answer.
-
reportProviderRateLimits
- Specified by:
reportProviderRateLimitsin interfaceNaruSession
-
removeSessionListener
- Specified by:
removeSessionListenerin interfaceNaruSession
-
waitFor
- Specified by:
waitForin interfaceNaruSession
-
systemPrompt
- Specified by:
systemPromptin interfaceNaruSession
-
systemPrompt
- Specified by:
systemPromptin interfaceNaruSession
-
onTerminated
public void onTerminated(long tid) -
onTaskStatusChanged
Dispatches a task status transition to session listeners.Note that
onTerminated(long)runs first for terminal states and unregisters the task, so a listener must use thetaskargument rather thanfindTask(id)— by the time it is called the lookup already returns empty. -
eventLog
- Specified by:
eventLogin interfaceNaruSession
-
findTaskIdsByParent
public long[] findTaskIdsByParent(long taskId) - Specified by:
findTaskIdsByParentin interfaceNaruSession
-
routines
- Specified by:
routinesin interfaceNaruSession
-
getSessionEnv
- Specified by:
getSessionEnvin interfaceNaruSession
-
loadModelConfig
- Specified by:
loadModelConfigin interfaceNaruSession
-
saveModelConfig
- Specified by:
saveModelConfigin interfaceNaruSession
-
routine
public net.thevpc.nuts.util.NOptional<NaruRoutine> routine(String nameOrPath, NaruTask task, boolean orCreate) - Specified by:
routinein interfaceNaruSession
-
fireChangedTask
public void fireChangedTask(long id)
-