modus
Menu
On this page

The entry assistant

The source src/modules/applications/assistant built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.

The assistant: a window where the principal asks an agent for help, and reads the conversation: the replies of the agent, each act that it proposes, and the result of each act.

What it is for. The agent runs on the host: modustool assistant reads each request through remote, asks a language model, runs each act of its reply through the host agent bridge, and gives the outcome back. An act that the bridge stops for the principal shows the act dialog of the trusted display; the principal decides it there, never the agent.

Start: the start menu, or start("assistant") in the console. Type a request, then Enter.

Grants, as the root service gives them:

  • Serve: its exports, for the agent runner through remote.
  • Connect to the role Display, with the boot image: the act dialog. The term asks_acts lets it ask the trusted display for an act dialog, and for nothing else that serves the principal: it acts for nobody.

See: The assistant in the repository

assistant module with an entry

Hash
9462cc0150d43c203ea9ca24326dea3c1021d95031d8ba824dcf1d66526dc8c8
Size
281299 bytes
Exports
8
Imports
1
Imported by
0
License
MIT

The assistant: a window where the principal asks an agent for help, and reads the conversation: the replies of the agent, each act that it proposes, and the result of each act

FactValue
KindModules with an entry
Sourcesrc/modules/applications/assistant
Boot imageyes: in the boot image, 281299 bytes in this build
Build settings
  • DRAWING_THROUGH_MODULE=true
Imports
Imported bynone

Neighbours

What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.

assistant drawing

Exports

ExportWhat it does
request_serial() -> Integergives the serial of the oldest request of the principal that no runner took, or 0 when none waits
request_text(serial: Integer) -> Textgives the text of a request, and marks it taken: request_serial does not give it again
reply(serial: Integer, text: Text, acts: Integer) -> Integershows the text of the reply of the model to a request that a runner took, with the count of its acts
reply_refused(serial: Integer, kind: Integer, unit: Integer, argument: Integer, value: Integer, limit: Integer) -> Integershows that the runner refused the reply of the model to a request at its border: the words of the error record of that refusal
act(serial: Integer, kind: Integer, line: Text, service: Text, export: Text) -> Integershows an act that the reply of the model to a request proposes, before the bridge answers it, and gives its number
act_result(act: Integer, state: Integer, text: Text) -> Integershows the answer of the bridge to an act: done with its result, refused with why, or waiting for the principal, which shows the act dialog of the trusted display
act_table(act: Integer, shape: Integer, name: Text, total_rows: Integer, columns: Table(Act_Table_Column, Read), cells: Table(Act_Table_Cell, Read)) -> Integergives the typed result of an act that is done, a table or a record, so the window draws it as the console does: a line of heads, aligned columns, the first rows and the count of the others
act_state(act: Integer) -> Integergives the state of an act, a word of assistant.Act_State: the runner reads the decision of the principal on an act that waited
entry()The entry of the assistant: it opens its service and its window, then runs the calls of the runner and the events of the window in one loop

request_serial

request_serial() -> 

request_serial gives the serial of the oldest request of the principal that no runner took, or 0 when none waits.

What it is for. The agent runner on the host asks for the next request through remote, then reads its text with request_text.

Grant: the caller must act for the principal; else No_Grant (-1).

Parameters
none
Result
When it fails
a negative result, and the error record
Source
src/modules/applications/assistant/conversation.odin:56

request_text

request_text(serial: ) -> 

request_text gives the text of a request, and marks it taken: request_serial does not give it again.

The result is the count of bytes of the text, or a negative number with an error record: No_Grant (-1, the caller does not act for the principal); Absent (-1, no request of the window has this serial); Too_Long (-1, the result has less room than the text: the request is not taken).

Parameters
  • serial:
Result
When it fails
a negative result, and the error record
Source
src/modules/applications/assistant/conversation.odin:66

reply

reply(serial: , text: , acts: ) -> 

reply shows the text of the reply of the model to a request that a runner took, with the count of its acts.

  • serial: the request.
  • text: the reply, at most 1024 bytes.
  • acts: the count of the acts of the reply, 0 to 4: the window takes that many acts of the request, and no more.

The result is the count of bytes kept, or a negative number with an error record: No_Grant (-1); Absent (-1, no request has the serial, or it was not taken); State (-1, the request has its reply already); Empty, Too_Long or Bad_Value (-1, the text has no byte, more than 1024 bytes, or a control byte or a damaged character); Bad_Value or Too_Long (-1, a count of acts under 0 or over 4).

Parameters
  • serial:
  • text:
  • acts:
Result
When it fails
a negative result, and the error record
Source
src/modules/applications/assistant/conversation.odin:85

reply_refused

reply_refused(serial: , kind: , unit: , argument: , value: , limit: ) -> 

reply_refused shows that the runner refused the reply of the model to a request at its border: the words of the error record of that refusal. No act of that reply runs, and the turn of the request ends.

The result is 1, or a negative number with an error record: No_Grant (-1); Absent (-1, no request taken has the serial); State (-1, the request has its reply already); Bad_Value (-1, a kind or a unit that names no member of the contract, or the kind None).

Parameters
  • serial:
  • kind:
  • unit:
  • argument:
  • value:
  • limit:
Result
When it fails
a negative result, and the error record
Source
src/modules/applications/assistant/conversation.odin:99

act

act(serial: , kind: , line: , service: , export: ) -> 

act shows an act that the reply of the model to a request proposes, before the bridge answers it, and gives its number.

  • serial: the request.
  • kind: the kind of the act, a word of assistant.Act_Kind: 1 a line of Lex.
  • line: the line of the act, at most 200 bytes.
  • service, export: the names of the one call of the line, which the runner parsed: two identifiers of 31 bytes at most, or two empty texts for a line that is no single call. The act dialog shows them.

The result is the number of the act, from 1, or a negative number with an error record: No_Grant (-1); Absent (-1, no request taken has the serial); State (-1, no reply counted this act: the reply did not come, was refused, or its acts came); Bad_Value (-1, a kind that names no member, or a name that is no identifier); Empty, Too_Long or Bad_Value (-1, the line).

Parameters
  • serial:
  • kind:
  • line:
  • service:
  • export:
Result
When it fails
a negative result, and the error record
Source
src/modules/applications/assistant/conversation.odin:122

act_result

act_result(act: , state: , text: ) -> 

act_result shows the answer of the bridge to an act: done with its result, refused with why, or waiting for the principal, which shows the act dialog of the trusted display.

  • act: the number that act gave.
  • state: a word of assistant.Act_State that the runner may write: 2 done, 3 refused, 4 waiting for the principal.
  • text: the result or the refusal, as words for the principal.

The result is 1, or a negative number with an error record: No_Grant (-1); Absent (-1, no act has the number); Bad_Value (-1, a state that names no member, one that the runner may not write, or waiting for an act with no names); State (-1, the act has an outcome already); Empty, Too_Long or Bad_Value (-1, the text).

Parameters
  • act:
  • state:
  • text:
Result
When it fails
a negative result, and the error record
Source
src/modules/applications/assistant/conversation.odin:140

act_table

act_table(act: , shape: , name: , total_rows: , columns: (, Read), cells: (, Read)) -> 

act_table gives the typed result of an act that is done, a table or a record, so the window draws it as the console does: a line of heads, aligned columns, the first rows and the count of the others.

  • act: the number that act gave; the act is done.
  • shape: a word of assistant.Act_Table_Shape: 1 a table, 2 a record of one row.
  • name: the name of the record, at most 32 bytes.
  • total_rows: the rows of the whole result; the cells hold the first ones.
  • columns: a table of Act_Table_Column rows, 1 to 24: the name of a column, its kind (a word of agent_bridge.Lex_Column_Kind: 1 text, 2 integer, 3 size, 4 time, 5 hexadecimal) and its unit word.
  • cells: a table of Act_Table_Cell rows, row after row, a cell for each column: the text of a text column, the value of a number column; at most 8 rows of the result.

The result is 1, or a negative number with an error record: No_Grant (-1); Absent (-1, no act has the number); State (-1, the act is not done, or has its table); Bad_Value (-1, a shape or a column kind that names no member, a unit that does not fit its kind, a text in a number cell or a value in a text cell, a record of another count of rows than 1, a total under the rows, a count of cells that is no whole count of rows, an empty column name, or a name or a cell that is not UTF-8 with no control byte or that has a byte after its zero); Empty or Too_Long (-1, the name, no column or more than 24, more than 8 rows).

Parameters
  • act:
  • shape:
  • name:
  • total_rows:
  • columns: (, Read)
  • cells: (, Read)
Result
When it fails
a negative result, and the error record
Source
src/modules/applications/assistant/conversation.odin:180

act_state

act_state(act: ) -> 

act_state gives the state of an act, a word of assistant.Act_State: the runner reads the decision of the principal on an act that waited.

The result is the state, or a negative number with an error record: No_Grant (-1); Absent (-1, no act has the number).

Parameters
  • act:
Result
When it fails
a negative result, and the error record
Source
src/modules/applications/assistant/conversation.odin:206

entry

entry()

The entry of the assistant: it opens its service and its window, then runs the calls of the runner and the events of the window in one loop. While an act waits for the principal, the loop also wakes to read the decision of the act dialog.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/applications/assistant/main.odin:202

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsA window and a service: the agent runner on the host calls its exports through remote, and it asks the trusted display for the act dialog with the term asks_acts. It acts for nobody: the grant to act for the principal would open each export of the display that serves the principal. The boot image checks that the holder of Display has the act dialog. See: The assistant: The right to ask an act in the repository
Other terms of its start grant setcallable = {0 = "display"}, asks_acts = true
Budget that it asks for
  • working memory pages 2110
  • pages of its threads 72
  • pages of the pictures of its window 3325
  • pages of the module and its imports from the files of the build
  • processes the least
  • threads the least
The window, the entries of the conversation (about 940 KiB: each act keeps the cells of its typed result, 14 KiB), the kept lines of three results (about 100 KiB), the two draw tables of the worst frame (about 130 KiB: result_table.odin), the stack, and the glyph memory of a window of paint, which this process draws as: the tool counts the window at the window bound (Module contract, "The budget that a module asks for").

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.

Error_Record record of a module

A record of the module assistant: 56 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Text wire form

A wire form of the module contract: one word of a call. The address of a slice record {address, count} of UTF-8 bytes.

Table wire form

A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).

Act_Table_Column record of a module

A record of the module assistant: 48 bytes, aligned on 8 bytes, 0 bytes of padding.

  • nameText(32)032 bytes
  • kindi64328 bytes
  • uniti64408 bytes

Act_Table_Cell record of a module

A record of the module assistant: 72 bytes, aligned on 8 bytes, 0 bytes of padding.

  • textText(64)064 bytes
  • integeri64648 bytes